Search in sources :

Example 6 with VtepIpPool

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool 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;
}
Also used : VtepIpPoolBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder) SubnetUtils(org.apache.commons.net.util.SubnetUtils) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepIpPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)

Aggregations

VtepIpPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)4 ArrayList (java.util.ArrayList)3 VtepIpPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder)3 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)2 VtepConfigSchema (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)2 BigInteger (java.math.BigInteger)1 SubnetUtils (org.apache.commons.net.util.SubnetUtils)1 TepCommandHelper (org.opendaylight.genius.itm.cli.TepCommandHelper)1 TepException (org.opendaylight.genius.itm.cli.TepException)1 VtepConfigSchemaBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder)1 DpnIds (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds)1