Search in sources :

Example 1 with ContrailSubnetIp

use of org.onap.so.adapters.network.beans.ContrailSubnetIp in project so by onap.

the class ContrailSubnetMapper method map.

public ContrailSubnet map() {
    final ContrailSubnet result = new ContrailSubnet();
    if (inputSubnet != null) {
        final String subnetname = this.getSubnetName(inputSubnet);
        result.setSubnetName(subnetname);
        result.setEnableDhcp(inputSubnet.getEnableDHCP());
        result.setDefaultGateway(inputSubnet.getGatewayIp());
        Optional<ContrailSubnetIp> csIp = createSubnet(inputSubnet);
        if (csIp.isPresent()) {
            result.setSubnet(csIp.get());
        }
        Optional<List<ContrailSubnetPool>> pools = this.createContrailSubnetPool(inputSubnet);
        if (pools.isPresent()) {
            result.setAllocationPools(pools.get());
        }
        Optional<ContrailSubnetHostRoutes> routes = this.createContrailSubnetHostRoutes(inputSubnet);
        if (routes.isPresent()) {
            result.setHostRoutes(routes.get());
        }
    }
    return result;
}
Also used : ContrailSubnet(org.onap.so.adapters.network.beans.ContrailSubnet) ContrailSubnetIp(org.onap.so.adapters.network.beans.ContrailSubnetIp) ContrailSubnetHostRoutes(org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes) List(java.util.List) ArrayList(java.util.ArrayList)

Example 2 with ContrailSubnetIp

use of org.onap.so.adapters.network.beans.ContrailSubnetIp in project so by onap.

the class ContrailSubnetMapper method createSubnet.

protected Optional<ContrailSubnetIp> createSubnet(final Subnet subnet) {
    Optional<ContrailSubnetIp> result = Optional.empty();
    if (!isNullOrEmpty(subnet.getCidr())) {
        int idx = subnet.getCidr().indexOf("/");
        final ContrailSubnetIp csIp = new ContrailSubnetIp();
        if (idx != -1) {
            csIp.setIpPrefix(subnet.getCidr().substring(0, idx));
            csIp.setIpPrefixLen(subnet.getCidr().substring(idx + 1));
            result = Optional.of(csIp);
        }
    }
    return result;
}
Also used : ContrailSubnetIp(org.onap.so.adapters.network.beans.ContrailSubnetIp)

Aggregations

ContrailSubnetIp (org.onap.so.adapters.network.beans.ContrailSubnetIp)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ContrailSubnet (org.onap.so.adapters.network.beans.ContrailSubnet)1 ContrailSubnetHostRoutes (org.onap.so.adapters.network.beans.ContrailSubnetHostRoutes)1