ITM changes 70/32470/2
authorDeepthi V V <deepthi.v.v@ericsson.com>
Wed, 13 Jan 2016 05:25:54 +0000 (10:55 +0530)
committerDeepthi V V <deepthi.v.v@ericsson.com>
Wed, 13 Jan 2016 05:34:47 +0000 (11:04 +0530)
- namespace change in config xml.
- Tunnel interface name is truncated on node connector up event. Fix tunnel interface name.

Change-Id: I1dbd65f6b8447c6a965c56a49405bda6e0557ee0
Signed-off-by: Deepthi V V <deepthi.v.v@ericsson.com>
13 files changed:
itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/globals/ITMConstants.java
itm/itm-impl/pom.xml
itm/itm-impl/src/main/config/default-config.xml
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmExternalTunnelAddWorker.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmExternalTunnelDeleteWorker.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelAddWorker.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmInternalTunnelDeleteWorker.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmTepAddWorker.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/confighelpers/ItmTepRemoveWorker.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmUtils.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/listeners/TransportZoneListener.java
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/rpc/ItmManagerRpcService.java

index 11c6204173f0229fb5ab53343a74caa63ab85c8c..cff7efe527fe1ffd1e630d5a65700a465bde2e61 100644 (file)
@@ -11,6 +11,13 @@ import java.math.BigInteger;
 
 
 public class ITMConstants{
+
     public static final short INTERNAL_TUNNEL_TABLE = 22;
     public static final BigInteger COOKIE_ITM = new BigInteger("9000000", 16);
+
+  public static final String ITM_IDPOOL_NAME = "Itmservices";
+  public static final long ITM_IDPOOL_START = 1L;
+  public static final String ITM_IDPOOL_SIZE = "100000";
+                
+
 }
index 0e6fc4ff8d1291252b85e2a7ebf09667024efde8..ffbd3c990b0d502422029f6822a141c54d3a0422 100644 (file)
       <artifactId>itm-api</artifactId>
       <version>${vpnservices.version}</version>
     </dependency>
+    <dependency>
+       <groupId>org.opendaylight.vpnservice</groupId>
+       <artifactId>idmanager-api</artifactId>
+       <version>${vpnservices.version}</version>
+    </dependency>
     <dependency>
       <groupId>org.opendaylight.vpnservice</groupId>
       <artifactId>interfacemgr-api</artifactId>
       <groupId>commons-net</groupId>
       <artifactId>commons-net</artifactId>
     </dependency>
+        <dependency>
+            <groupId>org.opendaylight.vpnservice</groupId>
+            <artifactId>idmanager-api</artifactId>
+            <version>0.2.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.vpnservice</groupId>
+            <artifactId>idmanager-api</artifactId>
+            <version>0.2.0-SNAPSHOT</version>
+        </dependency>
     </dependencies>
   </project>
index cb0636057c2e256a34c9c015b2f9a89cec879c1c..302d1f6ef2d6b6435beadb3e4f4ca77017304c90 100644 (file)
@@ -9,8 +9,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
 -->
 <snapshot>
   <required-capabilities>
-      <capability>urn:opendaylight:params:xml:ns:yang:itm?module=itm&amp;revision=2015-07-01</capability>
-      <capability>urn:opendaylight:params:xml:ns:yang:itm:impl?module=itm-impl&amp;revision=2014-12-10</capability>
+      <capability>urn:opendaylight:vpnservice:itm?module=itm&amp;revision=2015-07-01</capability>
+      <capability>urn:opendaylight:vpnservice:itm:impl?module=itm-impl&amp;revision=2014-12-10</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
       <capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&amp;revision=2015-04-10</capability>
@@ -21,7 +21,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
       <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
         <module>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:itm:impl">prefix:itm</type>
+          <type xmlns:prefix="urn:opendaylight:vpnservice:itm:impl">prefix:itm</type>
           <name>itm-default</name>
           <broker>
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
@@ -51,7 +51,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       </modules>
       <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
         <service>
