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;
}
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;
}
Aggregations