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");
}
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);
}
}
}
}
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;
}
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;
}
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();
}
Aggregations