use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.
the class VtepConfigSchemaListener method deleteVteps.
/**
* Delete vteps.
*
* @param schema
* the schema
* @param lstDpnIdsToBeDeleted
* the dpn ids list to be deleted
*/
private void deleteVteps(VtepConfigSchema schema, List<BigInteger> lstDpnIdsToBeDeleted) {
TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig);
List<IpAddress> freeIps = new ArrayList<>();
String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
String gatewayIp = handleGatewayIp(schema.getGatewayIp());
for (BigInteger dpnId : lstDpnIdsToBeDeleted) {
VtepsKey vtepkey = new VtepsKey(dpnId, schema.getPortName());
InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(schema.getTransportZoneName())).child(Subnets.class, new SubnetsKey(schema.getSubnet())).child(Vteps.class, vtepkey).build();
Vteps vtep;
Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
if (vtepOptional.isPresent()) {
vtep = vtepOptional.get();
} else {
LOG.warn("VTEP doesn't exist for DPN [{}] and port [{}].", dpnId, schema.getPortName());
continue;
}
IpAddress ipAddress = vtep.getIpAddress();
try {
tepCommandHelper.deleteVtep(dpnId, vtep.getPortname(), schema.getVlanId(), String.valueOf(ipAddress.getValue()), subnetCidr, gatewayIp, schema.getTransportZoneName(), null);
} catch (TepException e) {
LOG.error("delete Vtep Failed", e);
}
freeIps.add(ipAddress);
}
LOG.debug("Delete OnCommit in NewlyAddedDpns");
tepCommandHelper.deleteOnCommit();
deAllocateIpAddresses(freeIps, subnetCidr);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.
the class TepCommandHelper method deleteVtep.
@SuppressWarnings("checkstyle:IllegalCatch")
public void deleteVtep(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
final VtepsKey vtepkey = new VtepsKey(dpnId);
IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
Vteps vtepCli;
InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Vteps.class, vtepkey).build();
// check if present in tzones and delete from cache
boolean existsInCache = isInCache(dpnId, ipAddress, transportZone);
if (!existsInCache) {
Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
if (vtepOptional.isPresent()) {
vtepCli = vtepOptional.get();
if (Objects.equals(vtepCli.getIpAddress(), ipAddressObj)) {
vtepDelCommitList.add(vtepCli);
}
} else {
handleError("Vtep Doesnt exist");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.
the class TepCommandHelper method createLocalCache.
@SuppressWarnings("checkstyle:IllegalCatch")
public void createLocalCache(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
CHECK.incrementAndGet();
IpAddress ipAddressObj;
final VtepsKey vtepkey = new VtepsKey(dpnId);
ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
if (checkTepPerTzPerDpn(transportZone, dpnId)) {
handleError("Only one end point per transport Zone per Dpn is allowed");
return;
}
Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
if (transportZonesHashMap.containsKey(transportZone)) {
List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
if (!vtepListTemp.contains(vtepCli)) {
vtepListTemp.add(vtepCli);
}
} else {
List<Vteps> vtepListTemp = new ArrayList<>();
vtepListTemp.add(vtepCli);
transportZonesHashMap.put(transportZone, vtepListTemp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.
the class TepCommandHelper method isInCache.
// deletes from ADD-cache if it exists.
public boolean isInCache(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
boolean exists = false;
final VtepsKey vtepkey = new VtepsKey(dpnId);
IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
if (transportZonesHashMap.containsKey(transportZone)) {
List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
if (vtepListTemp.contains(vtepCli)) {
// return true if tzones has vtep
exists = true;
vtepListTemp.remove(vtepCli);
if (vtepListTemp.size() == 0) {
transportZonesHashMap.remove(transportZone);
}
} else {
handleError("Vtep has not been configured");
}
}
return exists;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.
the class ItmUtils method getDpIdFromTransportzone.
public static List<Uint64> getDpIdFromTransportzone(DataBroker dataBroker, String tzone) {
List<Uint64> listOfDpId = new ArrayList<>();
InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
if (transportZoneOptional.isPresent()) {
TransportZone transportZone = transportZoneOptional.get();
if (transportZone.getVteps() != null && !transportZone.getVteps().isEmpty()) {
@Nullable Map<VtepsKey, Vteps> vtepsList = transportZone.getVteps();
if (vtepsList != null && !vtepsList.isEmpty()) {
for (Vteps vtep : vtepsList.values()) {
listOfDpId.add(vtep.getDpnId());
}
}
}
}
return listOfDpId;
}
Aggregations