use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder in project genius by opendaylight.
the class VtepConfigSchemaListener method deAllocateIpAddresses.
/**
* De-allocate ip addresses.
*
* @param freeIps
* the free ips
* @param subnetCidr
* the subnet cidr
*/
private void deAllocateIpAddresses(List<IpAddress> freeIps, String subnetCidr) {
VtepIpPool vtepIpPool = getVtepIpPool(subnetCidr);
if (freeIps != null && !freeIps.isEmpty() && vtepIpPool != null) {
// Remove from the allocated IP address list and add to available IP
// address list.
VtepIpPoolBuilder builder = new VtepIpPoolBuilder(vtepIpPool);
if (builder.getAllocatedIpaddress() != null) {
builder.getAllocatedIpaddress().removeAll(freeIps);
}
if (builder.getAvailableIpaddress() == null) {
builder.setAvailableIpaddress(freeIps);
} else {
builder.getAvailableIpaddress().addAll(freeIps);
}
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepIpPoolIdentifier(subnetCidr), builder.build());
LOG.debug("Vtep IP Pool with key:{} updated to config DS", subnetCidr);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder in project genius by opendaylight.
the class VtepConfigSchemaListener method allocateIpAddresses.
/**
* Allocate ip addresses.
*
* @param allocatedIps
* the allocated ips
* @param vtepIpPool
* the vtep ip pool
* @param subnetCidr
* the subnet cidr
*/
private void allocateIpAddresses(List<IpAddress> allocatedIps, VtepIpPool vtepIpPool, String subnetCidr) {
if (allocatedIps != null && !allocatedIps.isEmpty() && vtepIpPool != null) {
// Remove from the available IP address list and add to allocated IP
// address list.
VtepIpPoolBuilder builder = new VtepIpPoolBuilder(vtepIpPool);
if (builder.getAvailableIpaddress() != null) {
builder.getAvailableIpaddress().removeAll(allocatedIps);
}
if (builder.getAllocatedIpaddress() == null) {
builder.setAllocatedIpaddress(allocatedIps);
} else {
builder.getAllocatedIpaddress().addAll(allocatedIps);
}
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepIpPoolIdentifier(subnetCidr), builder.build());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder in project genius by opendaylight.
the class VtepConfigSchemaListener method processAvailableIps.
/**
* Calculate available IPs from the subnet mask specified in the schema.
* Pushes the available and allocated IP address to config DS.
*
* @param schema
* the schema
*/
private VtepIpPool processAvailableIps(final VtepConfigSchema schema) {
String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
SubnetUtils subnetUtils = new SubnetUtils(subnetCidr);
List<IpAddress> availableIps = calculateAvailableIps(subnetUtils, schema.getExcludeIpFilter(), schema.getGatewayIp());
VtepIpPool vtepIpPool = new VtepIpPoolBuilder().setSubnetCidr(subnetCidr).setAvailableIpaddress(availableIps).setAllocatedIpaddress(new ArrayList<>()).build();
MDSALUtil.syncWrite(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepIpPoolIdentifier(subnetCidr), vtepIpPool);
LOG.info("Vtep IP Pool with key:{} added to config DS", subnetCidr);
return vtepIpPool;
}
Aggregations