Search in sources :

Example 6 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 ItmProvider method deleteAllVtepSchemas.

@Override
public void deleteAllVtepSchemas() {
    List<VtepConfigSchema> lstSchemas = getAllVtepConfigSchemas();
    if (lstSchemas != null && !lstSchemas.isEmpty()) {
        for (VtepConfigSchema schema : lstSchemas) {
            MDSALUtil.syncDelete(this.dataBroker, LogicalDatastoreType.CONFIGURATION, ItmUtils.getVtepConfigSchemaIdentifier(schema.getSchemaName()));
        }
    }
    LOG.debug("Deleted all Vtep schemas from config DS");
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema)

Example 7 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 validateForSingleGreTep.

private static void validateForSingleGreTep(String schemaName, List<BigInteger> lstDpnsForAdd, List<VtepConfigSchema> existingSchemas) {
    for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
        if (TunnelTypeGre.class.equals(existingSchema.getTunnelType()) && !StringUtils.equalsIgnoreCase(schemaName, existingSchema.getSchemaName())) {
            List<BigInteger> lstConflictingDpns = new ArrayList<>(getDpnIdList(existingSchema.getDpnIds()));
            lstConflictingDpns.retainAll(emptyIfNull(lstDpnsForAdd));
            if (!lstConflictingDpns.isEmpty()) {
                String errMsg = "DPN's " + lstConflictingDpns + " already configured with GRE TEP. Mutiple GRE TEP's on a single DPN are not allowed.";
                Preconditions.checkArgument(false, errMsg);
            }
        }
    }
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger)

Example 8 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 validateForUpdateVtepSchema.

public static VtepConfigSchema validateForUpdateVtepSchema(String schemaName, List<BigInteger> lstDpnsForAdd, List<BigInteger> lstDpnsForDelete, IITMProvider itmProvider) {
    Preconditions.checkArgument(StringUtils.isNotBlank(schemaName));
    if ((lstDpnsForAdd == null || lstDpnsForAdd.isEmpty()) && (lstDpnsForDelete == null || lstDpnsForDelete.isEmpty())) {
        Preconditions.checkArgument(false, "DPN ID list for add | delete is null or empty in schema " + schemaName);
    }
    VtepConfigSchema schema = itmProvider.getVtepConfigSchema(schemaName);
    if (schema == null) {
        Preconditions.checkArgument(false, "Specified VTEP Schema [" + schemaName + "] doesn't exists!");
    }
    List<BigInteger> existingDpnIds = getDpnIdList(schema.getDpnIds());
    if (isNotEmpty(lstDpnsForAdd)) {
        List<BigInteger> lstAlreadyExistingDpns = new ArrayList<>(existingDpnIds);
        lstAlreadyExistingDpns.retainAll(lstDpnsForAdd);
        Preconditions.checkArgument(lstAlreadyExistingDpns.isEmpty(), "DPN ID's " + lstAlreadyExistingDpns + " already exists in VTEP schema [" + schemaName + "]");
        if (schema.getTunnelType().equals(TunnelTypeGre.class)) {
            validateForSingleGreTep(schema.getSchemaName(), lstDpnsForAdd, itmProvider.getAllVtepConfigSchemas());
        }
    }
    if (isNotEmpty(lstDpnsForDelete)) {
        if (existingDpnIds.isEmpty()) {
            String builder = "DPN ID's " + lstDpnsForDelete + " specified for delete from VTEP schema [" + schemaName + "] are not configured in the schema.";
            Preconditions.checkArgument(false, builder);
        } else if (!existingDpnIds.containsAll(lstDpnsForDelete)) {
            List<BigInteger> lstConflictingDpns = new ArrayList<>(lstDpnsForDelete);
            lstConflictingDpns.removeAll(existingDpnIds);
            String builder = "DPN ID's " + lstConflictingDpns + " specified for delete from VTEP schema [" + schemaName + "] are not configured in the schema.";
            Preconditions.checkArgument(false, builder);
        }
    }
    return schema;
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) ArrayList(java.util.ArrayList) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) TunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.TunnelList) DcGatewayIpList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.DcGatewayIpList) List(java.util.List)

Example 9 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 getConflictingDpnsAlreadyConfiguredWithTz.

private static List<BigInteger> getConflictingDpnsAlreadyConfiguredWithTz(String schemaName, String tzone, List<BigInteger> lstDpns, List<VtepConfigSchema> existingSchemas) {
    List<BigInteger> lstConflictingDpns = new ArrayList<>();
    for (VtepConfigSchema schema : emptyIfNull(existingSchemas)) {
        if (!StringUtils.equalsIgnoreCase(schemaName, schema.getSchemaName()) && StringUtils.equals(schema.getTransportZoneName(), tzone)) {
            lstConflictingDpns = new ArrayList<>(getDpnIdList(schema.getDpnIds()));
            lstConflictingDpns.retainAll(lstDpns);
            if (!lstConflictingDpns.isEmpty()) {
                break;
            }
        }
    }
    return lstConflictingDpns;
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger)

Example 10 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 constructVtepConfigSchema.

public static VtepConfigSchema constructVtepConfigSchema(String schemaName, String portName, Integer vlanId, String subnetMask, String gatewayIp, String transportZone, String tunnelType, List<BigInteger> dpnIds, String excludeIpFilter) {
    IpAddress gatewayIpObj = StringUtils.isBlank(gatewayIp) ? null : IpAddressBuilder.getDefaultInstance(gatewayIp);
    IpPrefix subnet = StringUtils.isBlank(subnetMask) ? null : IpPrefixBuilder.getDefaultInstance(subnetMask);
    Class<? extends TunnelTypeBase> tunType;
    if (tunnelType.equals(ITMConstants.TUNNEL_TYPE_VXLAN)) {
        tunType = TunnelTypeVxlan.class;
    } else {
        tunType = TunnelTypeGre.class;
    }
    VtepConfigSchemaBuilder schemaBuilder = new VtepConfigSchemaBuilder().setSchemaName(schemaName).setPortName(portName).setVlanId(vlanId).setSubnet(subnet).setGatewayIp(gatewayIpObj).setTransportZoneName(transportZone).setTunnelType(tunType).setDpnIds(getDpnIdsListFromBigInt(dpnIds)).setExcludeIpFilter(excludeIpFilter);
    return schemaBuilder.build();
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) VtepConfigSchemaBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchemaBuilder) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

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