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) {
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.IfmUtil;
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;
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);
}
protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
logger.trace("Operation Interface update event - Old: {}, New: {}", original, update);
String interfaceName = update.getName();
- ElanInterface elanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
- if(elanInterface == null) {
- logger.debug("No Elan Interface is created for the interface:{} ", interfaceName);
- return;
- }
- Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface>
- intf = ElanUtils.read(broker, LogicalDatastoreType.CONFIGURATION, IfmUtil.buildId(interfaceName));
- if (intf != null && intf.get().getType().equals(Tunnel.class)) {
- if(update.getOperStatus().equals(Interface.OperStatus.Up) && update.getAdminStatus() == Interface.AdminStatus.Up) {
+ 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)) {
+ } else if (update.getOperStatus().equals(Interface.OperStatus.Down)) {
logger.trace("Operation Status for Interface:{} event state DOWN ", interfaceName);
handleVlanInterfaceOperationalStateChange(interfaceName, false);
}
+
}
}
String interfaceName = intrf.getName();
ElanInterface elanInterface = ElanUtils.getElanInterfaceByElanInterfaceName(interfaceName);
if(elanInterface == null) {
- logger.debug("No Elan Interface is created for the interface:{} ", interfaceName);
+ 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);
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;
+ }
}
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;
+ }
}