- 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>
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";
+
+
}
<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>
-->
<snapshot>
<required-capabilities>
- <capability>urn:opendaylight:params:xml:ns:yang:itm?module=itm&revision=2015-07-01</capability>
- <capability>urn:opendaylight:params:xml:ns:yang:itm:impl?module=itm-impl&revision=2014-12-10</capability>
+ <capability>urn:opendaylight:vpnservice:itm?module=itm&revision=2015-07-01</capability>
+ <capability>urn:opendaylight:vpnservice:itm:impl?module=itm-impl&revision=2014-12-10</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28</capability>
<capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&revision=2015-04-10</capability>
<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>
</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>
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;
};
};
- 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) {
// 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);
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) ;
}
}
}
- futures = buildTunnelsToExternalEndPoint( dataBroker, cfgDpnList, extIp, tunType) ;
+ futures = buildTunnelsToExternalEndPoint( dataBroker, idManagerService, cfgDpnList, extIp, tunType) ;
}
return futures ;
}
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;
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();
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);
}
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;
};
- 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();
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>() ;
}
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()) {
}
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();
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 ;
}
}
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) ;
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;
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();
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);
}
}
}
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);
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);
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;
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 );
}
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 ;
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;
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 );
}
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 ;
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;
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;
private DataBroker dataBroker;
private NotificationPublishService notificationPublishService;
private ItmManagerRpcService itmRpcService ;
+ private IdManagerService idManager;
private NotificationService notificationService;
private TransportZoneListener tzChangeListener;
private RpcProviderRegistry rpcProviderRegistry;
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);
itmManager.setMdsalManager(mdsalManager);
tzChangeListener.setItmManager(itmManager);
tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
+ createIdPool();
} catch (Exception e) {
LOG.error("Error initializing services", e);
}
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);
+ }
+ }
}
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;
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;
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;
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);
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;
}
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);
+ }
+ }
}
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;
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);
}
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);
}
}
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);
}
}
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;
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;
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>(){