}
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;
LOG.trace("Pkt received: {}", packet);
Class<? extends PacketInReason> pktInReason = packet.getPacketInReason();
short tableId = packet.getTableId().getValue();
- if (isPktInReasonSendtoCtrl(pktInReason) && ((NwConstants.DHCP_TABLE == tableId))) {
+ if (isPktInReasonSendtoCtrl(pktInReason)) {
byte[] inPayload = packet.getPayload();
Ethernet ethPkt = new Ethernet();
try {
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>3.0.3</version>
</dependency>
+ <dependency>
+ <groupId>org.opendaylight.vpnservice</groupId>
+ <artifactId>interfacemgr-impl</artifactId>
+ <version>${vpnservices.version}</version>
+ </dependency>
</dependencies>
</project>
removeElanInterface(elanInfo, interfaceName);
}
- public void removeElanService(ElanInterface del, int vlanId) {
+ public void removeElanService(ElanInterface del, InterfaceInfo interfaceInfo) {
ElanInstance elanInstance = ElanUtils.getElanInstanceByName(del.getElanInstanceName());
String interfaceName = del.getName();
- InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(interfaceName, InterfaceType.VLAN_INTERFACE);
removeElanInterface(elanInstance, interfaceInfo);
- unbindService(elanInstance, interfaceName, vlanId);
+ unbindService(elanInstance, interfaceName);
}
public void removeElanInterface(ElanInstance elanInfo, String interfaceName) {
InterfaceInfo interfaceInfo, BigInteger dstDpId) {
int elanTag = elanInfo.getElanTag().intValue();
long groupId = ElanUtils.getElanRemoteBCGID(elanTag);
+ DpnInterfaces dpnInterfaces = ElanUtils.getElanInterfaceInfoByElanDpn(elanInfo.getElanInstanceName(), interfaceInfo.getDpId());
List<DpnInterfaces> elanDpns = ElanUtils.getInvolvedDpnsInElan(elanInfo.getElanInstanceName());
if(elanDpns != null) {
for(DpnInterfaces dpnInterface : elanDpns) {
int bucketId = 0;
List<Bucket> remoteListBucket = new ArrayList<Bucket>();
if(ElanUtils.isDpnPresent(dstDpId) && dpnInterface.getDpId().equals(dstDpId) && dpnInterface.getInterfaces() != null && !dpnInterface.getInterfaces().isEmpty()) {
+ for(String ifName : dpnInterfaces.getInterfaces()) {
+ // In case if there is a InterfacePort in the cache which is not in
+ // operational state, skip processing it
+ InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
+ if (!isOperational(ifInfo)) {
+ continue;
+ }
+
+ remoteListBucket.add(MDSALUtil.buildBucket(getInterfacePortActions(ifInfo), MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
+ bucketId++;
+ }
try {
List<Action> remoteListActionInfo = ElanUtils.getItmEgressAction(interfaceInfo.getDpId(), dstDpId, (int) elanTag);
remoteListBucket.add(MDSALUtil.buildBucket(remoteListActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
logger.error( "Logical Group Interface not found between source Dpn - {}, destination Dpn - {} " ,dpnInterface.getDpId(), dstDpId);
return;
}
- List<Action> remoteListActionInfo = new ArrayList<Action>();
- remoteListActionInfo.add(new ActionInfo(ActionType.group, new String[] {String.valueOf(ElanUtils.getElanLocalBCGID(elanTag))}).buildAction());
- remoteListBucket.add(MDSALUtil.buildBucket(remoteListActionInfo, MDSALUtil.GROUP_WEIGHT, bucketId, MDSALUtil.WATCH_PORT, MDSALUtil.WATCH_GROUP));
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(remoteListBucket));
mdsalManager.syncInstallGroup(interfaceInfo.getDpId(), group, ElanConstants.DELAY_TIME_IN_MILLISECOND);
break;
// In case if there is a InterfacePort in the cache which is not in
// operational state, skip processing it
InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
- if (!isOperational(ifInfo)) {
+ if (ifInfo == null || !isOperational(ifInfo)) {
continue;
}
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
logger.trace("installing the localBroadCast Group:{}", group);
- mdsalManager.syncInstallGroup(dpnId, group, ElanConstants.DELAY_TIME_IN_MILLISECOND);
+ // In the case of OVS disconnected we receive null object when we query Interface Operation datastore
+ // so the size of the bucket will be zero
+ if(listBucket.size() == 0) {
+ mdsalManager.syncRemoveGroup(dpnId, group);
+ } else {
+ mdsalManager.syncInstallGroup(dpnId, group, ElanConstants.DELAY_TIME_IN_MILLISECOND);
+ }
}
public void setupLocalBroadcastGroups(ElanInstance elanInfo, InterfaceInfo interfaceInfo) {
// In case if there is a InterfacePort in the cache which is not in
// operational state, skip processing it
InterfaceInfo ifInfo = interfaceManager.getInterfaceInfoFromOperationalDataStore(ifName, interfaceInfo.getInterfaceType());
- if (!isOperational(ifInfo)) {
+ if (ifInfo == null || !isOperational(ifInfo)) {
continue;
}
bucketId++;
}
+
Group group = MDSALUtil.buildGroup(groupId, elanInfo.getElanInstanceName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(listBucket));
logger.trace("installing the localBroadCast Group:{}", group);
- mdsalManager.syncInstallGroup(dpnId, group, ElanConstants.DELAY_TIME_IN_MILLISECOND);
+ // In the case of OVS disconnected we receive null object for the Interface Operation datastore
+ // so the size of the bucket will be zero
+ if(listBucket.size() == 0) {
+ mdsalManager.syncRemoveGroup(dpnId, group);
+ } else {
+ mdsalManager.syncInstallGroup(dpnId, group, ElanConstants.DELAY_TIME_IN_MILLISECOND);
+ }
}
public void removeLocalBroadcastGroup(ElanInstance elanInfo, InterfaceInfo interfaceInfo) {
removeFilterEqualsTable(elanInfo, interfaceInfo);
} else {
setupElanBroadcastGroups(elanInfo, interfaceInfo);
+ setupLocalBroadcastGroups(elanInfo, interfaceInfo);
removeFilterEqualsTable(elanInfo, interfaceInfo);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.vpnservice.elan.internal;
+
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.vpnservice.elan.utils.ElanUtils;
+import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
+import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
+import org.opendaylight.vpnservice.mdsalutil.AbstractDataChangeListener;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.instances.ElanInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.interfaces.ElanInterface;
+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.tunnel.list.InternalTunnel;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.math.BigInteger;
+import java.util.List;
+
+public class ElanInterfaceStateChangeListener extends AbstractDataChangeListener<Interface> implements AutoCloseable {
+ private DataBroker broker;
+ private IInterfaceManager interfaceManager;
+ private ElanInterfaceManager elanInterfaceManager;
+ private ListenerRegistration<DataChangeListener> listenerRegistration;
+ private static final Logger logger = LoggerFactory.getLogger(ElanInterfaceStateChangeListener.class);
+
+ public ElanInterfaceStateChangeListener(final DataBroker db, final ElanInterfaceManager ifManager) {
+ super(Interface.class);
+ broker = db;
+ elanInterfaceManager = ifManager;
+ registerListener(db);
+ }
+
+ private void registerListener(final DataBroker db) {
+ try {
+ listenerRegistration = broker.registerDataChangeListener(LogicalDatastoreType.OPERATIONAL,
+ getWildCardPath(), ElanInterfaceStateChangeListener.this, AsyncDataBroker.DataChangeScope.SUBTREE);
+ } catch (final Exception e) {
+ logger.error("Elan Interfaces DataChange listener registration fail!", e);
+ throw new IllegalStateException("ElanInterface registration Listener failed.", e);
+ }
+ }
+
+ private InstanceIdentifier<Interface> getWildCardPath() {
+ return InstanceIdentifier.create(InterfacesState.class).child(Interface.class);
+ }
+
+ public void setInterfaceManager(IInterfaceManager interfaceManager) {
+ this.interfaceManager = interfaceManager;
+ }
+
+ private void handleVlanInterfaceOperationalStateChange(String interfaceName, boolean isStateUp) {
+ //fetching the elanInstanceName from elan-interface config data-store
+ ElanInterface elanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ if (elanInterface == null) {
+ return;
+ }
+ ElanInstance elanInfo = ElanUtils.getElanInstanceByName(elanInterface.getElanInstanceName());
+ InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
+
+ logger.trace("ElanService Interface Operational state has changes for Interface:{}", interfaceName);
+ elanInterfaceManager.handleInterfaceUpated(interfaceInfo, elanInfo , isStateUp);
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<Interface> identifier, Interface delIf) {
+ logger.trace("Received interface {} Down event", delIf);
+ String interfaceName = delIf.getName();
+ ElanInterface elanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ if(elanInterface == null) {
+ logger.debug("No Elan Interface is created for the interface:{} ", interfaceName);
+ return;
+ }
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(delIf.getLowerLayerIf().get(0));
+ BigInteger dpId = MDSALUtil.getDpnIdFromNodeName(nodeConnectorId.getValue());
+ InterfaceInfo interfaceInfo = new InterfaceInfo(dpId, nodeConnectorId.getValue());
+ interfaceInfo.setInterfaceName(interfaceName);
+ interfaceInfo.setInterfaceType(InterfaceInfo.InterfaceType.VLAN_INTERFACE);
+ interfaceInfo.setInterfaceTag(delIf.getIfIndex());
+ elanInterfaceManager.removeElanService(elanInterface, interfaceInfo);
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
+ logger.trace("Operation Interface update event - Old: {}, New: {}", original, update);
+ String interfaceName = update.getName();
+ if(update.getType().equals(Tunnel.class)) {
+ if (update.getOperStatus().equals(Interface.OperStatus.Up)) {
+ InternalTunnel internalTunnel = getTunnelState(interfaceName);
+ if (internalTunnel != null) {
+ elanInterfaceManager.handleTunnelStateEvent(internalTunnel.getSourceDPN(), internalTunnel.getDestinationDPN());
+ }
+ }
+ } else if(update.getType().equals(L2vlan.class)) {
+ ElanInterface elanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ if(elanInterface == null) {
+ logger.debug("No Elan Interface is created for the interface:{} ", interfaceName);
+ return;
+ }
+ if (update.getOperStatus().equals(Interface.OperStatus.Up) && update.getAdminStatus() == Interface.AdminStatus.Up) {
+ logger.trace("Operation Status for Interface:{} event state UP ", interfaceName);
+ handleVlanInterfaceOperationalStateChange(interfaceName, true);
+ } else if (update.getOperStatus().equals(Interface.OperStatus.Down)) {
+ logger.trace("Operation Status for Interface:{} event state DOWN ", interfaceName);
+ handleVlanInterfaceOperationalStateChange(interfaceName, false);
+ }
+
+ }
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
+ logger.trace("Received interface {} up event", intrf);
+ String interfaceName = intrf.getName();
+ ElanInterface elanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
+ if(elanInterface == null) {
+ if (intrf.getType() != null && intrf.getType().equals(Tunnel.class)) {
+ if(intrf.getOperStatus().equals(Interface.OperStatus.Up)) {
+ InternalTunnel internalTunnel = getTunnelState(interfaceName);
+ if (internalTunnel != null) {
+ elanInterfaceManager.handleTunnelStateEvent(internalTunnel.getSourceDPN(), internalTunnel.getDestinationDPN());
+ }
+ }
+ }
+ return;
+ }
+ InstanceIdentifier<ElanInterface> elanInterfaceId = ElanUtils.getElanInterfaceConfigurationDataPathId(interfaceName);
+ elanInterfaceManager.add(elanInterfaceId, elanInterface);
+ }
+
+ @Override
+ public void close() throws Exception {
+
+ }
+
+ public InternalTunnel getTunnelState(String interfaceName) {
+ InternalTunnel internalTunnel = null;
+ TunnelList tunnelList = ElanUtils.buildInternalTunnel(broker);
+ if (tunnelList.getInternalTunnel() != null) {
+ List<InternalTunnel> internalTunnels = tunnelList.getInternalTunnel();
+ for (InternalTunnel tunnel : internalTunnels) {
+ if (internalTunnel.getTunnelInterfaceName().equalsIgnoreCase(interfaceName)) {
+ internalTunnel = tunnel;
+ break;
+ }
+ }
+ }
+ return internalTunnel;
+ }
+}
private ElanInterfaceManager elanInterfaceManager;
private ElanPacketInHandler elanPacketInHandler;
private ElanSmacFlowEventListener elanSmacFlowEventListener;
+ private ElanInterfaceStateChangeListener elanInterfaceStateChangeListener;
private ElanNodeListener elanNodeListener;
private NotificationService notificationService;
private RpcProviderRegistry rpcProviderRegistry;
rpcProviderRegistry = rpcRegistry;
}
- //private ElanInterfaceEventListener elanInterfaceEventListener;
+ //private ElanInterfaceStateChangeListener elanInterfaceEventListener;
private ElanItmEventListener elanItmEventListener;
public void setItmRpcService(ItmRpcService itmRpcService) {
ElanStatisticsService interfaceStatsService = new ElanStatisticsImpl(broker, interfaceManager, mdsalManager);
rpcProviderRegistry.addRpcImplementation(ElanStatisticsService.class, interfaceStatsService);
+ elanInterfaceStateChangeListener = new ElanInterfaceStateChangeListener(broker, elanInterfaceManager);
+ elanInterfaceStateChangeListener.setInterfaceManager(interfaceManager);
ElanUtils.setElanServiceProvider(this);
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetEgressActionsOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.op.rev150701.TunnelList;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.CreateTerminatingServiceActionsInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.CreateTerminatingServiceActionsInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.itm.rpcs.rev151217.GetTunnelInterfaceNameInput;
itmRpcService.createTerminatingServiceActions(input);
}
+
+ public static TunnelList buildInternalTunnel(DataBroker dataBroker) {
+ InstanceIdentifier<TunnelList> tunnelListInstanceIdentifier = InstanceIdentifier.builder(TunnelList.class).build();
+ Optional<TunnelList> tunnelList = read(dataBroker, LogicalDatastoreType.CONFIGURATION, tunnelListInstanceIdentifier);
+ if(tunnelList.isPresent()) {
+ return tunnelList.get();
+ }
+ return null;
+ }
}
if (prefixInfo == null)
return; //Don't have any info for this prefix (shouldn't happen); need to return
String ifName = prefixInfo.getVpnInterfaceName();
- Optional<Adjacencies> optAdjacencies = FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL, FibUtil.getAdjListPath(ifName));
- int numAdj = 0;
- if (optAdjacencies.isPresent()) {
+ Optional<OpState> opStateData = FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL,
+ FibUtil.getVpnInterfaceOpStateIdentifier(ifName));
+ if(opStateData.isPresent() && !opStateData.get().isStateUp()) {
+ Optional<Adjacencies>
+ optAdjacencies =
+ FibUtil.read(broker, LogicalDatastoreType.OPERATIONAL, FibUtil.getAdjListPath(ifName));
+ int numAdj = 0;
+ if (optAdjacencies.isPresent()) {
numAdj = optAdjacencies.get().getAdjacency().size();
- }
- LOG.trace("cleanUpOpDataForFib: remove adjacency for prefix: {} {}", vpnId, vrfEntry.getDestPrefix());
- //remove adjacency corr to prefix
- FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL, FibUtil.getAdjacencyIdentifier(ifName, vrfEntry.getDestPrefix()));
-
- if((numAdj - 1) == 0) { //there are no adjacencies left for this vpn interface, clean up
- //clean up the vpn interface from DpnToVpn list
+ }
+ LOG.trace("cleanUpOpDataForFib: remove adjacency for prefix: {} {}", vpnId,
+ vrfEntry.getDestPrefix());
+ //remove adjacency corr to prefix
+ FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
+ FibUtil.getAdjacencyIdentifier(ifName, vrfEntry.getDestPrefix()));
+
+ if ((numAdj - 1) == 0) { //there are no adjacencies left for this vpn interface, clean up
+ //clean up the vpn interface from DpnToVpn list
delIntfFromDpnToVpnList(vpnId, prefixInfo.getDpnId(), ifName, rd);
- LOG.trace("cleanUpOpDataForFib: Delete prefix to interface and vpnInterface ");
+ LOG.trace("cleanUpOpDataForFib: Delete prefix to interface and vpnInterface ");
FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
- FibUtil.getPrefixToInterfaceIdentifier(
- vpnId,
- (extra_route) ? vrfEntry.getNextHopAddress() + "/32" : vrfEntry.getDestPrefix()));
+ FibUtil.getPrefixToInterfaceIdentifier(
+ vpnId,
+ (extra_route) ? vrfEntry.getNextHopAddress() + "/32"
+ : vrfEntry.getDestPrefix()));
FibUtil.delete(broker, LogicalDatastoreType.OPERATIONAL,
- FibUtil.getVpnInterfaceIdentifier(ifName));
+ FibUtil.getVpnInterfaceIdentifier(ifName));
+ }
}
}
final VrfEntry vrfEntry) {
LOG.debug("deleting route "+ vrfEntry.getDestPrefix() + " "+vpnId);
String rd = vrfTableKey.getRouteDistinguisher();
- String egressInterface = resolveAdjacency(localDpnId, remoteDpnId, vpnId, vrfEntry, rd);
- if(egressInterface == null) {
- LOG.error("Could not get nexthop group id for nexthop: {} in vpn {}",
- vrfEntry.getNextHopAddress(), rd);
- LOG.warn("Failed to delete Route: {} in vpn: {}",
- vrfEntry.getDestPrefix(), rd);
- return;
+ boolean isRemoteRoute = true;
+ if (localDpnId == null) {
+ // localDpnId is not known when clean up happens for last vm for a vpn on a dpn
+ VpnNexthop localNextHopInfo = nextHopManager.getVpnNexthop(vpnId, vrfEntry.getDestPrefix());
+ if(localNextHopInfo == null) {
+ //Is this fib route an extra route? If yes, get the nexthop which would be an adjacency in the vpn
+ Extraroute extra_route = getVpnToExtraroute(rd, vrfEntry.getDestPrefix());
+ if (extra_route != null) {
+ localNextHopInfo = nextHopManager.getVpnNexthop(vpnId, extra_route.getNexthopIp());
+ }
+ }
+ isRemoteRoute = ((localNextHopInfo != null) && (!remoteDpnId.equals(localNextHopInfo.getDpnId())));
+ }
+ if (isRemoteRoute) {
+ makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW);
+ LOG.debug("Successfully delete fib entry for "+ vrfEntry.getDestPrefix() + " vpnId "+vpnId);
+ } else{
+ LOG.debug("Did not delete fib entry rd: {} =, prefix: {} as it is local to dpn {}", rd, vrfEntry.getDestPrefix(), remoteDpnId);
}
-
- makeConnectedRoute(remoteDpnId, vpnId, vrfEntry, rd, null, NwConstants.DEL_FLOW);
- LOG.debug("Successfully delete fib entry for "+ vrfEntry.getDestPrefix() + " vpnId "+vpnId);
}
private long getIpAddress(byte[] rawIpAddress) {
if(L2vlan.class.equals(ifType)){
IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
LOG.trace("L2Vlan: {}",vlanIface);
- long vlanVid = (vlanIface == null) ? 0 : vlanIface.getVlanId().getValue();
+ long vlanVid = (vlanIface == null) ? 0 :
+ vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
if (vlanVid != 0) {
listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}, actionKeyStart));
actionKeyStart++;
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) {
package org.opendaylight.vpnservice.interfacemgr.commons;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.idmanager.IdManager;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
-import org.opendaylight.vpnservice.mdsalutil.*;
+import org.opendaylight.vpnservice.mdsalutil.FlowEntity;
+import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
+import org.opendaylight.vpnservice.mdsalutil.InstructionType;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+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 org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
public class InterfaceManagerCommonUtils {
private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerCommonUtils.class);
MDSALUtil.syncUpdate(broker, LogicalDatastoreType.OPERATIONAL, id, ifaceBuilder.build());
}
- public static void createInterfaceParentEntryIfNotPresent(DataBroker dataBroker, WriteTransaction t,
- String parentInterface){
- InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
- InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier =
- InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
- InterfaceParentEntry interfaceParentEntry =
- InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIdentifier, dataBroker);
-
- if(interfaceParentEntry != null){
- LOG.info("Not Found entry for Parent Interface: {} in Vlan Trunk-Member Interface Renderer ConfigDS. " +
- "Creating...", parentInterface);
- InterfaceParentEntryBuilder interfaceParentEntryBuilder = new InterfaceParentEntryBuilder()
- .setKey(interfaceParentEntryKey).setParentInterface(parentInterface);
- t.put(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier,
- interfaceParentEntryBuilder.build(), true);
- }
- }
-
public static void createInterfaceChildEntry( WriteTransaction t,
String parentInterface, String childInterface){
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
IfmUtil.buildStateInterfaceId(interfaceName);
transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
}
+
+ // For trunk interfaces, binding to a parent interface which is already bound to another trunk interface should not
+ // be allowed
+ public static boolean createInterfaceChildEntryIfNotPresent( DataBroker dataBroker, WriteTransaction t,
+ String parentInterface, String childInterface){
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
+ InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier =
+ InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
+ InterfaceParentEntry interfaceParentEntry =
+ InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIdentifier, dataBroker);
+
+ if(interfaceParentEntry != null){
+ LOG.error("Trying to bind the same parent interface {} to multiple trunk interfaces. ", parentInterface);
+ return false;
+ }
+
+ LOG.info("First vlan trunk {} bound on parent-interface {}", childInterface, parentInterface);
+ InterfaceChildEntryKey interfaceChildEntryKey = new InterfaceChildEntryKey(childInterface);
+ InstanceIdentifier<InterfaceChildEntry> intfId =
+ InterfaceMetaUtils.getInterfaceChildEntryIdentifier(interfaceParentEntryKey, interfaceChildEntryKey);
+ InterfaceChildEntryBuilder entryBuilder = new InterfaceChildEntryBuilder().setKey(interfaceChildEntryKey)
+ .setChildInterface(childInterface);
+ t.put(LogicalDatastoreType.CONFIGURATION, intfId, entryBuilder.build(),true);
+ return true;
+ }
+
+ public static boolean deleteParentInterfaceEntry( WriteTransaction t, String parentInterface){
+ InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentInterface);
+ InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(interfaceParentEntryKey);
+ t.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
+ return true;
+ }
+
}
\ No newline at end of file
*/
package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.idmanager.IdManager;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.AlivenessMonitorUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.ListenableFuture;
public class OvsInterfaceConfigAddHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigAddHelper.class);
if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode()) {
return;
}
- LOG.debug("adding vlan configuration for {}",interfaceNew.getName());
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
- InterfaceManagerCommonUtils.createInterfaceChildEntry(transaction,
- parentRefs.getParentInterface(), interfaceNew.getName());
+ if(!InterfaceManagerCommonUtils.createInterfaceChildEntryIfNotPresent(dataBroker, transaction,
+ parentRefs.getParentInterface(), interfaceNew.getName())){
+ return;
+ }
+ LOG.debug("adding vlan configuration for {}",interfaceNew.getName());
org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(parentRefs.getParentInterface(), dataBroker);
NodeConnectorId ncId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId));
FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, transaction);
+ InterfaceManagerCommonUtils.deleteParentInterfaceEntry(transaction, parentRefs.getParentInterface());
// For Vlan-Trunk Interface, remove the trunk-member operstates as well...
InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceOld.getName());
*/
package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers;
-import com.google.common.util.concurrent.ListenableFuture;
+import java.util.ArrayList;
+import java.util.List;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
-import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
-import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
-import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
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.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.common.util.concurrent.ListenableFuture;
public class OvsVlanMemberConfigAddHelper {
private static final Logger LOG = LoggerFactory.getLogger(OvsVlanMemberConfigAddHelper.class);
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- InterfaceManagerCommonUtils.createInterfaceParentEntryIfNotPresent(dataBroker, t, parentRefs.getParentInterface());
InterfaceManagerCommonUtils.createInterfaceChildEntry(t, parentRefs.getParentInterface(), interfaceNew.getName());
InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(parentRefs.getParentInterface(), dataBroker);
if (ifState != null) {
LOG.debug("add interface state info for vlan member {}",interfaceNew.getName());
- OperStatus operStatus = ifState.getOperStatus();
- AdminStatus adminStatus = ifState.getAdminStatus();
- PhysAddress physAddress = ifState.getPhysAddress();
-
- if (!interfaceNew.isEnabled()) {
- operStatus = OperStatus.Down;
- }
+ InterfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), t, dataBroker, idManager, ifState);
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
- IfmUtil.buildStateInterfaceId(interfaceNew.getName());
- List<String> lowerLayerIfList = new ArrayList<>();
- lowerLayerIfList.add(ifState.getLowerLayerIf().get(0));
- //lowerLayerIfList.add(parentRefs.getParentInterface());
- Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceNew.getName());
- InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus)
- .setPhysAddress(physAddress).setLowerLayerIf(lowerLayerIfList).setIfIndex(ifIndex);
- ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceNew.getName()));
- t.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
-
- // create lportTag Interface Map
- InterfaceMetaUtils.createLportTagInterfaceMap(t, interfaceNew.getName(), ifIndex);
- //Installing vlan flow for vlan member
- NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
- BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
- if (operStatus == OperStatus.Up) {
- List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, interfaceNew);
- FlowBasedServicesUtils.installVlanFlow(dpId, portNo, interfaceNew, t, matches, ifIndex);
- }
// FIXME: Maybe, add the new interface to the higher-layer if of the parent interface-state.
// That may not serve any purpose though for interface manager.... Unless some external parties are interested in it.
*/
package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers;
-import com.google.common.util.concurrent.ListenableFuture;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
import org.opendaylight.vpnservice.interfacemgr.commons.AlivenessMonitorUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
-import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
import org.opendaylight.vpnservice.mdsalutil.NwConstants;
import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
+import com.google.common.util.concurrent.ListenableFuture;
/**
* This worker is responsible for adding the openflow-interfaces/of-port-info container
Interface ifState = InterfaceManagerCommonUtils.addStateEntry(iface, portName, transaction, idManager,
physAddress, operStatus, adminStatus, nodeConnectorId);
- BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
// If this interface is a tunnel interface, create the tunnel ingress flow
if(iface != null) {
IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
if (tunnel != null) {
+ BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
+ long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface,
ifState.getIfIndex(), NwConstants.ADD_FLOW);
futures.add(transaction.submit());
if (matches != null) {
WriteTransaction removeFlowTransaction = dataBroker.newWriteOnlyTransaction();
- FlowBasedServicesUtils.removeIngressFlow(iface, serviceToReplace, dpId, removeFlowTransaction);
+ FlowBasedServicesUtils.removeIngressFlow(iface.getName(), serviceToReplace, dpId, removeFlowTransaction);
futures.add(removeFlowTransaction.submit());
WriteTransaction installFlowTransaction = dataBroker.newWriteOnlyTransaction();
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
if (boundServices.isEmpty()) {
// Remove default entry from Lport Dispatcher Table.
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundServiceOld, t, IfmConstants.DEFAULT_SERVICE_INDEX);
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), boundServiceOld, t, IfmConstants.DEFAULT_SERVICE_INDEX);
if (t != null) {
futures.add(t.submit());
}
// This means the one removed was the highest priority service
if (high == null) {
LOG.trace("Deleting table entry for service {}, match service index {}", boundServiceOld, IfmConstants.DEFAULT_SERVICE_INDEX);
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundServiceOld, t, IfmConstants.DEFAULT_SERVICE_INDEX);
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), boundServiceOld, t, IfmConstants.DEFAULT_SERVICE_INDEX);
if (low != null) {
//delete the lower services flow entry.
LOG.trace("Deleting table entry for lower service {}, match service index {}", low, low.getServicePriority());
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, low, t, low.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), low, t, low.getServicePriority());
BoundServices lower = FlowBasedServicesUtils.getHighAndLowPriorityService(boundServices, low)[0];
short lowerServiceIndex = (short) ((lower!=null) ? lower.getServicePriority() : low.getServicePriority() + 1);
LOG.trace("Installing new entry for lower service {}, match service index {}, update service index {}", low, IfmConstants.DEFAULT_SERVICE_INDEX, lowerServiceIndex);
}
} else {
LOG.trace("Deleting table entry for service {}, match service index {}", boundServiceOld, boundServiceOld.getServicePriority());
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundServiceOld, t, boundServiceOld.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), boundServiceOld, t, boundServiceOld.getServicePriority());
short lowerServiceIndex = (short) ((low!=null) ? low.getServicePriority() : boundServiceOld.getServicePriority() + 1);
BoundServices highest = FlowBasedServicesUtils.getHighestPriorityService(boundServices);
if (high.equals(highest)) {
if (boundServices.isEmpty()) {
// Remove entry from Ingress Table.
- FlowBasedServicesUtils.removeIngressFlow(iface, boundServiceOld, dpId, t);
+ FlowBasedServicesUtils.removeIngressFlow(iface.getName(), boundServiceOld, dpId, t);
if (t != null) {
futures.add(t.submit());
}
}
if (highestPriority < boundServiceOld.getServicePriority()) {
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundServiceOld, t, boundServiceOld.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), boundServiceOld, t, boundServiceOld.getServicePriority());
if (t != null) {
futures.add(t.submit());
}
matches = FlowBasedServicesUtils.getMatchInfoForTunnelPortAtIngressTable (dpId, portNo, iface);
BoundServices toBeMoved = tmpServicesMap.get(highestPriority);
- FlowBasedServicesUtils.removeIngressFlow(iface, boundServiceOld, dpId, t);
+ FlowBasedServicesUtils.removeIngressFlow(iface.getName(), boundServiceOld, dpId, t);
FlowBasedServicesUtils.installInterfaceIngressFlow(dpId, iface, toBeMoved, t,
matches, ifIndex, NwConstants.VLAN_INTERFACE_INGRESS_TABLE);
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, toBeMoved, t, toBeMoved.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), toBeMoved, t, toBeMoved.getServicePriority());
if (t != null) {
futures.add(t.submit());
Collections.sort(allServices, new Comparator<BoundServices>() {
@Override
public int compare(BoundServices serviceInfo1, BoundServices serviceInfo2) {
- return serviceInfo2.getServicePriority().compareTo(serviceInfo1.getServicePriority());
+ return serviceInfo1.getServicePriority().compareTo(serviceInfo2.getServicePriority());
}
});
BoundServices highestPriority = allServices.remove(0);
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
-import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
import org.opendaylight.vpnservice.interfacemgr.servicebindings.flowbased.utilities.FlowBasedServicesUtils;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel;
-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.ietf.interfaces.rev140508.interfaces.state.Interface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
return futures;
}
- InterfaceKey interfaceKey = new InterfaceKey(ifaceState.getName());
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
- InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
-
if (ifaceState.getType().isAssignableFrom(L2vlan.class)) {
- return unbindServiceOnVlan(allServices, iface, ifaceState.getIfIndex(), dataBroker);
+ return unbindServiceOnVlan(allServices, ifaceState, ifaceState.getIfIndex(), dataBroker);
} else if (ifaceState.getType().isAssignableFrom(Tunnel.class)){
- return unbindServiceOnTunnel(allServices, iface, ifaceState.getIfIndex(), dataBroker);
+ return unbindServiceOnTunnel(allServices, ifaceState, ifaceState.getIfIndex(), dataBroker);
}
return futures;
}
private static List<ListenableFuture<Void>> unbindServiceOnTunnel(
List<BoundServices> allServices,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface,
+ Interface iface,
Integer ifIndex, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker);
+ List<String> ofportIds = iface.getLowerLayerIf();
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
if(nodeConnectorId == null){
return futures;
}
BoundServices highestPriorityBoundService = FlowBasedServicesUtils.getHighestPriorityService(allServices);
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
- FlowBasedServicesUtils.removeIngressFlow(iface, highestPriorityBoundService, dpId, t);
+ FlowBasedServicesUtils.removeIngressFlow(iface.getName(), highestPriorityBoundService, dpId, t);
for (BoundServices boundService : allServices) {
if (!boundService.equals(highestPriorityBoundService)) {
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundService, t, boundService.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface.getName(), boundService, t, boundService.getServicePriority());
}
}
}
private static List<ListenableFuture<Void>> unbindServiceOnVlan(
- List<BoundServices> allServices,
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface,
+ List<BoundServices> allServices, Interface ifaceState,
Integer ifIndex, DataBroker dataBroker) {
List<ListenableFuture<Void>> futures = new ArrayList<>();
WriteTransaction t = dataBroker.newWriteOnlyTransaction();
- NodeConnectorId nodeConnectorId = FlowBasedServicesUtils.getNodeConnectorIdFromInterface(iface, dataBroker);
- if (nodeConnectorId == null) {
+ List<String> ofportIds = ifaceState.getLowerLayerIf();
+ NodeConnectorId nodeConnectorId = new NodeConnectorId(ofportIds.get(0));
+ if(nodeConnectorId == null){
return futures;
}
BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
Collections.sort(allServices, new Comparator<BoundServices>() {
@Override
public int compare(BoundServices serviceInfo1, BoundServices serviceInfo2) {
- return serviceInfo2.getServicePriority().compareTo(serviceInfo1.getServicePriority());
+ return serviceInfo1.getServicePriority().compareTo(serviceInfo2.getServicePriority());
}
});
BoundServices highestPriority = allServices.remove(0);
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, highestPriority, t, IfmConstants.DEFAULT_SERVICE_INDEX);
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, ifaceState.getName(), highestPriority, t, IfmConstants.DEFAULT_SERVICE_INDEX);
for (BoundServices boundService : allServices) {
- FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, iface, boundService, t, boundService.getServicePriority());
+ FlowBasedServicesUtils.removeLPortDispatcherFlow(dpId, ifaceState.getName(), boundService, t, boundService.getServicePriority());
}
futures.add(t.submit());
return futures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.ServiceBindings;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.StypeOpenflow;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.servicebinding.rev151015.service.bindings.ServicesInfo;
installFlow(dpId, ingressFlow, t);
}
- public static void removeIngressFlow(Interface iface, BoundServices serviceOld, BigInteger dpId, WriteTransaction t) {
+ public static void removeIngressFlow(String name, BoundServices serviceOld, BigInteger dpId, WriteTransaction t) {
LOG.debug("Removing Ingress Flows");
- String flowKeyStr = getFlowRef(dpId, iface.getName(), serviceOld, serviceOld.getServicePriority());
+ String flowKeyStr = getFlowRef(dpId, name, serviceOld, serviceOld.getServicePriority());
FlowKey flowKey = new FlowKey(new FlowId(flowKeyStr));
Node nodeDpn = buildInventoryDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
t.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
- public static void removeLPortDispatcherFlow(BigInteger dpId, Interface iface, BoundServices boundServicesOld, WriteTransaction t, short currentServiceIndex) {
+ public static void removeLPortDispatcherFlow(BigInteger dpId, String iface, BoundServices boundServicesOld, WriteTransaction t, short currentServiceIndex) {
LOG.debug("Removing LPort Dispatcher Flows {}, {}", dpId, iface);
StypeOpenflow stypeOpenFlow = boundServicesOld.getAugmentation(StypeOpenflow.class);
// build the flow and install it
- String flowRef = getFlowRef(dpId, iface.getName(), boundServicesOld, currentServiceIndex);
+ String flowRef = getFlowRef(dpId, iface, boundServicesOld, currentServiceIndex);
FlowKey flowKey = new FlowKey(new FlowId(flowRef));
Node nodeDpn = buildInventoryDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
.child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
- .child(Table.class, new TableKey(stypeOpenFlow.getDispatcherTableId())).child(Flow.class, flowKey).build();
+ .child(Table.class, new TableKey(NwConstants.LPORT_DISPATCHER_TABLE)).child(Flow.class, flowKey).build();
t.delete(LogicalDatastoreType.CONFIGURATION, flowInstanceId);
}
Collections.sort(availableServiceInfos, new Comparator<BoundServices>() {
@Override
public int compare(BoundServices serviceInfo1, BoundServices serviceInfo2) {
- return serviceInfo2.getServicePriority().compareTo(serviceInfo1.getServicePriority());
+ return serviceInfo1.getServicePriority().compareTo(serviceInfo2.getServicePriority());
}
});
for (BoundServices availableServiceInfo: availableServiceInfos) {
- if (currentServiceInfo.getServicePriority() > availableServiceInfo.getServicePriority()) {
+ if (currentServiceInfo.getServicePriority() < availableServiceInfo.getServicePriority()) {
lower = availableServiceInfo;
break;
} else {
BoundServices highPriorityService = availableServiceInfos.get(0);
availableServiceInfos.remove(0);
for (BoundServices availableServiceInfo: availableServiceInfos) {
- if (availableServiceInfo.getServicePriority() > highPriorityService.getServicePriority()) {
+ if (availableServiceInfo.getServicePriority() < highPriorityService.getServicePriority()) {
highPriorityService = availableServiceInfo;
}
}
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<>();
for (TunnelEndPoints dstTep : dstDpn.getTunnelEndPoints()) {
logger.trace("Processing dstTep " + dstTep);
if (dstTep.getTransportZone().equals(srcTZone)) {
+ if( checkIfTrunkExists(dstDpn.getDPNID(), srcDpn.getDPNID(), dataBroker)) {
// remove all trunk interfaces
logger.trace("Invoking removeTrunkInterface between source TEP {} , Destination TEP {} " ,srcTep , dstTep);
removeTrunkInterface(dataBroker, idManagerService, srcTep, dstTep, srcDpn.getDPNID(), dstDpn.getDPNID(), t, futures);
+ }
}
}
}
// 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 =
tnlContainerPath, dataBroker);
// remove container if no DPNs are present
if (containerOptional.isPresent()) {
- DpnEndpoints deps = containerOptional.get();
+ DpnEndpoints deps = containerOptional.get();
if (deps.getDPNTEPsInfo() == null || deps.getDPNTEPsInfo().isEmpty()) {
logger.trace("Container Removal from DPNTEPSINFO CONFIG DS");
t.delete(LogicalDatastoreType.CONFIGURATION, tnlContainerPath);
.getValue());
logger.trace("Removing forward Trunk Interface " + trunkfwdIfName);
InstanceIdentifier<Interface> trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
- logger.debug( " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
+ logger.debug( " Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkfwdIfName, trunkIdentifier ) ;
t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
// also update itm-state ds -- Delete the forward tunnel-interface from the tunnel list
TunnelList.class)
.child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId));
t.delete(LogicalDatastoreType.CONFIGURATION,path) ;
- // Release the Id for the forward trunk
- ItmUtils.releaseId(idManagerService, trunkfwdIfName);
+ // Release the Ids for the forward trunk interface Name
+ ItmUtils.releaseIdForTrunkInterfaceName(idManagerService,srcTep.getInterfaceName(), srcTep.getIpAddress()
+ .getIpv4Address().getValue(), dstTep.getIpAddress().getIpv4Address()
+ .getValue() );
String trunkRevIfName =
ItmUtils.getTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(), dstTep.getIpAddress()
.getIpv4Address().getValue(), srcTep.getIpAddress().getIpv4Address()
.getValue());
logger.trace("Removing Reverse Trunk Interface " + trunkRevIfName);
- trunkIdentifier = ItmUtils.buildId(trunkfwdIfName);
- logger.debug( " Removing Trunk Interface Name - {} , Id - {} from Config DS {}, {} ", trunkfwdIfName, trunkIdentifier ) ;
+ trunkIdentifier = ItmUtils.buildId(trunkRevIfName);
+ logger.debug( " Removing Trunk Interface Name - {} , Id - {} from Config DS ", trunkRevIfName, trunkIdentifier ) ;
t.delete(LogicalDatastoreType.CONFIGURATION, trunkIdentifier);
// also update itm-state ds -- Delete the reverse tunnel-interface from the tunnel list
.child(InternalTunnel.class, new InternalTunnelKey(dstDpnId, srcDpnId));
t.delete(LogicalDatastoreType.CONFIGURATION,path) ;
- // Release the Id for the Reverse trunk
- ItmUtils.releaseId(idManagerService, trunkRevIfName);
+ // Release the Ids for the reverse trunk interface Name
+ ItmUtils.releaseIdForTrunkInterfaceName(idManagerService, dstTep.getInterfaceName(), dstTep.getIpAddress()
+ .getIpv4Address().getValue(), srcTep.getIpAddress().getIpv4Address()
+ .getValue());
+ }
+ private static boolean checkIfTrunkExists( BigInteger srcDpnId, BigInteger dstDpnId, DataBroker dataBroker) {
+ boolean existsFlag = false ;
+ InstanceIdentifier<InternalTunnel> path = InstanceIdentifier.create(
+ TunnelList.class)
+ .child(InternalTunnel.class, new InternalTunnelKey( srcDpnId, dstDpnId));
+ Optional<InternalTunnel> internalTunnels = ItmUtils.read(LogicalDatastoreType.CONFIGURATION,path, dataBroker) ;
+ if( internalTunnels.isPresent())
+ existsFlag = true ;
+ return existsFlag ;
}
}
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);
}
}
description "UUID representing the subnet ";
}
+ leaf subnet-ip {
+ type string;
+ description "Specifies the subnet IP in CIDR format";
+ }
+
leaf tenant-id {
type yang:uuid;
description "The UUID of the tenant that will own the subnet.";
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.interfaces.ElanInterface;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.interfaces.ElanInterfaceBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.interfaces.ElanInterfaceKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlanBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
.PortFixedipToPortNameBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.neutronvpn.rev150602.neutron.port.data
// Create of-port interface for this neutron port
createOfPortInterface(port, portVlanId);
LOG.debug("Creating ELAN Interface");
- createElanInterface(port, portVlanId);
+ createElanInterface(port);
LOG.debug("Add port to subnet");
// add port to local Subnets DS
Uuid vpnId = addPortToSubnets(port);
interfaceIdentifier);
if (!optionalInf.isPresent()) {
// handle these for trunkport extensions : portVlanId, isVlanTransparent
- Interface inf = new InterfaceBuilder().setEnabled(true).setName(name).setType(L2vlan.class).build();
+ IfL2vlan l2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
+ ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(name).build();
+ Interface inf = new InterfaceBuilder().setEnabled(true).setName(name).setType(L2vlan.class)
+ .addAugmentation(IfL2vlan.class, l2vlan).addAugmentation(ParentRefs.class, parentRefs).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, inf);
} else {
LOG.error("Interface {} is already present", name);
.getUuid());
}
- private void createElanInterface(Port port, int portVlanId) {
+ private void createElanInterface(Port port) {
String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
- String interfaceName = new StringBuilder(name).append(":").append(Integer.toString(portVlanId)).toString();
String elanInstanceName = port.getNetworkId().getValue();
List<PhysAddress> physAddresses = new ArrayList<>();
physAddresses.add(new PhysAddress(port.getMacAddress()));
InstanceIdentifier<ElanInterface> id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface
- .class, new ElanInterfaceKey(interfaceName)).build();
+ .class, new ElanInterfaceKey(name)).build();
ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName)
- .setName(interfaceName).setStaticMacEntries(physAddresses).
- setKey(new ElanInterfaceKey(interfaceName)).build();
+ .setName(name).setStaticMacEntries(physAddresses).setKey(new ElanInterfaceKey(name)).build();
MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, elanInterface);
LOG.debug("Creating new ELan Interface {}", elanInterface);
}
ipValue, name);
subnetId = ip.getSubnetId();
- Subnetmap subnetmap = nvpnManager.updateSubnetNode(subnetId, null, null, null, null, port.getUuid());
- if (vpnId == null && subnetmap != null) {
+ Subnetmap subnetmap = nvpnManager.updateSubnetNode(subnetId, null, null, null, null, null, port.getUuid());
+ if (subnetmap != null) {
vpnId = subnetmap.getVpnId();
}
}
*/
package org.opendaylight.vpnservice.neutronvpn;
-
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.vpnservice.mdsalutil.AbstractDataChangeListener;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
if (LOG.isTraceEnabled()) {
LOG.trace("Adding Subnet : key: " + identifier + ", value=" + input);
}
- handleNeutronSubnetCreated(input.getUuid(), input.getNetworkId(), input.getTenantId());
+ handleNeutronSubnetCreated(input.getUuid(), input.getCidr(), input.getNetworkId(), input.getTenantId());
}
@Override
handleNeutronSubnetUpdated(update.getUuid(), update.getNetworkId(), update.getTenantId());
}
- private void handleNeutronSubnetCreated(Uuid subnetId, Uuid networkId, Uuid tenantId) {
- nvpnManager.updateSubnetNode(subnetId, tenantId, networkId, null, null, null);
+ private void handleNeutronSubnetCreated(Uuid subnetId, String subnetIp, Uuid networkId, Uuid tenantId) {
+ nvpnManager.updateSubnetNode(subnetId, subnetIp, tenantId, networkId, null, null, null);
if (networkId != null && NeutronvpnUtils.getNeutronNetwork(broker, networkId) != null) {
createSubnetToNetworkMapping(subnetId, networkId);
}
if (networkId != null) {
deleteSubnetToNetworkMapping(subnetId, networkId);
}
+ nvpnManager.deleteSubnetMapNode(subnetId);
}
private void handleNeutronSubnetUpdated(Uuid subnetId, Uuid networkId, Uuid tenantId) {
if (networkId != null && !networkId.equals(oldNetworkId)) {
createSubnetToNetworkMapping(subnetId, networkId);
}
- nvpnManager.updateSubnetNode(subnetId, tenantId, networkId, null, null, null);
+ nvpnManager.updateSubnetNode(subnetId, null, tenantId, networkId, null, null, null);
}
private void createSubnetToNetworkMapping(Uuid subnetId, Uuid networkId) {
*/
package org.opendaylight.vpnservice.neutronvpn;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
-
import com.google.common.base.Optional;
import com.google.common.util.concurrent.SettableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.adjacency.list.Adjacency;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.adjacency.list.AdjacencyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.adjacency.list.AdjacencyKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
logger.info("Neutron VPN Manager Closed");
}
- protected Subnetmap updateSubnetNode(Uuid subnetId, Uuid tenantId, Uuid networkId, Uuid routerId, Uuid vpnId,
- Uuid portId) {
+ protected Subnetmap updateSubnetNode(Uuid subnetId, String subnetIp, Uuid tenantId, Uuid networkId, Uuid routerId,
+ Uuid vpnId, Uuid portId) {
Subnetmap subnetmap = null;
SubnetmapBuilder builder = null;
boolean isLockAcquired = false;
logger.debug("updating Subnet :new: ");
}
+ if (subnetIp != null) {
+ builder.setSubnetIp(subnetIp);
+ }
if (routerId != null) {
builder.setRouterId(routerId);
}
return subnetmap;
}
+ protected void deleteSubnetMapNode(Uuid subnetId) {
+ boolean isLockAcquired = false;
+ InstanceIdentifier<Subnetmap> subnetMapIdentifier = InstanceIdentifier.builder(Subnetmaps.class)
+ .child(Subnetmap.class, new SubnetmapKey(subnetId)).build();
+ logger.debug("removing subnetMap node: {} ", subnetId.getValue());
+ try {
+ isLockAcquired = NeutronvpnUtils.lock(lockManager, subnetId.getValue());
+ MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, subnetMapIdentifier);
+ } catch (Exception e) {
+ logger.error("Delete subnetMap node failed for subnet : {} ", subnetId.getValue());
+ } finally {
+ if (isLockAcquired) {
+ NeutronvpnUtils.unlock(lockManager, subnetId.getValue());
+ }
+ }
+ }
+
private void updateVpnInstanceNode(String vpnName, List<String> rd, List<String> irt, List<String> ert) {
VpnInstanceBuilder builder = null;
}
String portname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
List<Adjacency> adjList = new ArrayList<Adjacency>();
- InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
- child(VpnInterface.class, new VpnInterfaceKey(portname)).build();
+ InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(portname);
+
// find router associated to vpn
Uuid routerId = NeutronvpnUtils.getRouterforVpn(broker, vpnId);
Router rtr = null;
if (port != null) {
boolean isLockAcquired = false;
String pname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
- InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).
- child(VpnInterface.class, new VpnInterfaceKey(pname)).build();
+ InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(pname);
+
try {
isLockAcquired = NeutronvpnUtils.lock(lockManager, pname);
logger.debug("Deleting vpn interface {}", pname);
}
}
+ protected void updateVpnInterface(Uuid vpnId, Port port) {
+ if (vpnId == null || port == null) {
+ return;
+ }
+ boolean isLockAcquired = false;
+ String portname = NeutronvpnUtils.uuidToTapPortName(port.getUuid());
+ String ifname = new StringBuilder(portname).append(":0").toString();
+ InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(ifname);
+ try {
+ Optional<VpnInterface> optionalVpnInterface = NeutronvpnUtils.read(broker, LogicalDatastoreType
+ .CONFIGURATION, vpnIfIdentifier);
+ if (optionalVpnInterface.isPresent()) {
+ VpnInterfaceBuilder vpnIfBuilder = new VpnInterfaceBuilder(optionalVpnInterface.get());
+ VpnInterface vpnIf = vpnIfBuilder.setVpnInstanceName(vpnId.getValue()).build();
+ isLockAcquired = NeutronvpnUtils.lock(lockManager, ifname);
+ logger.debug("Updating vpn interface {}", vpnIf);
+ MDSALUtil.syncUpdate(broker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
+ } else {
+ logger.error("VPN Interface {} not found", ifname);
+ }
+ } catch (Exception ex) {
+ logger.error("Updation of vpninterface {} failed due to {}", ifname, ex);
+ } finally {
+ if (isLockAcquired) {
+ NeutronvpnUtils.unlock(lockManager, ifname);
+ }
+ }
+ }
+
public void createL3Vpn(Uuid vpn, String name, Uuid tenant, List<String> rd, List<String> irt, List<String> ert,
Uuid router, List<Uuid> networks) {
vpn.getImportRT(), vpn.getExportRT(), vpn.getRouterId(), vpn.getNetworkIds());
} catch (Exception ex) {
msg = String.format("Creation of L3VPN failed for VPN %s", vpn.getId().getValue());
- logger.error(msg, ex.getMessage());
+ logger.error(msg, ex);
error = RpcResultBuilder.newError(ErrorType.APPLICATION, msg, ex.getMessage());
errorList.add(error);
failurecount++;
InstanceIdentifier.builder(VpnInstances.class).build();
Optional<VpnInstances> optionalVpns = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
vpnsIdentifier);
- if (optionalVpns.isPresent()) {
+ if (optionalVpns.isPresent() && optionalVpns.get().getVpnInstance() != null) {
for (VpnInstance vpn : optionalVpns.get().getVpnInstance()) {
vpns.add(vpn);
}
for (VpnInstance vpnInstance : vpns) {
Uuid vpnId = new Uuid(vpnInstance.getVpnInstanceName());
// create VpnMaps id
- InstanceIdentifier<VpnMap> vpnMapIdentifier =
- InstanceIdentifier.builder(VpnMaps.class)
- .child(VpnMap.class, new VpnMapKey(vpnId)).build();
+ InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap
+ .class, new VpnMapKey(vpnId)).build();
L3vpnInstancesBuilder l3vpn = new L3vpnInstancesBuilder();
List<String> rd = Arrays.asList(vpnInstance.getIpv4Family().getRouteDistinguisher().split(","));
} catch (Exception ex) {
String message = String.format("GetL3VPN failed due to %s", ex.getMessage());
- logger.error(message);
+ logger.error(message, ex);
result.set(RpcResultBuilder.<GetL3VPNOutput>failed().withError(ErrorType.APPLICATION, message).build());
}
-
return result;
}
}
} catch (Exception ex) {
msg = String.format("Deletion of L3VPN failed when deleting for uuid %s", vpn.getValue());
- logger.error(msg, ex.getMessage());
+ logger.error(msg, ex);
error = RpcResultBuilder.newError(ErrorType.APPLICATION, msg, ex.getMessage());
errorList.add(error);
failurecount++;
protected void addSubnetToVpn(Uuid vpnId, Uuid subnet) {
logger.debug("Adding subnet {} to vpn {}", subnet.getValue(), vpnId.getValue());
- Subnetmap sn = updateSubnetNode(subnet, null, null, null, vpnId, null);
+ Subnetmap sn = updateSubnetNode(subnet, null, null, null, null, vpnId, null);
// Check if there are ports on this subnet and add corresponding vpn-interfaces
List<Uuid> portList = sn.getPortList();
if (portList != null) {
}
}
+ protected void updateVpnForSubnet(Uuid vpnId, Uuid subnet) {
+ logger.debug("Updating VPN {} for subnet {}", vpnId.getValue(), subnet.getValue());
+ Subnetmap sn = updateSubnetNode(subnet, null, null, null, null, vpnId, null);
+ // Check for ports on this subnet and update association of corresponding vpn-interfaces to external vpn
+ List<Uuid> portList = sn.getPortList();
+ if (portList != null) {
+ for (Uuid port : sn.getPortList()) {
+ logger.debug("Updating vpn-interface for port {}", port.getValue());
+ updateVpnInterface(vpnId, getNeutronPort(port));
+ }
+ }
+ }
+
protected List<Adjacency> addAdjacencyforExtraRoute(List<Routes> routeList, boolean rtrUp, String vpnifname) {
List<Adjacency> adjList = new ArrayList<Adjacency>();
for (Routes route : routeList) {
}
protected void associateRouterToVpn(Uuid vpnId, Uuid routerId) {
-
+ updateVpnMaps(vpnId, null, routerId, null, null);
List<Uuid> routerSubnets = NeutronvpnUtils.getNeutronRouterSubnetIds(broker, routerId);
-
if (!vpnId.equals(routerId)) {
- logger.debug("Removing subnets from internal vpn {}", routerId.getValue());
+ logger.debug("Updating association of subnets to external vpn {}", vpnId.getValue());
if (routerSubnets != null) {
- for (Uuid subnet : routerSubnets) {
- removeSubnetFromVpn(routerId, subnet);
+ for (Uuid subnetId : routerSubnets) {
+ updateVpnForSubnet(vpnId, subnetId);
}
}
+ } else {
+ logger.debug("Adding subnets to internal vpn {}", vpnId.getValue());
+ for (Uuid subnet : routerSubnets) {
+ addSubnetToVpn(vpnId, subnet);
+ }
}
- logger.debug("Adding subnets to vpn {}", vpnId.getValue());
- for (Uuid subnet : routerSubnets) {
- addSubnetToVpn(vpnId, subnet);
- }
-
- updateVpnMaps(vpnId, null, routerId, null, null);
}
protected void dissociateRouterFromVpn(Uuid vpnId, Uuid routerId) {
- // remove existing external vpn interfaces
List<Uuid> routerSubnets = NeutronvpnUtils.getNeutronRouterSubnetIds(broker, routerId);
-
if (routerSubnets != null) {
- for (Uuid subnet : routerSubnets) {
- logger.debug("Removing subnets from external vpn {}", vpnId.getValue());
- removeSubnetFromVpn(vpnId, subnet);
- logger.debug("Adding subnets to internal vpn {}", routerId.getValue());
- addSubnetToVpn(routerId, subnet);
+ for (Uuid subnetId : routerSubnets) {
+ logger.debug("Updating association of subnets to internal vpn {}", routerId.getValue());
+ updateVpnForSubnet(routerId, subnetId);
}
}
clearFromVpnMaps(vpnId, routerId, null);
} catch (Exception ex) {
String message = String.format("associate Networks to vpn %s failed due to %s", input.getVpnId().getValue(),
ex.getMessage());
- logger.error(message);
+ logger.error(message, ex);
result.set(RpcResultBuilder.<AssociateNetworksOutput>failed().withError(ErrorType.APPLICATION, message)
.build());
}
} catch (Exception ex) {
String message = String.format("associate router %s to vpn %s failed due to %s", routerId.getValue(),
vpnId.getValue(), ex.getMessage());
- logger.error(message);
+ logger.error(message, ex);
result.set(RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, message).build());
}
logger.debug("associateRouter returns..");
returnMsg.append("VPN not found : ").append(vpnId.getValue());
}
if (returnMsg.length() != 0) {
- String message = String.format("disssociate Networks to vpn %s failed due to %s", vpnId.getValue(),
+ String message = String.format("dissociate Networks to vpn %s failed due to %s", vpnId.getValue(),
returnMsg);
logger.error(message);
String errorResponse = String.format("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: " +
} catch (Exception ex) {
String message = String.format("dissociate Networks to vpn %s failed due to %s", input.getVpnId().
getValue(), ex.getMessage());
- logger.error(message);
+ logger.error(message, ex);
result.set(RpcResultBuilder.<DissociateNetworksOutput>failed().withError(ErrorType.APPLICATION, message)
.build());
}
returnMsg.append("VPN not found : ").append(vpnId.getValue());
}
if (returnMsg.length() != 0) {
- String message = String.format("disssociate router %s to vpn %s failed due to %s", routerId.getValue(),
+ String message = String.format("dissociate router %s to vpn %s failed due to %s", routerId.getValue(),
vpnId.getValue(), returnMsg);
logger.error(message);
String errorResponse = String.format("ErrorType: PROTOCOL, ErrorTag: invalid-value, ErrorMessage: " +
} catch (Exception ex) {
String message = String.format("disssociate router %s to vpn %s failed due to %s", routerId.getValue(),
vpnId.getValue(), ex.getMessage());
- logger.error(message);
+ logger.error(message, ex);
result.set(RpcResultBuilder.<Void>failed().withError(ErrorType.APPLICATION, message).build());
}
logger.debug("dissociateRouter returns..");
InstanceIdentifier<Subnetmaps> subnetmapsid = InstanceIdentifier.builder(Subnetmaps.class).build();
Optional<Subnetmaps> subnetmaps = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION,
subnetmapsid);
- if (subnetmaps.isPresent()) {
- Subnetmaps smaps = subnetmaps.get();
- List<Subnetmap> subnetMapList = smaps.getSubnetmap();
+ if (subnetmaps.isPresent() && subnetmaps.get().getSubnetmap() != null) {
+ List<Subnetmap> subnetMapList = subnetmaps.get().getSubnetmap();
for (Subnetmap subnetMap : subnetMapList) {
if (subnetMap.getVpnId() != null && subnetMap.getVpnId().equals(vpnid)) {
subnets.add(subnetMap.getId());
InstanceIdentifier<Ports> portidentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class);
try {
Optional<Ports> ports = NeutronvpnUtils.read(broker, LogicalDatastoreType.CONFIGURATION, portidentifier);
- if (ports.isPresent()) {
+ if (ports.isPresent() && ports.get().getPort()!= null) {
List<Port> portList = ports.get().getPort();
for (Port port : portList) {
result.add(String.format(" %-22s %-22s %-22s %-6s ", NeutronvpnUtils.uuidToTapPortName(port
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
protected static Uuid getVpnForNetwork(DataBroker broker, Uuid network) {
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optionalVpnMaps = read(broker, LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
- if (optionalVpnMaps.isPresent()) {
- VpnMaps vpnMaps = optionalVpnMaps.get();
- List<VpnMap> allMaps = vpnMaps.getVpnMap();
+ if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
+ List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
for (VpnMap vpnMap : allMaps) {
if (vpnMap.getNetworkIds().contains(network)) {
return vpnMap.getVpnId();
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optionalVpnMaps = read(broker, LogicalDatastoreType.CONFIGURATION,
vpnMapsIdentifier);
- if (optionalVpnMaps.isPresent()) {
- VpnMaps vpnNets = optionalVpnMaps.get();
- List<VpnMap> allMaps = vpnNets.getVpnMap();
+ if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
+ List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
if (routerId != null) {
for (VpnMap vpnMap : allMaps) {
if (routerId.equals(vpnMap.getRouterId())) {
if (router != null) {
List<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router
.Interfaces> interfacesList = router.getInterfaces();
- if (!interfacesList.isEmpty()) {
+ if (interfacesList != null) {
for (org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers
.router.Interfaces interfaces : interfacesList) {
subnetIdList.add(interfaces.getSubnetId());
protected static boolean lock(LockManagerService lockManager, String lockName) {
TryLockInput input = new TryLockInputBuilder().setLockName(lockName).setTime(5L).setTimeUnit
(TimeUnits.Milliseconds).build();
- boolean islockAquired = false;
+ boolean islockAcquired = false;
try {
Future<RpcResult<Void>> result = lockManager.tryLock(input);
if ((result != null) && (result.get().isSuccessful())) {
logger.debug("Acquired lock for {}", lockName);
- islockAquired = true;
+ islockAcquired = true;
} else {
- throw new RuntimeException(String.format("Unable to acquire lock for %s", lockName));
+ logger.error("Unable to acquire lock for {}", lockName);
}
} catch (InterruptedException | ExecutionException e) {
logger.error("Unable to acquire lock for {}", lockName);
- throw new RuntimeException(String.format("Unable to acquire lock for %s", lockName), e
- .getCause());
+ throw new RuntimeException(String.format("Unable to acquire lock for %s", lockName), e.getCause());
}
- return islockAquired;
+ return islockAcquired;
}
- protected static void unlock(LockManagerService lockManager, String lockName) {
+ protected static boolean unlock(LockManagerService lockManager, String lockName) {
UnlockInput input = new UnlockInputBuilder().setLockName(lockName).build();
+ boolean islockAcquired = false;
try {
Future<RpcResult<Void>> result = lockManager.unlock(input);
if ((result != null) && (result.get().isSuccessful())) {
logger.debug("Unlocked {}", lockName);
+ islockAcquired = true;
} else {
- logger.debug("Unable to unlock {}", lockName);
+ logger.error("Unable to unlock {}", lockName);
}
} catch (InterruptedException | ExecutionException e) {
logger.error("Unable to unlock {}", lockName);
- throw new RuntimeException(String.format("Unable to unlock %s", lockName), e
- .getCause());
+ throw new RuntimeException(String.format("Unable to unlock %s", lockName), e.getCause());
}
+ return islockAcquired;
}
protected static Short getIPPrefixFromPort(DataBroker broker, Port port) {
logger.trace("Unable to read on subnet datastore");
}
} catch (Exception e) {
- logger.trace("Failed to retrieve IP prefix from port : ", e);
+ logger.error("Failed to retrieve IP prefix from port : ", e);
System.out.println("Failed to retrieve IP prefix from port : " + e.getMessage());
}
return null;
return id;
}
+ static InstanceIdentifier<VpnInterface> buildVpnInterfaceIdentifier(String ifName) {
+ InstanceIdentifier<VpnInterface> id = InstanceIdentifier.builder(VpnInterfaces.class).
+ child(VpnInterface.class, new VpnInterfaceKey(ifName)).build();
+ return id;
+ }
+
static InstanceIdentifier<Subnetmap> buildSubnetMapIdentifier(Uuid subnetId) {
InstanceIdentifier<Subnetmap> id = InstanceIdentifier.builder(Subnetmaps.class).child(Subnetmap.class, new
SubnetmapKey(subnetId)).build();
LOG.trace("VPN Interface already provisioned , bailing out from here.");
return;
}
-
bindService(dpId, vpnName, interfaceName, lPortTag);
updateDpnDbs(vpnName, interfaceName, true);
processVpnInterfaceAdjacencies(VpnUtil.getVpnInterfaceIdentifier(vpnInterface.getName()), vpnInterface, true);
}
@Override
- protected void update(InstanceIdentifier<VpnInterface> identifier,
- VpnInterface original, VpnInterface update) {
- LOG.trace("Update VPN Interface {} , original {}, update {}",
- identifier, original, update);
- String vpnName = original.getVpnInstanceName();
-
- boolean vpnNameChanged = false;
- String rd = getRouteDistinguisher(vpnName);
- String newRd = rd;
- String newVpnName = update.getVpnInstanceName();
- if(!vpnName.equals(newVpnName)) {
- //VPN for this interface got changed.
- //Remove the interface from old VPN and add it to new VPN
- newRd = getRouteDistinguisher(newVpnName);
- if(newRd.equals("")) {
- LOG.warn("VPN Instance {} not found. Update operation aborted", newVpnName);
- return;
- }
- vpnNameChanged = true;
- LOG.debug("New VPN Name for the interface {} is {}", newVpnName, original.getName());
+ protected void update(InstanceIdentifier<VpnInterface> identifier, VpnInterface original, VpnInterface update) {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Updating VPN Interface : key " + identifier + ", original value=" + original + ", update " +
+ "value=" + update);
}
-
+ String oldVpnName = original.getVpnInstanceName();
+ String newVpnName = update.getVpnInstanceName();
List<Adjacency> oldAdjs = original.getAugmentation(Adjacencies.class).getAdjacency();
List<Adjacency> newAdjs = update.getAugmentation(Adjacencies.class).getAdjacency();
- if(vpnNameChanged && newAdjs != null && !newAdjs.isEmpty()) {
- long label = VpnConstants.INVALID_ID;
- InstanceIdentifier<Adjacencies> path = identifier.augmentation(Adjacencies.class);
- Optional<Adjacencies> adjacencies = VpnUtil.read(broker, LogicalDatastoreType.OPERATIONAL, path);
- if (adjacencies.isPresent()) {
- List<Adjacency> nextHops = adjacencies.get().getAdjacency();
- for(Adjacency nextHop : nextHops) {
- label = nextHop.getLabel();
- if(label == VpnConstants.INVALID_ID) {
- //Generate label using ID Manager
- label = VpnUtil.getUniqueId(idManager, VpnConstants.VPN_IDPOOL_NAME,
- VpnUtil.getNextHopLabelKey(newRd, nextHop.getIpAddress()));
- }
- if (rd != null) {
- removePrefixFromBGP(rd, nextHop.getIpAddress());
- } else {
- removeFibEntryFromDS(vpnName, nextHop.getIpAddress());
- }
- //updatePrefixToBGP(newRd, nextHop, nextHopIp, label);
- }
- processVpnInterfaceAdjacencies(identifier, update, true);
- VpnUtil.syncUpdate(broker, LogicalDatastoreType.OPERATIONAL, identifier, update);
- }
- } else if (oldAdjs != newAdjs) {
- //handle both addition and removal of adjacencies
- //currently, new adjacency may be an extra route
+ if (oldAdjs == null) {
+ oldAdjs = new ArrayList<>();
+ }
+ if (newAdjs == null) {
+ newAdjs = new ArrayList<>();
+ }
+ //handles switching between <internal VPN - external VPN>
+ if (!oldVpnName.equals(newVpnName)) {
+ remove(identifier, original);
+ add(identifier, update);
+ }
+ //handle both addition and removal of adjacencies
+ //currently, new adjacency may be an extra route
+ if (!oldAdjs.equals(newAdjs)) {
for (Adjacency adj : newAdjs) {
if (oldAdjs.contains(adj)) {
oldAdjs.remove(adj);
addNewAdjToVpnInterface(identifier, adj);
}
}
-
for (Adjacency adj : oldAdjs) {
delAdjFromVpnInterface(identifier, adj);
}
}
- else {
- LOG.debug("No Update information is available for VPN Interface to proceed");
- }
-
}
public void processArpRequest(IpAddress srcIP, PhysAddress srcMac, IpAddress targetIP, String srcInterface){