Search in sources :

Example 16 with VtepConfigSchema

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;
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) BigInteger(java.math.BigInteger)

Example 17 with VtepConfigSchema

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);
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) VtepIpPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)

Example 18 with VtepConfigSchema

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

VtepConfigSchema (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)13 BigInteger (java.math.BigInteger)7 ArrayList (java.util.ArrayList)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 VtepConfigSchemaBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder)4 VtepIpPool (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)3 SubnetUtils (org.apache.commons.net.util.SubnetUtils)2 TepCommandHelper (org.opendaylight.genius.itm.cli.TepCommandHelper)2 TepException (org.opendaylight.genius.itm.cli.TepException)2 List (java.util.List)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 TunnelTypeGre (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre)1 DpnIds (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.vtep.config.schema.DpnIds)1 VtepIpPoolBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPoolBuilder)1 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)1 TunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelList)1 StateTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)1 DcGatewayIpList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList)1 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)1 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)1