}
List<ActionInfo> actionInfos = new ArrayList<ActionInfo>();
-
+ // Set the LLDP service Id which is 0
if(Tunnel.class.equals(intfType)) {
actionInfos.add(new ActionInfo(ActionType.set_field_tunnel_id, new BigInteger[] {
- BigInteger.valueOf(0x08000000)}));
+ BigInteger.valueOf(0)}));
}
actionInfos.add(new ActionInfo(ActionType.output, new String[] { Long.toString(portNum) }));
return actionInfos;
public static void startLLDPMonitoring(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
Interface trunkInterface) {
//LLDP monitoring for the trunk interface
- /*String trunkInterfaceName = trunkInterface.getName();
+ String trunkInterfaceName = trunkInterface.getName();
IfTunnel ifTunnel = trunkInterface.getAugmentation(IfTunnel.class);
if(ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) {
MonitorStartInput lldpMonitorInput = new MonitorStartInputBuilder().setConfig(new ConfigBuilder()
} catch (InterruptedException | ExecutionException e) {
LOG.warn("Exception when starting monitoring", e);
}
- }*/
+ }
}
public static void stopLLDPMonitoring(AlivenessMonitorService alivenessMonitorService, DataBroker dataBroker,
Interface trunkInterface) {
- /*IfTunnel ifTunnel = trunkInterface.getAugmentation(IfTunnel.class);
+ IfTunnel ifTunnel = trunkInterface.getAugmentation(IfTunnel.class);
if(!ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)){
return;
}
removeMonitorIdFromInterfaceMonitorIdMap(dataBroker, interfaceName, monitorId);
return;
}
- }*/
+ }
}
public static String getInterfaceFromMonitorId(DataBroker broker, Long monitorId) {
public static final String ITM_IDPOOL_NAME = "Itmservices";
public static final long ITM_IDPOOL_START = 1L;
public static final String ITM_IDPOOL_SIZE = "100000";
-
- public static final short INTERNAL_TUNNEL_TABLE = 22;
-
-
-
- public static final short TERMINATING_SERVICE_TABLE = 36;
+ public static int LLDP_SERVICE_ID = 0;
}
ExternalTunnelList.class)
.child(ExternalTunnel.class, new ExternalTunnelKey(extIp, teps.getDPNID()));
t.delete(LogicalDatastoreType.CONFIGURATION, path);
- // Release the Ids for the trunk interface
- ItmUtils.releaseId(idManagerService, trunkInterfaceName);
+ // Release the Ids for the trunk interface Name
+ ItmUtils.releaseIdForTrunkInterfaceName(idManagerService,interfaceName,firstEndPt.getIpAddress().getIpv4Address().getValue(), extIp.getIpv4Address().getValue() );
}
}
futures.add(t.submit()) ;
import com.google.common.util.concurrent.FutureCallback;
import com.google.common.util.concurrent.ListenableFuture;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.vpnservice.itm.globals.ITMConstants;
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
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.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
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, IdManagerService idManagerService,
+ public static List<ListenableFuture<Void>> build_all_tunnels(DataBroker dataBroker, IdManagerService idManagerService,IMdsalApiManager mdsalManager,
List<DPNTEPsInfo> cfgdDpnList, List<DPNTEPsInfo> meshedDpnList) {
logger.trace( "Building tunnels with DPN List {} " , cfgdDpnList );
List<ListenableFuture<Void>> futures = new ArrayList<>();
for( DPNTEPsInfo dpn : cfgdDpnList) {
//#####if dpn is not in meshedDpnList
- build_tunnel_from(dpn, meshedDpnList, dataBroker, idManagerService, t, futures);
+ build_tunnel_from(dpn, meshedDpnList, dataBroker, idManagerService, mdsalManager, 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, IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ private static void build_tunnel_from( DPNTEPsInfo srcDpn,List<DPNTEPsInfo> meshedDpnList, DataBroker dataBroker, IdManagerService idManagerService, IMdsalApiManager mdsalManager, 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, idManagerService, t, futures) ;
+ wireUpWithinTransportZone(srcDpn, dstDpn, dataBroker, idManagerService, mdsalManager, t, futures) ;
}
}
private static void wireUpWithinTransportZone( DPNTEPsInfo srcDpn, DPNTEPsInfo dstDpn, DataBroker dataBroker,
- IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ IdManagerService idManagerService, IMdsalApiManager mdsalManager,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, idManagerService, t, futures );
+ wireUpBidirectionalTunnel( srcte, dstte, srcDpn.getDPNID(), dstDpn.getDPNID(), dataBroker, idManagerService, mdsalManager, 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, IdManagerService idManagerService, WriteTransaction t, List<ListenableFuture<Void>> futures) {
+ DataBroker dataBroker, IdManagerService idManagerService, IMdsalApiManager mdsalManager, WriteTransaction t, List<ListenableFuture<Void>> futures) {
// Setup the flow for LLDP monitoring -- PUNT TO CONTROLLER
- // setUpOrRemoveTerminatingServiceTable(srcDpnId, true);
- // setUpOrRemoveTerminatingServiceTable(dstDpnId, true);
+ ItmUtils.setUpOrRemoveTerminatingServiceTable(srcDpnId, mdsalManager, true);
+ ItmUtils.setUpOrRemoveTerminatingServiceTable(dstDpnId, mdsalManager, true);
// Create the forward direction tunnel
if(!wireUp( srcte, dstte, srcDpnId, dstDpnId, dataBroker, idManagerService, t, futures ))
t.merge(LogicalDatastoreType.CONFIGURATION,path, tnl, true) ;
return true;
}
-
}
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;
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<>();
// 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 =
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()
.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());
}
}
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.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
private IdManagerService idManagerService;
private List<DPNTEPsInfo> meshedDpnList;
private List<DPNTEPsInfo> cfgdDpnList ;
+ private IMdsalApiManager mdsalManager;
- public ItmTepAddWorker( List<DPNTEPsInfo> cfgdDpnList, DataBroker broker, IdManagerService idManagerService) {
+ public ItmTepAddWorker( List<DPNTEPsInfo> cfgdDpnList, DataBroker broker, IdManagerService idManagerService, IMdsalApiManager mdsalManager) {
this.cfgdDpnList = cfgdDpnList ;
this.dataBroker = broker ;
this.idManagerService = idManagerService;
+ this.mdsalManager = mdsalManager;
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, idManagerService, cfgdDpnList, meshedDpnList) ) ;
+ futures.addAll( ItmInternalTunnelAddWorker.build_all_tunnels(dataBroker, idManagerService,mdsalManager, 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.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.dpn.endpoints.DPNTEPsInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
private List<DPNTEPsInfo> delDpnList ;
private List<DPNTEPsInfo> meshedDpnList ;
private IdManagerService idManagerService;
+ private IMdsalApiManager mdsalManager;
- public ItmTepRemoveWorker( List<DPNTEPsInfo> delDpnList, DataBroker broker, IdManagerService idManagerService) {
+ public ItmTepRemoveWorker( List<DPNTEPsInfo> delDpnList, DataBroker broker, IdManagerService idManagerService, IMdsalApiManager mdsalManager) {
this.delDpnList = delDpnList ;
this.dataBroker = broker ;
this.idManagerService = idManagerService;
+ this.mdsalManager = mdsalManager;
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, idManagerService, delDpnList, meshedDpnList));
+ futures.addAll( ItmInternalTunnelDeleteWorker.deleteTunnels(dataBroker, idManagerService, mdsalManager, 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 ;
itmManager.setMdsalManager(mdsalManager);
itmManager.setNotificationPublishService(notificationPublishService);
itmManager.setMdsalManager(mdsalManager);
+ tzChangeListener.setMdsalManager(mdsalManager);
tzChangeListener.setItmManager(itmManager);
tzChangeListener.registerListener(LogicalDatastoreType.CONFIGURATION, dataBroker);
createIdPool();
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnel;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.tunnel.list.InternalTunnelKey;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.vpnservice.itm.globals.ITMConstants;
import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
+import org.opendaylight.vpnservice.mdsalutil.ActionType;
+import org.opendaylight.vpnservice.mdsalutil.FlowEntity;
+import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
+import org.opendaylight.vpnservice.mdsalutil.InstructionType;
+import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
+import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
+import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.net.InetAddresses;
return trunkInterfaceName;
}
+ public static void releaseIdForTrunkInterfaceName(IdManagerService idManager, String parentInterfaceName, String localHostName, String remoteHostName) {
+ String trunkInterfaceName = String.format("%s:%s:%s", parentInterfaceName, localHostName, remoteHostName);
+ LOG.trace("Releasing Id for trunkInterface - {}", trunkInterfaceName );
+ releaseId(idManager, trunkInterfaceName) ;
+ }
+
public static InetAddress getInetAddressFromIpAddress(IpAddress ip) {
return InetAddresses.forString(ip.getIpv4Address().getValue());
}
}
return cfgDpnList;
}
+
+ public static void setUpOrRemoveTerminatingServiceTable(BigInteger dpnId, IMdsalApiManager mdsalManager, boolean addFlag) {
+ String logmsg = ( addFlag == true) ? "Installing" : "Removing";
+ LOG.trace( logmsg + " PUNT to Controller flow in DPN {} ", dpnId );
+ long dpId;
+ List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
+ listActionInfo.add(new ActionInfo(ActionType.punt_to_controller,
+ new String[] {}));
+
+ try {
+ List<MatchInfo> mkMatches = new ArrayList<MatchInfo>();
+
+ mkMatches.add(new MatchInfo(MatchFieldType.tunnel_id, new BigInteger[] {
+ BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID) }));
+
+ List<InstructionInfo> mkInstructions = new ArrayList<InstructionInfo>();
+ mkInstructions.add(new InstructionInfo(InstructionType.apply_actions,
+ listActionInfo));
+
+ FlowEntity terminatingServiceTableFlowEntity = MDSALUtil
+ .buildFlowEntity(
+ dpnId,
+ NwConstants.INTERNAL_TUNNEL_TABLE,
+ getFlowRef(NwConstants.INTERNAL_TUNNEL_TABLE,
+ ITMConstants.LLDP_SERVICE_ID), 5, String.format("%s:%d","ITM Flow Entry ",ITMConstants.LLDP_SERVICE_ID),
+ 0, 0, ITMConstants.COOKIE_ITM
+ .add(BigInteger.valueOf(ITMConstants.LLDP_SERVICE_ID)),
+ mkMatches, mkInstructions);
+ if(addFlag)
+ mdsalManager.installFlow(terminatingServiceTableFlowEntity);
+ else
+ mdsalManager.removeFlow(terminatingServiceTableFlowEntity);
+ } catch (Exception e) {
+ LOG.error("Error while setting up Table 36 for {}", dpnId, e);
+ }
+ }
+
+ private static String getFlowRef(long termSvcTable, int svcId) {
+ return new StringBuffer().append(termSvcTable).append(svcId).toString();
+ }
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rev150701.transport.zones.transport.zone.subnets.Vteps;
import org.opendaylight.vpnservice.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.vpnservice.itm.impl.ITMManager;
import org.opendaylight.vpnservice.itm.impl.ItmUtils;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
private static final Logger LOG = LoggerFactory.getLogger(TransportZoneListener.class);
private DataBroker dataBroker;
private IdManagerService idManagerService;
+ private IMdsalApiManager mdsalManager;
private ITMManager itmManager;
public TransportZoneListener(final DataBroker dataBroker, final IdManagerService idManagerService) {
this.itmManager = itmManager;
}
+ public void setMdsalManager(IMdsalApiManager mdsalManager) {
+ this.mdsalManager = mdsalManager;
+ }
+
private void initializeTZNode(DataBroker db) {
ReadWriteTransaction transaction = db.newReadWriteTransaction();
InstanceIdentifier<TransportZones> path = InstanceIdentifier.create(TransportZones.class);
LOG.trace("Delete: Invoking ItmManager");
// itmManager.deleteTunnels(opDpnList);
DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
- ItmTepRemoveWorker removeWorker = new ItmTepRemoveWorker(opDpnList, dataBroker, idManagerService);
+ ItmTepRemoveWorker removeWorker = new ItmTepRemoveWorker(opDpnList, dataBroker, idManagerService, mdsalManager);
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, idManagerService);
+ ItmTepAddWorker addWorker = new ItmTepAddWorker(opDpnList,dataBroker, idManagerService, mdsalManager);
coordinator.enqueueJob(tzNew.getZoneName(), addWorker);
}
}