use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class ItmUtils method validateForAddVtepConfigSchema.
public static VtepConfigSchema validateForAddVtepConfigSchema(VtepConfigSchema schema, List<VtepConfigSchema> existingSchemas) {
VtepConfigSchema validSchema = validateVtepConfigSchema(schema);
for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
if (!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName()) && schema.getSubnet().equals(existingSchema.getSubnet())) {
String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
Preconditions.checkArgument(false, "VTEP schema with subnet [" + subnetCidr + "] already exists. Multiple VTEP schemas with same subnet is not allowed.");
}
}
if (isNotEmpty(getDpnIdList(validSchema.getDpnIds()))) {
String tzone = validSchema.getTransportZoneName();
List<BigInteger> lstDpns = getConflictingDpnsAlreadyConfiguredWithTz(validSchema.getSchemaName(), tzone, getDpnIdList(validSchema.getDpnIds()), existingSchemas);
if (!lstDpns.isEmpty()) {
Preconditions.checkArgument(false, "DPN's " + lstDpns + " already configured for transport zone " + tzone + ". Only one end point per transport Zone per Dpn is allowed.");
}
if (schema.getTunnelType().equals(TunnelTypeGre.class)) {
validateForSingleGreTep(validSchema.getSchemaName(), getDpnIdList(validSchema.getDpnIds()), existingSchemas);
}
}
return validSchema;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema in project genius by opendaylight.
the class VtepConfigSchemaListener method add.
@Override
public void add(@Nonnull VtepConfigSchema vtepConfigSchema) {
// Construct the transport zones from the provided schemas and push it to config DS
LOG.trace("Add VtepConfigSchema: {}", vtepConfigSchema);
VtepConfigSchema validatedSchema = ItmUtils.validateForAddVtepConfigSchema(vtepConfigSchema, getAllVtepConfigSchemas());
VtepIpPool vtepIpPool = processAvailableIps(validatedSchema);
addVteps(validatedSchema, vtepIpPool);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema 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