-          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:itm">prefix:itm</type>
+          <type xmlns:prefix="urn:opendaylight:vpnservice:itm">prefix:itm</type>
           <instance>
             <name>itm</name>
             <provider>/modules/module[type='itm'][name='itm-default']</provider>
index 2dcbfcc266d2783ff6cac497d2ee5c05e235d408..c44e96a28157e2c0315f67ad1b22a4fbc0db97d7 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.vpnservice.itm.impl.ItmUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 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.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeGre;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
@@ -48,7 +49,8 @@ public class ItmExternalTunnelAddWorker {
                 };
             };
 
-    public static List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(DataBroker dataBroker,List<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
+    public static List<ListenableFuture<Void>> buildTunnelsToExternalEndPoint(DataBroker dataBroker, IdManagerService idManagerService,
+                                                                              List<DPNTEPsInfo> cfgDpnList, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
        if( null != cfgDpnList) {
@@ -56,7 +58,7 @@ public class ItmExternalTunnelAddWorker {
              // CHECK -- Assumption -- Only one End Point / Dpn for GRE/Vxlan Tunnels
               TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0) ;
               String interfaceName = firstEndPt.getInterfaceName() ;
-              String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
+              String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
               char[] subnetMaskArray = firstEndPt.getSubnetMask().getValue() ;
               String subnetMaskStr = String.valueOf(subnetMaskArray) ;
               SubnetUtils utils = new SubnetUtils(subnetMaskStr);
@@ -86,7 +88,8 @@ public class ItmExternalTunnelAddWorker {
         return futures ;
     }
 
-    public static List<ListenableFuture<Void>> buildTunnelsFromDpnToExternalEndPoint(DataBroker dataBroker, List<BigInteger> dpnId, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
+    public static List<ListenableFuture<Void>> buildTunnelsFromDpnToExternalEndPoint(DataBroker dataBroker, IdManagerService idManagerService,
+                                                                                     List<BigInteger> dpnId, IpAddress extIp, Class<? extends TunnelTypeBase> tunType) {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         List<DPNTEPsInfo> cfgDpnList = new ArrayList<DPNTEPsInfo>() ;
         List<DPNTEPsInfo> meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
@@ -98,7 +101,7 @@ public class ItmExternalTunnelAddWorker {
                      }
                   }
           }
-          futures = buildTunnelsToExternalEndPoint( dataBroker, cfgDpnList, extIp, tunType) ;
+          futures = buildTunnelsToExternalEndPoint( dataBroker, idManagerService, cfgDpnList, extIp, tunType) ;
        }
         return futures ;
     }
index 50a036c09357391435eed063c0095d9b27f27f89..b976155d7d12386f73f095ec4fef5fd56df0d7d7 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.vpnservice.itm.impl.ItmUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 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.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -27,7 +28,8 @@ import com.google.common.util.concurrent.ListenableFuture;
 public class ItmExternalTunnelDeleteWorker {
     private static final Logger logger = LoggerFactory.getLogger(ItmExternalTunnelDeleteWorker.class ) ;
 
-    public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, List<DPNTEPsInfo> dpnTepsList,IpAddress extIp ) {
+    public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService,
+                                                             List<DPNTEPsInfo> dpnTepsList, IpAddress extIp ) {
         logger.trace( " Delete Tunnels towards DC Gateway with Ip  {}", extIp ) ;
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
@@ -39,7 +41,7 @@ public class ItmExternalTunnelDeleteWorker {
             for( DPNTEPsInfo teps : dpnTepsList) {
                 TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0) ;
                 String interfaceName = firstEndPt.getInterfaceName() ;
-                String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
+                String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName, firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue()) ;
                 InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkInterfaceName);
                 t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
             }
index 8e62b9c9e9b95a0816539bef9a04ae1577802a11..faa2c6bf1efac0c6e6dc3b8d4ced67e0551d9957 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 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.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeGre;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan;
@@ -54,7 +55,8 @@ public class ItmInternalTunnelAddWorker {
              };
 
 
