Search in sources :

Example 1 with StaticRoutes

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));
}
Also used : StaticRoute(com.cloud.agent.resource.virtualnetwork.model.StaticRoute) StaticRouteProfile(com.cloud.network.vpc.StaticRouteProfile) SetStaticRouteCommand(com.cloud.agent.api.routing.SetStaticRouteCommand) StaticRoutes(com.cloud.agent.resource.virtualnetwork.model.StaticRoutes) LinkedList(java.util.LinkedList)

Aggregations

SetStaticRouteCommand (com.cloud.agent.api.routing.SetStaticRouteCommand)1 StaticRoute (com.cloud.agent.resource.virtualnetwork.model.StaticRoute)1 StaticRoutes (com.cloud.agent.resource.virtualnetwork.model.StaticRoutes)1 StaticRouteProfile (com.cloud.network.vpc.StaticRouteProfile)1 LinkedList (java.util.LinkedList)1