Merge "Bug 5092 : Flow incorrectly installed for LLDP mon"
authorVishal Thapar <vishal.thapar@ericsson.com>
Fri, 19 Feb 2016 08:31:33 +0000 (08:31 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 19 Feb 2016 08:31:33 +0000 (08:31 +0000)
1  2 
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelDeleteWorker.java

index fc9a3a72bec9e643941d3a6ba657d219b3e90ae5,7b4e06dfc9ce7a9eae8301aec1ae99fd450fa531..9e113f25b04887fddeb07d938ac43c7afd66dc19
@@@ -18,6 -18,7 +18,7 @@@ import org.opendaylight.controller.md.s
  import org.opendaylight.vpnservice.itm.impl.ItmUtils;
  import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+ import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.DpnEndpoints;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.TunnelList;
  import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
@@@ -34,7 -35,7 +35,7 @@@ import com.google.common.util.concurren
  public class ItmInternalTunnelDeleteWorker {
     private static final Logger logger = LoggerFactory.getLogger(ItmInternalTunnelDeleteWorker.class) ;
  
-     public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService,
+     public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService,IMdsalApiManager mdsalManager,
                                                               List<DPNTEPsInfo> dpnTepsList, List<DPNTEPsInfo> meshedDpnList)
      {
          List<ListenableFuture<Void>> futures = new ArrayList<>();
                              for (TunnelEndPoints dstTep : dstDpn.getTunnelEndPoints()) {
                                  logger.trace("Processing dstTep " + dstTep);
                                  if (dstTep.getTransportZone().equals(srcTZone)) {
 +                                    if( checkIfTrunkExists(dstDpn.getDPNID(), srcDpn.getDPNID(), dataBroker)) {
                                      // remove all trunk interfaces
                                      logger.trace("Invoking removeTrunkInterface between source TEP {} , Destination TEP {} " ,srcTep , dstTep);
                                      removeTrunkInterface(dataBroker, idManagerService, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
 +                                    }
                                  }
                              }
                          }
@@@ -88,7 -87,7 +89,7 @@@
                          // remove dpn if no vteps exist on dpn
                          if (dpnRead.getTunnelEndPoints() == null || dpnRead.getTunnelEndPoints().size() == 0) {
                              logger.debug( "Removing Terminating Service Table Flow ") ;
-                            // setUpOrRemoveTerminatingServiceTable(dpnRead.getDPNID(), false);
+                            ItmUtils.setUpOrRemoveTerminatingServiceTable(dpnRead.getDPNID(), mdsalManager,false);
                              logger.trace("DPN Removal from DPNTEPSINFO CONFIG DS " + dpnRead);
                              t.delete(LogicalDatastoreType.CONFIGURATION, dpnPath);
                              InstanceIdentifier<DpnEndpoints> tnlContainerPath =
@@@ -98,7 -97,7 +99,7 @@@
                                                              tnlContainerPath, dataBroker);
                              // remove container if no DPNs are present
                              if (containerOptional.isPresent()) {
 -                              DpnEndpoints deps = containerOptional.get();
 +                               DpnEndpoints deps = containerOptional.get();
                                  if (deps.getDPNTEPsInfo() == null || deps.getDPNTEPsInfo().isEmpty()) {
                                      logger.trace("Container Removal from DPNTEPSINFO CONFIG DS");
                                      t.delete(LogicalDatastoreType.CONFIGURATION, tnlContainerPath);
                                          .getValue());
          logger.trace("Removing forward Trunk Interface " + trunkfwdIfName);
          InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
 -        logger.debug(  " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
 +        logger.debug(  " Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkfwdIfName, trunkIdentifier ) ;
          t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
  
          // also update itm-state ds -- Delete the forward tunnel-interface from the tunnel list
                  TunnelList.class)
                      .child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId));   
          t.delete(LogicalDatastoreType.CONFIGURATION,path) ;
-         // Release the Id for the forward trunk
-         ItmUtils.releaseId(idManagerService, trunkfwdIfName);
+         // Release the Ids for the forward trunk interface Name
+         ItmUtils.releaseIdForTrunkInterfaceName(idManagerService,srcTep.getInterfaceName(), srcTep.getIpAddress()
+                 .getIpv4Address().getValue(), dstTep.getIpAddress().getIpv4Address()
+                 .getValue() );
  
          String trunkRevIfName =
                          ItmUtils.getTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(), dstTep.getIpAddress()
                                          .getIpv4Address().getValue(), srcTep.getIpAddress().getIpv4Address()
                                          .getValue());
          logger.trace("Removing Reverse Trunk Interface " + trunkRevIfName);
 -        trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
 -        logger.debug(  " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
 +        trunkIdentifier = ItmUtils.buildId(trunkRevIfName);
 +        logger.debug(  " Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkRevIfName, trunkIdentifier ) ;
          t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
  
       // also update itm-state ds -- Delete the reverse tunnel-interface from the tunnel list
                      .child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId));   
          t.delete(LogicalDatastoreType.CONFIGURATION,path) ;
          
-         // Release the Id for the Reverse trunk
-         ItmUtils.releaseId(idManagerService, trunkRevIfName);
+      // Release the Ids for the reverse trunk interface Name
+         ItmUtils.releaseIdForTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(), dstTep.getIpAddress()
+                 .getIpv4Address().getValue(), srcTep.getIpAddress().getIpv4Address()
+                 .getValue());
      }
 +    private static boolean checkIfTrunkExists( BigInteger srcDpnId, BigInteger dstDpnId, DataBroker dataBroker) {
 +        boolean existsFlag = false ;
 +        InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(
 +                TunnelList.class)
 +                    .child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId));   
 +        Optional<InternalTunnel> internalTunnels = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,path, dataBroker) ;
 +        if( internalTunnels.isPresent())
 +            existsFlag = true ;
 +           return existsFlag ;
 +    }
  }