-    public static List<ListenableFuture<Void>> build_all_tunnels(DataBroker dataBroker, List<DPNTEPsInfo> cfgdDpnList, List<DPNTEPsInfo> meshedDpnList) {
+    public static List<ListenableFuture<Void>> build_all_tunnels(DataBroker dataBroker, IdManagerService idManagerService,
+                                                                 List<DPNTEPsInfo> cfgdDpnList, List<DPNTEPsInfo> meshedDpnList) {
         logger.trace( "Building tunnels with DPN List {} " , cfgdDpnList );
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
@@ -65,7 +67,7 @@ public class ItmInternalTunnelAddWorker {
 
         for( DPNTEPsInfo dpn : cfgdDpnList) {
             //#####if dpn is not in meshedDpnList
-            build_tunnel_from(dpn, meshedDpnList, dataBroker, t, futures);
+            build_tunnel_from(dpn, meshedDpnList, dataBroker, idManagerService, t, futures);
             if(null == meshedDpnList) {
                 meshedDpnList = new ArrayList<DPNTEPsInfo>() ;
             }
@@ -86,7 +88,7 @@ public class ItmInternalTunnelAddWorker {
         t.merge(LogicalDatastoreType.CONFIGURATION, dep, tnlBuilder, true);
     }
 
-    private static void build_tunnel_from( DPNTEPsInfo srcDpn,List<DPNTEPsInfo> meshedDpnList, DataBroker dataBroker,  WriteTransaction t, List<ListenableFuture<Void>> futures) {
+    private static void build_tunnel_from( DPNTEPsInfo srcDpn,List<DPNTEPsInfo> meshedDpnList, DataBroker dataBroker,  IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
         logger.trace( "Building tunnels from DPN {} " , srcDpn );
 
         if( null == meshedDpnList || 0 == meshedDpnList.size()) {
@@ -95,12 +97,13 @@ public class ItmInternalTunnelAddWorker {
         }
         for( DPNTEPsInfo dstDpn: meshedDpnList) {
             if ( ! srcDpn.equals(dstDpn) )
-                    wireUpWithinTransportZone(srcDpn, dstDpn, dataBroker, t, futures) ;
+                    wireUpWithinTransportZone(srcDpn, dstDpn, dataBroker, idManagerService, t, futures) ;
         }
 
    }
 
-    private static void wireUpWithinTransportZone( DPNTEPsInfo srcDpn, DPNTEPsInfo dstDpn, DataBroker dataBroker,  WriteTransaction t, List<ListenableFuture<Void>> futures) {
+    private static void wireUpWithinTransportZone( DPNTEPsInfo srcDpn, DPNTEPsInfo dstDpn, DataBroker dataBroker,
+                                                   IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
         logger.trace( "Wiring up within Transport Zone for Dpns {}, {} " , srcDpn, dstDpn );
         List<TunnelEndPoints> srcEndPts = srcDpn.getTunnelEndPoints();
         List<TunnelEndPoints> dstEndPts = dstDpn.getTunnelEndPoints();
@@ -111,7 +114,7 @@ public class ItmInternalTunnelAddWorker {
               if (!srcDpn.getDPNID().equals(dstDpn.getDPNID())) {
                 if( (srcte.getTransportZone().equals(dstte.getTransportZone()))) {
                      // wire them up
-                     wireUpBidirectionalTunnel( srcte, dstte, srcDpn.getDPNID(), dstDpn.getDPNID(), dataBroker, t, futures );
+                     wireUpBidirectionalTunnel( srcte, dstte, srcDpn.getDPNID(), dstDpn.getDPNID(), dataBroker, idManagerService, t, futures );
                      // CHECK THIS -- Assumption -- One end point per Dpn per transport zone
                      break ;
                 }
@@ -121,30 +124,30 @@ public class ItmInternalTunnelAddWorker {
     }
 
     private static void wireUpBidirectionalTunnel( TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, BigInteger dstDpnId,
-        DataBroker dataBroker,  WriteTransaction t, List<ListenableFuture<Void>> futures) {
+        DataBroker dataBroker,  IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
        // Setup the flow for LLDP monitoring -- PUNT TO CONTROLLER
        //  setUpOrRemoveTerminatingServiceTable(srcDpnId, true);
        //  setUpOrRemoveTerminatingServiceTable(dstDpnId, true);
 
         // Create the forward direction tunnel
-        if(!wireUp( srcte, dstte, srcDpnId, dstDpnId, dataBroker, t, futures ))
+        if(!wireUp( srcte, dstte, srcDpnId, dstDpnId, dataBroker, idManagerService, t, futures ))
            logger.error("Could not build tunnel between end points {}, {} " , srcte, dstte );
 
         // CHECK IF FORWARD IS NOT BUILT , REVERSE CAN BE BUILT
       // Create the tunnel for the reverse direction
-       if(! wireUp( dstte, srcte, dstDpnId, srcDpnId, dataBroker, t, futures ))
+       if(! wireUp( dstte, srcte, dstDpnId, srcDpnId, dataBroker, idManagerService, t, futures ))
           logger.error("Could not build tunnel between end points {}, {} " , dstte, srcte);
     }
 
-    private static boolean wireUp( TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, BigInteger dstDpnId ,
-          DataBroker dataBroker,  WriteTransaction t, List<ListenableFuture<Void>> futures) {
+    private static boolean wireUp(TunnelEndPoints srcte, TunnelEndPoints dstte, BigInteger srcDpnId, BigInteger dstDpnId ,
+                                  DataBroker dataBroker, IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
         // Wire Up logic
         logger.trace( "Wiring between source tunnel end points {}, destination tunnel end points {} " , srcte, dstte );
         String interfaceName = srcte.getInterfaceName() ;
         Class<? extends TunnelTypeBase> tunType = srcte.getTunnelType();
         String ifDescription = srcte.getTunnelType().getName();
         // Form the trunk Interface Name
-        String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(interfaceName,srcte.getIpAddress().getIpv4Address().getValue(), dstte.getIpAddress().getIpv4Address().getValue()) ;
+        String trunkInterfaceName = ItmUtils.getTrunkInterfaceName(idManagerService, interfaceName,srcte.getIpAddress().getIpv4Address().getValue(), dstte.getIpAddress().getIpv4Address().getValue()) ;
         IpAddress gwyIpAddress = ( srcte.getSubnetMask().equals(dstte.getSubnetMask()) ) ? null : srcte.getGwIpAddress() ;
         logger.debug(  " Creating Trunk Interface with parameters trunk I/f Name - {}, parent I/f name - {}, source IP - {}, destination IP - {} gateway IP - {}",trunkInterfaceName, interfaceName, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress ) ;
         Interface iface = ItmUtils.buildTunnelInterface(srcDpnId, trunkInterfaceName, String.format( "%s %s",ifDescription, "Trunk Interface"), true, tunType, srcte.getIpAddress(), dstte.getIpAddress(), gwyIpAddress) ;
index a6d3d47f418ebed058747341e17da0fe5e402f04..cb0b23f1d86368c7aa2b602119f2f3a2b0a2b8d6 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 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.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.DpnEndpoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
@@ -30,7 +31,8 @@ import com.google.common.util.concurrent.ListenableFuture;
 public class ItmInternalTunnelDeleteWorker {
    private static final Logger logger = LoggerFactory.getLogger(ItmInternalTunnelDeleteWorker.class) ;
 
-    public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, List<DPNTEPsInfo> dpnTepsList, List<DPNTEPsInfo> meshedDpnList)
+    public static List<ListenableFuture<Void>> deleteTunnels(DataBroker dataBroker, IdManagerService idManagerService,
+                                                             List<DPNTEPsInfo> dpnTepsList, List<DPNTEPsInfo> meshedDpnList)
     {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
@@ -58,7 +60,7 @@ public class ItmInternalTunnelDeleteWorker {
                                 if (dstTep.getTransportZone().equals(srcTZone)) {
                                     // remove all trunk interfaces
                                     logger.trace("Invoking removeTrunkInterface between source TEP {} , Destination TEP {} " ,srcTep , dstTep);
-                                    removeTrunkInterface(dataBroker, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
+                                    removeTrunkInterface(dataBroker, idManagerService, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
                                 }
                             }
                         }
@@ -108,10 +110,11 @@ public class ItmInternalTunnelDeleteWorker {
         return futures ;
     }
 
-    private static void removeTrunkInterface(DataBroker dataBroker, TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId,
-        WriteTransaction t, List<ListenableFuture<Void>> futures) {
+    private static void removeTrunkInterface(DataBroker dataBroker, IdManagerService idManagerService,
+                                             TunnelEndPoints srcTep, TunnelEndPoints dstTep, BigInteger srcDpnId, BigInteger dstDpnId,
+                                             WriteTransaction t, List<ListenableFuture<Void>> futures) {
         String trunkfwdIfName =
-                        ItmUtils.getTrunkInterfaceName(srcTep.getInterfaceName(), srcTep.getIpAddress()
+                        ItmUtils.getTrunkInterfaceName(idManagerService, srcTep.getInterfaceName(), srcTep.getIpAddress()
                                         .getIpv4Address().getValue(), dstTep.getIpAddress().getIpv4Address()
                                         .getValue());
         logger.trace("Removing forward Trunk Interface " + trunkfwdIfName);
@@ -119,7 +122,7 @@ public class ItmInternalTunnelDeleteWorker {
         logger.debug(  " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
         t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
         String trunkRevIfName =
-                        ItmUtils.getTrunkInterfaceName(dstTep.getInterfaceName(), dstTep.getIpAddress()
+                        ItmUtils.getTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(), dstTep.getIpAddress()
                                         .getIpv4Address().getValue(), srcTep.getIpAddress().getIpv4Address()
                                         .getValue());
         logger.trace("Removing Reverse Trunk Interface " + trunkRevIfName);
index e6dc9987cb280432e6aada9f121ed96d3dcc5e12..92c17e06e4d9f039cdc6397259fbbdcda0ed45bc 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.vpnservice.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
 import org.slf4j.LoggerFactory;
 import org.slf4j.Logger;
@@ -22,12 +23,14 @@ import org.slf4j.Logger;
 public class ItmTepAddWorker implements Callable<List<ListenableFuture<Void>>> {
     private static final Logger logger = LoggerFactory.getLogger(ItmTepAddWorker.class ) ;
     private DataBroker dataBroker;
+    private IdManagerService idManagerService;
     private List<DPNTEPsInfo> meshedDpnList;
     private List<DPNTEPsInfo> cfgdDpnList ;
 
-    public ItmTepAddWorker( List<DPNTEPsInfo> cfgdDpnList,  DataBroker broker) {
+    public ItmTepAddWorker( List<DPNTEPsInfo> cfgdDpnList,  DataBroker broker, IdManagerService idManagerService) {
         this.cfgdDpnList = cfgdDpnList ;
         this.dataBroker = broker ;
+        this.idManagerService = idManagerService;
         logger.trace("ItmTepAddWorker initialized with  DpnList {}",cfgdDpnList );
     }
 
@@ -36,7 +39,7 @@ public class ItmTepAddWorker implements Callable<List<ListenableFuture<Void>>> {
         List<ListenableFuture<Void>> futures = new ArrayList<>() ;
         this.meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
         logger.debug("Invoking Internal Tunnel build method with Configured DpnList {} ; Meshed DpnList {} ",cfgdDpnList, meshedDpnList );
-        futures.addAll( ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, cfgdDpnList, meshedDpnList) ) ;
+        futures.addAll( ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, idManagerService, cfgdDpnList, meshedDpnList) ) ;
         // IF EXTERNAL TUNNELS NEEDS TO BE BUILT, DO IT HERE. IT COULD BE TO DC GATEWAY OR TOR SWITCH
         //futures.addAll(ItmExternalTunnelAddWorker.buildTunnelsToExternalEndPoint(dataBroker,meshedDpnList, extIp) ;
         return futures ;
index 66ca75029a7188701a38c87c7cc53ca8fb53032b..6c4cb00810ca73fd6b74500778c43ddfead19b1b 100644 (file)
@@ -15,6 +15,7 @@ import com.google.common.util.concurrent.ListenableFuture;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.vpnservice.itm.impl.ItmUtils;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -24,10 +25,12 @@ public class ItmTepRemoveWorker implements Callable<List<ListenableFuture<Void>>
     private DataBroker dataBroker;
     private List<DPNTEPsInfo> delDpnList ;
     private List<DPNTEPsInfo> meshedDpnList ;
+    private IdManagerService idManagerService;
 
-    public ItmTepRemoveWorker( List<DPNTEPsInfo> delDpnList,  DataBroker broker) {
+    public ItmTepRemoveWorker( List<DPNTEPsInfo> delDpnList,  DataBroker broker, IdManagerService idManagerService) {
         this.delDpnList = delDpnList ;
         this.dataBroker = broker ;
+        this.idManagerService = idManagerService;
         logger.trace("ItmTepRemoveWorker initialized with  DpnList {}",delDpnList );
     }
 
@@ -35,7 +38,7 @@ public class ItmTepRemoveWorker implements Callable<List<ListenableFuture<Void>>
     public List<ListenableFuture<Void>> call() throws Exception {
         List<ListenableFuture<Void>> futures = new ArrayList<>() ;
         this.meshedDpnList = ItmUtils.getTunnelMeshInfo(dataBroker) ;
-        futures.addAll( ItmInternalTunnelDeleteWorker.deleteTunnels(dataBroker, delDpnList, meshedDpnList));
+        futures.addAll( ItmInternalTunnelDeleteWorker.deleteTunnels(dataBroker, idManagerService, delDpnList, meshedDpnList));
         logger.debug("Invoking Internal Tunnel delete method with DpnList to be deleted {} ; Meshed DpnList {} ",delDpnList, meshedDpnList );
         // IF EXTERNAL TUNNELS NEEDS TO BE DELETED, DO IT HERE, IT COULD BE TO DC GATEWAY OR TOR SWITCH
         return futures ;
index b805a629c9bc6b3546a2c226225f26e16f957da9..1a4c02961f0f1ffc4df07d779646b3a8ea2825df 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.vpnservice.itm.impl;
 
 import java.math.BigInteger;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -21,9 +22,13 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
 import org.opendaylight.vpnservice.itm.api.IITMProvider;
+import org.opendaylight.vpnservice.itm.globals.ITMConstants;
 import org.opendaylight.vpnservice.itm.listeners.TransportZoneListener;
 import org.opendaylight.vpnservice.itm.rpc.ItmManagerRpcService;
 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.CreateIdPoolInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.ItmRpcService;
 
@@ -40,6 +45,7 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro
     private DataBroker dataBroker;
     private NotificationPublishService notificationPublishService;
     private ItmManagerRpcService itmRpcService ;
+    private IdManagerService idManager;
     private NotificationService notificationService;
     private TransportZoneListener tzChangeListener;
     private RpcProviderRegistry rpcProviderRegistry;
@@ -57,10 +63,11 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro
         LOG.info("ItmProvider Session Initiated");
         try {
             dataBroker = session.getSALService(DataBroker.class);
+            idManager = getRpcProviderRegistry().getRpcService(IdManagerService.class);
 
             itmManager = new ITMManager(dataBroker);
-            tzChangeListener = new TransportZoneListener(dataBroker) ;
-            itmRpcService = new ItmManagerRpcService(dataBroker);
+            tzChangeListener = new TransportZoneListener(dataBroker, idManager) ;
+            itmRpcService = new ItmManagerRpcService(dataBroker, idManager);
             final BindingAwareBroker.RpcRegistration<ItmRpcService> rpcRegistration = getRpcProviderRegistry().addRpcImplementation(ItmRpcService.class, itmRpcService);
             itmRpcService.setMdsalManager(mdsalManager);
             itmManager.setMdsalManager(mdsalManager);
@@ -68,6 +75,7 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro
             itmManager.setMdsalManager(mdsalManager);
             tzChangeListener.setItmManager(itmManager);
             tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+            createIdPool();
         } catch (Exception e) {
             LOG.error("Error initializing services", e);
         }
@@ -100,5 +108,19 @@ public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMPro
         LOG.info("ItmProvider Closed");
     }
 
-
+    private void createIdPool() {
+        CreateIdPoolInput createPool = new CreateIdPoolInputBuilder()
+            .setPoolName(ITMConstants.ITM_IDPOOL_NAME)
+            .setLow(ITMConstants.ITM_IDPOOL_START)
+            .setHigh(new BigInteger(ITMConstants.ITM_IDPOOL_SIZE).longValue())
+            .build();
+        try {
+            Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
+            if ((result != null) && (result.get().isSuccessful())) {
+                LOG.debug("Created IdPool for ITM Service");
+            }
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.error("Failed to create idPool for ITM Service",e);
+        }
+    }
 }
index f156715ace514081dfb146bdf146b7cc7f82b9da..74d143c4da4ab149b1846813865d27597ed182ae 100644 (file)
@@ -12,6 +12,8 @@ import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.net.util.SubnetUtils;
@@ -23,6 +25,12 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.ReleaseIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.ReleaseIdInputBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
 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.DpnEndpointsBuilder;
@@ -44,6 +52,7 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
+import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -58,6 +67,7 @@ public class ItmUtils {
     public static final String DUMMY_IP_ADDRESS = "0.0.0.0";
     public static final String TUNNEL_TYPE_VXLAN = "VXLAN";
     public static final String TUNNEL_TYPE_GRE = "GRE";
+    public static final String TUNNEL = "TUNNEL";
 
     private static final Logger LOG = LoggerFactory.getLogger(ItmUtils.class);
 
@@ -117,8 +127,9 @@ public class ItmUtils {
         return dpnId;
     }
 
-    public static String getTrunkInterfaceName(String parentInterfaceName, String localHostName, String remoteHostName) {
+    public static String getTrunkInterfaceName(IdManagerService idManager, String parentInterfaceName, String localHostName, String remoteHostName) {
         String trunkInterfaceName = String.format("%s:%s:%s", parentInterfaceName, localHostName, remoteHostName);
+        trunkInterfaceName = String.format("%s:%s", TUNNEL, getUniqueId(idManager, trunkInterfaceName));
         return trunkInterfaceName;
     }
 
@@ -184,4 +195,36 @@ public class ItmUtils {
             LOG.debug( "No Dpn information in CONFIGURATION datastore "  );
          return dpnTEPs ;
     }
+
+    public static int getUniqueId(IdManagerService idManager, String idKey) {
+        AllocateIdInput getIdInput = new AllocateIdInputBuilder()
+            .setPoolName(ITMConstants.ITM_IDPOOL_NAME)
+            .setIdKey(idKey).build();
+
+        try {
+            Future<RpcResult<AllocateIdOutput>> result = idManager.allocateId(getIdInput);
+            RpcResult<AllocateIdOutput> rpcResult = result.get();
+            if(rpcResult.isSuccessful()) {
+                return rpcResult.getResult().getIdValue().intValue();
+            } else {
+                LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
+            }
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.warn("Exception when getting Unique Id",e);
+        }
+        return 0;
+    }
+
+    public static void releaseId(IdManagerService idManager, String idKey) {
+        ReleaseIdInput idInput = new ReleaseIdInputBuilder().setPoolName(ITMConstants.ITM_IDPOOL_NAME).setIdKey(idKey).build();
+        try {
+            Future<RpcResult<Void>> result = idManager.releaseId(idInput);
+            RpcResult<Void> rpcResult = result.get();
+            if(!rpcResult.isSuccessful()) {
+                LOG.warn("RPC Call to Get Unique Id returned with Errors {}", rpcResult.getErrors());
+            }
+        } catch (InterruptedException | ExecutionException e) {
+            LOG.warn("Exception when getting Unique Id for key {}", idKey, e);
+        }
+    }
 }
index 3af1659aab01cbcb8d8dfb0f31f06c570f15b0f9..e60d3ee0fdde576b12fdb2fe64b6aa858f34b495 100644 (file)
@@ -24,6 +24,7 @@ import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeBase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.dpn.teps.info.TunnelEndPoints;
@@ -50,11 +51,13 @@ import org.slf4j.LoggerFactory;
 public class TransportZoneListener extends AsyncDataTreeChangeListenerBase<TransportZone, TransportZoneListener> implements AutoCloseable{
     private static final Logger LOG = LoggerFactory.getLogger(TransportZoneListener.class);
     private DataBroker dataBroker;
+    private IdManagerService idManagerService;
     private ITMManager itmManager;
 
-    public TransportZoneListener(final DataBroker dataBroker) {
+    public TransportZoneListener(final DataBroker dataBroker, final IdManagerService idManagerService) {
         super(TransportZone.class, TransportZoneListener.class);
         this.dataBroker = dataBroker;
+        this.idManagerService = idManagerService;
         initializeTZNode(dataBroker);
     }
 
@@ -103,7 +106,7 @@ public class TransportZoneListener extends AsyncDataTreeChangeListenerBase<Trans
             LOG.trace("Delete: Invoking ItmManager");
            // itmManager.deleteTunnels(opDpnList);
             DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
-            ItmTepRemoveWorker removeWorker = new ItmTepRemoveWorker(opDpnList, dataBroker);
+            ItmTepRemoveWorker removeWorker = new ItmTepRemoveWorker(opDpnList, dataBroker, idManagerService);
             coordinator.enqueueJob(tzOld.getZoneName(), removeWorker);
         }
     }
@@ -125,7 +128,7 @@ public class TransportZoneListener extends AsyncDataTreeChangeListenerBase<Trans
           LOG.trace("Add: Invoking ItmManager with DPN List {} " , opDpnList);
           //itmManager.build_all_tunnels(opDpnList);
           DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
-          ItmTepAddWorker addWorker = new ItmTepAddWorker(opDpnList,dataBroker);
+          ItmTepAddWorker addWorker = new ItmTepAddWorker(opDpnList,dataBroker, idManagerService);
           coordinator.enqueueJob(tzNew.getZoneName(), addWorker);
       }
     }
index 70d8f82c45a789c7ffda0671eb23adcb01b19a6d..ce67233439497e64f0c3d3c518eca04ee70b14d9 100644 (file)
@@ -12,6 +12,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.Future;
 
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -69,14 +70,19 @@ public class ItmManagerRpcService implements ItmRpcService {
    private static final Logger LOG = LoggerFactory.getLogger(ItmManagerRpcService.class);
         DataBroker dataBroker;
         private IMdsalApiManager mdsalManager;
-        public ItmManagerRpcService(DataBroker dataBroker) {
-        this.dataBroker = dataBroker;
-    }
+
 
     public void setMdsalManager(IMdsalApiManager mdsalManager) {
             this.mdsalManager = mdsalManager;
     }
 
+        IdManagerService idManagerService;
+
+        public ItmManagerRpcService(DataBroker dataBroker, IdManagerService idManagerService) {
+          this.dataBroker = dataBroker;
+          this.idManagerService = idManagerService;
+        }
+
      @Override
      public Future<RpcResult<GetTunnelInterfaceNameOutput>> getTunnelInterfaceName(GetTunnelInterfaceNameInput input) {
          RpcResultBuilder<GetTunnelInterfaceNameOutput> resultBld = null;
@@ -125,7 +131,7 @@ public class ItmManagerRpcService implements ItmRpcService {
             BuildExternalTunnelFromDpnsInput input) {
         //Ignore the Futures for now
         final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
-        List<ListenableFuture<Void>> extTunnelResultList = ItmExternalTunnelAddWorker.buildTunnelsFromDpnToExternalEndPoint(dataBroker, input.getDpnId(), input.getDestinationIp(), input.getTunnelType());
+        List<ListenableFuture<Void>> extTunnelResultList = ItmExternalTunnelAddWorker.buildTunnelsFromDpnToExternalEndPoint(dataBroker, idManagerService, input.getDpnId(), input.getDestinationIp(), input.getTunnelType());
         for (ListenableFuture<Void> extTunnelResult : extTunnelResultList) {
             Futures.addCallback(extTunnelResult, new FutureCallback<Void>(){