use of com.cloud.agent.resource.virtualnetwork.model.StaticRoutes in project cloudstack by apache.
the class SetStaticRouteConfigItem method generateConfig.
@Override
public List<ConfigItem> generateConfig(final NetworkElementCommand cmd) {
final SetStaticRouteCommand command = (SetStaticRouteCommand) cmd;
final LinkedList<StaticRoute> routes = new LinkedList<>();
for (final StaticRouteProfile profile : command.getStaticRoutes()) {
final String cidr = profile.getCidr();
final String subnet = NetUtils.getCidrSubNet(cidr);
final String cidrSize = cidr.split("\\/")[1];
final boolean keep = profile.getState() == com.cloud.network.vpc.StaticRoute.State.Active || profile.getState() == com.cloud.network.vpc.StaticRoute.State.Add;
routes.add(new StaticRoute(!keep, profile.getIp4Address(), profile.getGateway(), subnet + "/" + cidrSize));
}
return generateConfigItems(new StaticRoutes(routes));
}
Aggregations