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;
+ }
}