use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel in project genius by opendaylight.
the class ItmExternalTunnelDeleteWorker method deleteTunnels.
public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, Collection<DPNTEPsInfo> dpnTepsList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
LOG.trace(" Delete Tunnels towards DC Gateway with Ip {}", extIp);
if (dpnTepsList == null || dpnTepsList.isEmpty()) {
LOG.debug("no vtep to delete");
return Collections.emptyList();
}
WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
for (DPNTEPsInfo teps : dpnTepsList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
String interfaceName = firstEndPt.getInterfaceName();
String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
ItmUtils.ITM_CACHE.removeInterface(trunkInterfaceName);
InstanceIdentifier<ExternalTunnel> path = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, ItmUtils.getExternalTunnelKey(String.valueOf(extIp.getValue()), teps.getDPNID().toString(), tunType));
writeTransaction.delete(LogicalDatastoreType.CONFIGURATION, path);
LOG.debug("Deleting tunnel towards DC gateway, Tunnel interface name {} ", trunkInterfaceName);
ItmUtils.ITM_CACHE.removeExternalTunnel(trunkInterfaceName);
// Release the Ids for the trunk interface Name
ItmUtils.releaseIdForTrunkInterfaceName(interfaceName, new String(firstEndPt.getIpAddress().getValue()), new String(extIp.getValue()), tunType.getName());
}
return Collections.singletonList(writeTransaction.submit());
}
Aggregations