Bug 5182 - Customized name support for VLAN trunk should be supported 69/34169/1
authorFaseela K <faseela.k@ericsson.com>
Fri, 5 Feb 2016 14:05:17 +0000 (19:35 +0530)
committerFaseela K <faseela.k@ericsson.com>
Fri, 5 Feb 2016 15:21:47 +0000 (15:21 +0000)
Description : Changing the code, to accept any name as interface name.
              Also, fixing minor issues found in arp-utils when this
      change was done

Change-Id: I5685ffdbcc4b27ab76e6a4bcb06211d242c71f45
Signed-off-by: Faseela K <faseela.k@ericsson.com>
(cherry picked from commit e93a84dd08d096592729ad8807f6f74e7ba411a9)

21 files changed:
arputil/arputil-impl/src/main/java/org/opendaylight/vpnservice/arputil/internal/ArpUtilImpl.java
arputil/arputil-impl/src/main/java/org/opendaylight/vpnservice/arputil/internal/ArpUtilProvider.java
interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang
interfacemgr/interfacemgr-impl/pom.xml
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/IfmUtil.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/commons/InterfaceManagerCommonUtils.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/InterfaceConfigListener.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/VlanMemberConfigListener.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigRemoveHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsInterfaceConfigUpdateHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsVlanMemberConfigAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/confighelpers/OvsVlanMemberConfigRemoveHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateAddHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateRemoveHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/ovs/statehelpers/OvsInterfaceStateUpdateHelper.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/rpcservice/InterfaceManagerRpcService.java
interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/servicebindings/flowbased/utilities/FlowBasedServicesUtils.java
interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/InterfaceManagerTestUtil.java
interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/StateInterfaceTest.java
interfacemgr/interfacemgr-impl/src/test/java/org/opendaylight/vpnservice/interfacemgr/test/VlanInterfaceConfigurationTest.java

index 772b7811cbcf80753d4b19600a2dad25b8943611..8128d9156ba42ad9944c54d2a074ace90b10949e 100644 (file)
@@ -17,10 +17,10 @@ import java.net.UnknownHostException;
 import java.util.List;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-
 import org.opendaylight.controller.liblldp.NetUtils;
 import org.opendaylight.controller.liblldp.Packet;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -28,7 +28,10 @@ import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
 import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
 import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
 import org.opendaylight.vpnservice.mdsalutil.NWUtil;
 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
 import org.opendaylight.vpnservice.mdsalutil.packet.ARP;
@@ -49,12 +52,14 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Metadata;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketInReason;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingListener;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.ArpRequestReceived;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.ArpRequestReceivedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.ArpResponseReceivedBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.GetMacInput;
@@ -67,6 +72,13 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.SendArpResponseInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.arputil.rev151126.interfaces.InterfaceAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.BaseIds;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetInterfaceFromIfIndexOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.GetPortFromInterfaceOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rpcs.rev151003.OdlInterfaceRpcService;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -107,6 +119,8 @@ public class ArpUtilImpl implements OdlArputilService,
     private static final Logger LOGGER = LoggerFactory
             .getLogger(ArpUtilImpl.class);
 
+    static OdlInterfaceRpcService intfRpc;
+    
     ExecutorService threadPool = Executors.newFixedThreadPool(1);
 
     DataBroker dataBroker;
@@ -115,6 +129,7 @@ public class ArpUtilImpl implements OdlArputilService,
     NotificationService notificationService;
     IMdsalApiManager mdsalMgr;
 
+    RpcProviderRegistry rpc;
     ListenerRegistration<ArpUtilImpl> listenerRegistration;
 
     ConcurrentMap<String, String> macsDB = new ConcurrentHashMap<>();
@@ -124,18 +139,26 @@ public class ArpUtilImpl implements OdlArputilService,
             PacketProcessingService packetProcessingService,
             NotificationPublishService notificationPublishService,
             NotificationService notificationService,
-            IMdsalApiManager mdsalApiManager) {
+            IMdsalApiManager mdsalApiManager,
+            RpcProviderRegistry rpc) {
 
         this.dataBroker = db;
         this.packetProcessingService = packetProcessingService;
         this.notificationPublishService = notificationPublishService;
         this.mdsalMgr = mdsalApiManager;
         this.notificationService = notificationService;
-
+        this.rpc = rpc;
         listenerRegistration = notificationService
                 .registerNotificationListener(this);
         LOGGER.info("ArpUtil Manager Initialized ");
     }
+    
+    OdlInterfaceRpcService getInterfaceRpcService() {
+       if (intfRpc == null ) {
+               intfRpc = rpc.getRpcService(OdlInterfaceRpcService.class);
+       }
+       return intfRpc;
+    }
 
     @Override
     public void close() throws Exception {
@@ -243,8 +266,11 @@ public class ArpUtilImpl implements OdlArputilService,
 
                 NodeConnectorId id = getNodeConnectorFromInterfaceName(interfaceName);
 
-                dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
-                Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+                GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
+                //dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
+                //Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+                dpnId = portResult.getDpid();
+                Long portid = portResult.getPortno();
                 checkArgument(null != dpnId && BigInteger.ZERO != dpnId,
                         DPN_NOT_FOUND_ERROR, interfaceName);
 
@@ -275,7 +301,7 @@ public class ArpUtilImpl implements OdlArputilService,
                     LOGGER.trace("sent arp request for "
                             + arpReqInput.getIpaddress());
                 }
-            } catch (Exception e) {
+            } catch (Throwable e) {
                 LOGGER.trace("failed to send arp req for {} on interface {}",
                         arpReqInput.getIpaddress(), interfaceName);
 
@@ -326,11 +352,18 @@ public class ArpUtilImpl implements OdlArputilService,
 
         try {
             String interfaceName = input.getInterface();
-            NodeConnectorId id = getNodeConnectorFromInterfaceName(interfaceName);
+            //NodeConnectorId id = getNodeConnectorFromInterfaceName(interfaceName);
+
+            //dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
+            //Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
 
-            dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
-            Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+            GetPortFromInterfaceOutput portResult = getPortFromInterface(interfaceName);
+            //dpnId = BigInteger.valueOf(MDSALUtil.getDpnIdFromPortName(id));
+            //Long portid = MDSALUtil.getOfPortNumberFromPortName(id);
+            dpnId = portResult.getDpid();
+            Long portid = portResult.getPortno();
 
+            
             NodeConnectorRef ref = MDSALUtil.getNodeConnRef(dpnId,
                     portid.toString());
             checkArgument(null != dpnId && BigInteger.ZERO != dpnId,
@@ -359,7 +392,7 @@ public class ArpUtilImpl implements OdlArputilService,
                 LOGGER.trace("sent the arp response for "
                         + input.getSrcIpAddress());
             }
-        } catch (Exception e) {
+        } catch (Throwable e) {
             LOGGER.trace("failed to send arp response for {} {}",
                     input.getSrcIpAddress(), e);
             return RpcResultBuilder.<Void> failed()
@@ -402,8 +435,11 @@ public class ArpUtilImpl implements OdlArputilService,
 
                 NodeConnectorRef ref = packetReceived.getIngress();
 
-                String interfaceName = MDSALUtil.getInterfaceName(ref, dataBroker);
-
+                Metadata i  = packetReceived.getMatch().getMetadata();
+                
+                //String interfaceName = MDSALUtil.getInterfaceName(ref, dataBroker);
+                String interfaceName = getInterfaceName(ref,i, dataBroker);
+                
                 checkAndFireMacChangedNotification(interfaceName, srcInetAddr,
                         srcMac);
 
@@ -421,13 +457,40 @@ public class ArpUtilImpl implements OdlArputilService,
                     threadPool.submit(new MacResponderTask(arp));
                 }
 
-            } catch (Exception e) {
+            } catch (Throwable e) {
                 LOGGER.trace("Failed to decode packet: {}", e);
             }
         }
     }
 
-    class MacResponderTask implements Runnable {
+    GetPortFromInterfaceOutput getPortFromInterface(String interfaceName) throws Throwable {
+       GetPortFromInterfaceInputBuilder x = new GetPortFromInterfaceInputBuilder();
+               x.setIntfName(interfaceName);;
+               Future<RpcResult<GetPortFromInterfaceOutput>> ft = intfRpc.getPortFromInterface(x.build());
+               GetPortFromInterfaceOutput result = ft.get().getResult();
+               LOGGER.trace("getPortFromInterface rpc result is {} ", result);
+               if (result != null) {
+                       LOGGER.trace("getPortFromInterface rpc result is {} {} ", result.getDpid(), result.getPortno());
+               }
+               return result;
+    }
+    
+    private String getInterfaceName(NodeConnectorRef ref, Metadata metadata, DataBroker dataBroker2) throws Throwable {
+       LOGGER.debug("metadata received is {} ", metadata);
+       
+       GetInterfaceFromIfIndexInputBuilder ifIndexInputBuilder = new GetInterfaceFromIfIndexInputBuilder();
+       BigInteger lportTag = MetaDataUtil.getLportFromMetadata(metadata.getMetadata());
+       
+       ifIndexInputBuilder.setIfIndex(lportTag.intValue());
+       GetInterfaceFromIfIndexInput input = ifIndexInputBuilder.build();
+       OdlInterfaceRpcService intfRpc = getInterfaceRpcService();
+
+               Future<RpcResult<GetInterfaceFromIfIndexOutput>> interfaceFromIfIndex = intfRpc.getInterfaceFromIfIndex(input);
+               GetInterfaceFromIfIndexOutput interfaceFromIfIndexOutput = interfaceFromIfIndex.get().getResult();
+        return interfaceFromIfIndexOutput.getInterfaceName();
+       }
+
+       class MacResponderTask implements Runnable {
         ARP arp;
 
         MacResponderTask(ARP arp) {
index d22f699639be584a62efbed4795d74fc1702e1d9..fc812c44cbe06dd35eb1e09e7904d2e78ec6581e 100644 (file)
@@ -62,7 +62,7 @@ public class ArpUtilProvider implements BindingAwareProvider, AutoCloseable {
 
             arpManager = new ArpUtilImpl( dataBroker, packetProcessingService,
                     notificationPublishService, notificationService,
-                     mdsalApiManager) ;
+                     mdsalApiManager, rpcProviderRegistry) ;
 
             rpcRegistration = rpcProviderRegistry.
                     addRpcImplementation(OdlArputilService.class, arpManager);
index 29994dafdc8937b8f29842a81f3e1f3595ae018b..e72728aa2703c2b37a872643166701c4e46c66b1 100644 (file)
@@ -143,6 +143,7 @@ module odl-interface {
                         "The VLAN mode transparent.";
                 }
             }
+            default "trunk";
         }
     }
 
index 7580d63fd254679733cabb86cd889e5402e3d790..b9e22b40db702bffab40597c50ab4669e17785a2 100644 (file)
@@ -35,11 +35,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <groupId>org.opendaylight.mdsal.model</groupId>
       <artifactId>ietf-interfaces</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.vpnservice</groupId>
-      <artifactId>vpnmanager-impl</artifactId>
-      <version>${vpnservices.version}</version>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.vpnservice</groupId>
       <artifactId>mdsalutil-api</artifactId>
index 7855fe17f78d08a69cb30525a23fb9314be4cc9d..c1f2cb957f7b492141d97762c0344a667643fba7 100644 (file)
@@ -230,8 +230,13 @@ public class IfmUtil {
 
     public static BigInteger getDpnId(DatapathId datapathId){
         if (datapathId != null) {
+            // Adding logs for a random issue spotted during datapath id conversion
+            LOG.info("Received datapathId {}",datapathId.getValue());
             String dpIdStr = datapathId.getValue().replace(":", "");
-            return new BigInteger(dpIdStr, 16);
+            LOG.info("Received datapathId {}",dpIdStr);
+            BigInteger dpnId =  new BigInteger(dpIdStr, 16);
+            LOG.info("After conversion datapathId {}",dpnId);
+            return dpnId;
         }
         return null;
     }
index 7cc125d3b4a93e4f2f3fc7a0b27543b65e9e30d0..5fb0f89ae36a746bcd05b07ee2bc4ab21f82a5d6 100644 (file)
@@ -14,15 +14,17 @@ 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.VpnConstants;
 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.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.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.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.flow.inventory.rev130819.FlowCapableNodeConnector;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
@@ -30,17 +32,23 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.No
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeMplsOverGre;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 
 public class InterfaceManagerCommonUtils {
     private static final Logger LOG = LoggerFactory.getLogger(InterfaceManagerCommonUtils.class);
@@ -135,4 +143,174 @@ public class InterfaceManagerCommonUtils {
         LOG.trace("Updating trunk interface {} in Config DS", interfaceName);
         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);
+        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);
+    }
+
+    /*public static void updateStateEntry(Interface interfaceInfo, DataBroker dataBroker, WriteTransaction transaction,
+                                         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+        String ncStr = ifState.getLowerLayerIf().get(0);
+        NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
+        NodeConnector nodeConnector =
+                InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
+        if(nodeConnector != null) {
+            FlowCapableNodeConnector flowCapableNodeConnector =
+                    nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+            //State state = flowCapableNodeConnector.getState();
+            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus =
+                    flowCapableNodeConnector == null ? org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down : org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up;
+
+            if (ifState.getOperStatus() != operStatus) {
+                InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+                        IfmUtil.buildStateInterfaceId(interfaceInfo.getName());
+                InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
+                ifaceBuilder.setOperStatus(operStatus);
+                ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceInfo.getName()));
+                transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+            }
+        }
+    }*/
+
+    public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus
+           updateStateEntry(Interface interfaceNew, DataBroker dataBroker, WriteTransaction transaction,
+                          org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus;
+        if (!interfaceNew.isEnabled()) {
+            operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+        } else {
+            String ncStr = ifState.getLowerLayerIf().get(0);
+            NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
+            NodeConnector nodeConnector =
+                    InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
+            FlowCapableNodeConnector flowCapableNodeConnector =
+                    nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
+            //State state = flowCapableNodeConnector.getState();
+            operStatus = flowCapableNodeConnector == null ? org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down : org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up;
+        }
+
+        String ifName = interfaceNew.getName();
+        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+                IfmUtil.buildStateInterfaceId(interfaceNew.getName());
+        InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
+        ifaceBuilder.setOperStatus(operStatus);
+        ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifName));
+        transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+        return operStatus;
+    }
+
+    public static void updateOperStatus(String interfaceName, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus,
+                                        WriteTransaction transaction) {
+        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
+                IfmUtil.buildStateInterfaceId(interfaceName);
+        InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder();
+        ifaceBuilderChild.setOperStatus(operStatus);
+        ifaceBuilderChild.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceName));
+        transaction.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilderChild.build());
+    }
+
+    public static void addStateEntry(String interfaceName, WriteTransaction transaction, DataBroker dataBroker, IdManagerService idManager,
+                                     org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus = ifState.getOperStatus();
+        PhysAddress physAddress = ifState.getPhysAddress();
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus = ifState.getAdminStatus();
+        NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
+        InterfaceKey interfaceKey = new InterfaceKey(interfaceName);
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface interfaceInfo =
+                InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
+
+        if (interfaceInfo != null && !interfaceInfo.isEnabled()) {
+            operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+        }
+
+        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+                IfmUtil.buildStateInterfaceId(interfaceName);
+        List<String> childLowerLayerIfList = new ArrayList<>();
+        childLowerLayerIfList.add(0, nodeConnectorId.getValue());
+        //childLowerLayerIfList.add(1, interfaceName);
+        InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
+                .setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
+
+        Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceName);
+        ifaceBuilder.setIfIndex(ifIndex);
+
+        if(interfaceInfo != null){
+            ifaceBuilder.setType(interfaceInfo.getType());
+        }
+        ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceInfo.getName()));
+        transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
+
+        // create lportTag Interface Map
+        InterfaceMetaUtils.createLportTagInterfaceMap(transaction, interfaceName, ifIndex);
+
+        // install ingress flow
+        BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
+        long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
+        if(interfaceInfo.isEnabled() && ifState.getOperStatus() == org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Up) {
+            List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, interfaceInfo);
+            FlowBasedServicesUtils.installVlanFlow(dpId, portNo, interfaceInfo, transaction, matches, ifIndex);
+        }
+    }
+
+    public static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface
+                  addStateEntry(Interface interfaceInfo, String portName, WriteTransaction transaction, IdManagerService idManager,
+                                     PhysAddress physAddress, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus operStatus,
+                                     org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.AdminStatus adminStatus,
+                                     NodeConnectorId nodeConnectorId) {
+        if (interfaceInfo != null && !interfaceInfo.isEnabled()) {
+            operStatus = org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus.Down;
+        }
+        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
+                IfmUtil.buildStateInterfaceId(portName);
+        List<String> childLowerLayerIfList = new ArrayList<>();
+        childLowerLayerIfList.add(0, nodeConnectorId.getValue());
+        //childLowerLayerIfList.add(1, interfaceInfo.getName());
+        InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
+                .setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
+
+        Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, portName);
+        ifaceBuilder.setIfIndex(ifIndex);
+
+        if(interfaceInfo != null){
+            ifaceBuilder.setType(interfaceInfo.getType());
+        }
+        ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(portName));
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState = ifaceBuilder.build();
+        transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId,ifState , true);
+
+        // allocate lport tag and set in if-index
+        InterfaceMetaUtils.createLportTagInterfaceMap(transaction, portName, ifIndex);
+        return ifState;
+    }
+
+    public static void deleteStateEntry(String interfaceName, WriteTransaction transaction) {
+        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
+                IfmUtil.buildStateInterfaceId(interfaceName);
+        transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
+    }
 }
\ No newline at end of file
index be8bd8d15b0072c6145506126ba1cd19d108aa27..24c72e55551c950b21a8acb5cb3b6bb727458e6d 100644 (file)
@@ -67,15 +67,17 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         String parentInterface = null;
 
         ParentRefs parentRefs = interfaceOld.getAugmentation(ParentRefs.class);
-        if (parentRefs != null) {
-            parentInterface = parentRefs.getParentInterface();
+        /* parentInterface = parentRefs.getParentInterface();
             if (parentInterface != null && !parentInterface.equals(ifName)) {
                 return;
             }
             if (parentRefs.getDatapathNodeIdentifier() == null) {
                 return;
             }
-        }
+            if(parentInterface == null){
+                LOG.error("parent interface not specified for {}",interfaceOld.getName());
+            }
+        }*/
 
         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
         RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld, ifName, parentRefs);
@@ -88,14 +90,15 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         String ifNameNew = interfaceNew.getName();
         String parentInterface = null;
 
-        ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
-        if (parentRefs != null) {
-            parentInterface = parentRefs.getParentInterface();
+        /*ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
+        if (parentRefs == null) {
+            LOG.error("parent refs not specified for {}",interfaceNew.getName());
         }
 
-        if (parentInterface != null && !parentInterface.equals(ifNameNew)) {
+        if (parentInterface == null) {
+            LOG.error("parent interface not specified for {}",interfaceOld.getName());
             return;
-        }
+        }*/
 
         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
         RendererConfigUpdateWorker worker = new RendererConfigUpdateWorker(key, interfaceOld, interfaceNew, ifNameNew);
@@ -109,13 +112,13 @@ public class InterfaceConfigListener extends AsyncDataTreeChangeListenerBase<Int
         String parentInterface = null;
 
         ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class);
-        if (parentRefs != null) {
-            parentInterface = parentRefs.getParentInterface();
+        if (parentRefs == null) {
+            LOG.error("parent refs not specified for {}",interfaceNew.getName());
         }
 
-        if (parentInterface != null && !parentInterface.equals(ifName)) {
-            return;
-        }
+        /*if(parentInterface == null){
+            LOG.error("parent interface not specified for {}",interfaceNew.getName());
+        }*/
 
         DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
         RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs, ifName);
index 2e41bfb7f4524aeb7131a60d2eb3e526c8ee814a..88d76ac7c279afd62d56fc988514f5d6ae4b7292 100644 (file)
@@ -54,7 +54,7 @@ public class VlanMemberConfigListener extends AsyncDataTreeChangeListenerBase<In
     @Override
     protected void remove(InstanceIdentifier<Interface> key, Interface interfaceOld) {
         IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class);
-        if (ifL2vlan == null) {
+        if (ifL2vlan == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlan.getL2vlanMode()) {
             return;
         }
 
@@ -78,7 +78,7 @@ public class VlanMemberConfigListener extends AsyncDataTreeChangeListenerBase<In
     @Override
     protected void update(InstanceIdentifier<Interface> key, Interface interfaceOld, Interface interfaceNew) {
         IfL2vlan ifL2vlanNew = interfaceNew.getAugmentation(IfL2vlan.class);
-        if (ifL2vlanNew == null) {
+        if (ifL2vlanNew == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlanNew.getL2vlanMode()) {
             return;
         }
 
@@ -105,7 +105,7 @@ public class VlanMemberConfigListener extends AsyncDataTreeChangeListenerBase<In
     @Override
     protected void add(InstanceIdentifier<Interface> key, Interface interfaceNew) {
         IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
-        if (ifL2vlan == null) {
+        if (ifL2vlan == null || IfL2vlan.L2vlanMode.TrunkMember != ifL2vlan.getL2vlanMode()) {
             return;
         }
 
index 11eed1c6dc3baf53525dcb06d48b964c39306a7d..c22ce3bb068654dc07b86b49690773a38e0e2598 100644 (file)
@@ -9,58 +9,39 @@ package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers;
 
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.ListenableFuture;
-
-import org.eclipse.xtend.lib.annotations.Data;
 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.commons.AlivenessMonitorUtils;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils;
-import org.opendaylight.vpnservice.interfacemgr.globals.InterfaceInfo;
 import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils;
-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.inet.types.rev100924.IpAddressBuilder;
 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.OperStatus;
-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.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.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.*;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.params.SourceBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.monitor.start.input.ConfigBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.*;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
 
 public class OvsInterfaceConfigAddHelper {
     private static final Logger LOG = LoggerFactory.getLogger(OvsInterfaceConfigAddHelper.class);
@@ -78,89 +59,50 @@ public class OvsInterfaceConfigAddHelper {
             return futures;
         }
 
-        addVlanConfiguration(interfaceNew, dataBroker, idManager, futures);
+        addVlanConfiguration(interfaceNew, parentRefs, dataBroker, idManager, futures);
         return futures;
     }
 
-    private static void addVlanConfiguration(Interface interfaceNew, DataBroker dataBroker, IdManagerService idManager,
+    private static void addVlanConfiguration(Interface interfaceNew, ParentRefs parentRefs, DataBroker dataBroker, IdManagerService idManager,
                                              List<ListenableFuture<Void>> futures) {
+        IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
+        if (ifL2vlan == null || IfL2vlan.L2vlanMode.Trunk != ifL2vlan.getL2vlanMode()) {
+            return;
+        }
         WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
+        InterfaceManagerCommonUtils.createInterfaceChildEntry(transaction,
+                parentRefs.getParentInterface(), interfaceNew.getName());
+
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
-                InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceNew.getName(), dataBroker);
+                InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(parentRefs.getParentInterface(), dataBroker);
 
         if (ifState == null) {
-            return;
-        }
-        updateStateEntry(interfaceNew, transaction, ifState);
-
-        NodeConnectorId nodeConnectorId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
-        BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
-        long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
-        Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, interfaceNew.getName());
-        IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
-        if (ifL2vlan == null) {
-            futures.add(transaction.submit());
-            return;
-        }
-        if(interfaceNew.isEnabled() && ifState.getOperStatus() == OperStatus.Up) {
-            List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, interfaceNew);
-            FlowBasedServicesUtils.installVlanFlow(dpId, portNo, interfaceNew, transaction, matches, ifIndex);
-        }
-        if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
             futures.add(transaction.submit());
             return;
         }
 
+        InterfaceManagerCommonUtils.addStateEntry(interfaceNew.getName(), transaction, dataBroker, idManager, ifState);
+
         InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
         InterfaceParentEntry interfaceParentEntry =
                 InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
-        if (interfaceParentEntry == null) {
+        if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
             futures.add(transaction.submit());
             return;
         }
 
-        List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
-        if (interfaceChildEntries == null) {
-            return;
-        }
-
-        OperStatus operStatus = ifState.getOperStatus();
-        PhysAddress physAddress = ifState.getPhysAddress();
-        AdminStatus adminStatus = ifState.getAdminStatus();
-
         //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
-        for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
-            InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface ifaceChild =
-                    InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker);
-
-            if (!ifaceChild.isEnabled()) {
-                operStatus = OperStatus.Down;
-            }
-
-            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
-                    IfmUtil.buildStateInterfaceId(ifaceChild.getName());
-            List<String> childLowerLayerIfList = new ArrayList<>();
-            childLowerLayerIfList.add(0, nodeConnectorId.getValue());
-            childLowerLayerIfList.add(1, interfaceNew.getName());
-            ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, ifaceChild.getName());
-            InterfaceBuilder childIfaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus)
-                    .setOperStatus(operStatus).setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList);
-            childIfaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifaceChild.getName()));
-            transaction.put(LogicalDatastoreType.OPERATIONAL, ifChildStateId, childIfaceBuilder.build(), true);
-            if (operStatus == OperStatus.Up) {
-                List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, ifaceChild);
-                FlowBasedServicesUtils.installVlanFlow(dpId, portNo, ifaceChild, transaction, matches, ifIndex);
-            }
+        for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+            InterfaceManagerCommonUtils.addStateEntry(interfaceChildEntry.getChildInterface(), transaction, dataBroker, idManager,ifState);
         }
         futures.add(transaction.submit());
     }
 
     private static void addTunnelConfiguration(DataBroker dataBroker, ParentRefs parentRefs,
-                                              Interface interfaceNew, IdManagerService idManager,
-                                              AlivenessMonitorService alivenessMonitorService,
-                                              IMdsalApiManager mdsalApiManager,
-                                              List<ListenableFuture<Void>> futures) {
+                                               Interface interfaceNew, IdManagerService idManager,
+                                               AlivenessMonitorService alivenessMonitorService,
+                                               IMdsalApiManager mdsalApiManager,
+                                               List<ListenableFuture<Void>> futures) {
         LOG.debug("adding tunnel configuration for {}", interfaceNew.getName());
         WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
         if (parentRefs == null) {
@@ -181,7 +123,7 @@ public class OvsInterfaceConfigAddHelper {
 
         LOG.debug("creating bridge interfaceEntry in ConfigDS {}", bridgeEntryKey);
         InterfaceMetaUtils.createBridgeInterfaceEntryInConfigDS(bridgeEntryKey, bridgeInterfaceEntryKey,
-                    interfaceNew.getName(), transaction);
+                interfaceNew.getName(), transaction);
         futures.add(transaction.submit());
 
         // create bridge on switch, if switch is connected
@@ -218,17 +160,4 @@ public class OvsInterfaceConfigAddHelper {
             }
         }
     }
-
-    private static void updateStateEntry(Interface interfaceNew, WriteTransaction transaction,
-                                         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState) {
-        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
-                IfmUtil.buildStateInterfaceId(interfaceNew.getName());
-        InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
-        if (!interfaceNew.isEnabled() && ifState.getOperStatus() != OperStatus.Down) {
-            ifaceBuilder.setOperStatus(OperStatus.Down);
-            ifaceBuilder.setType(interfaceNew.getType());
-            ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceNew.getName()));
-            transaction.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
-        }
-    }
 }
index 722db1aa8d526eb115dd7b9a68fdf8e04485fdd8..765aaea17085b5d08818a671538ae52754e1761c 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers;
 
 import com.google.common.util.concurrent.ListenableFuture;
-
 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;
@@ -70,75 +69,40 @@ public class OvsInterfaceConfigRemoveHelper {
             removeTunnelConfiguration(alivenessMonitorService, parentRefs, dataBroker, interfaceOld,
                     idManager, mdsalApiManager, futures);
         }else {
-            removeVlanConfiguration(dataBroker, interfaceOld, t);
+            removeVlanConfiguration(dataBroker, parentRefs, interfaceOld, t);
             futures.add(t.submit());
         }
         return futures;
     }
 
-    private static void removeVlanConfiguration(DataBroker dataBroker, Interface interfaceOld, WriteTransaction t) {
-        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
-                InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceOld.getName(), dataBroker);
-        if (ifState == null) {
-            return;
-        }
-
-        String ncStr = ifState.getLowerLayerIf().get(0);
-        NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
-        NodeConnector nodeConnector =
-                InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
-        if(nodeConnector != null) {
-            FlowCapableNodeConnector flowCapableNodeConnector =
-                    nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
-            //State state = flowCapableNodeConnector.getState();
-            OperStatus operStatus = flowCapableNodeConnector == null ? OperStatus.Down : OperStatus.Up;
-
-            if (ifState.getOperStatus() != operStatus) {
-                InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
-                        IfmUtil.buildStateInterfaceId(interfaceOld.getName());
-                InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
-                ifaceBuilder.setOperStatus(operStatus);
-                ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceOld.getName()));
-                t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
-            }
-        }
+    private static void removeVlanConfiguration(DataBroker dataBroker, ParentRefs parentRefs, Interface interfaceOld, WriteTransaction transaction) {
         IfL2vlan ifL2vlan = interfaceOld.getAugmentation(IfL2vlan.class);
-        if (ifL2vlan == null) {
+        if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
             return;
         }
-        BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
-        FlowBasedServicesUtils.removeIngressFlow(interfaceOld, dpId, t);
-        if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
+        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
+                InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceOld.getName(), dataBroker);
+        if (ifState == null) {
             return;
         }
 
+        InterfaceManagerCommonUtils.updateOperStatus(interfaceOld.getName(), OperStatus.Down, transaction);
+        NodeConnectorId ncId = new NodeConnectorId(ifState.getLowerLayerIf().get(0));
+        BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(ncId));
+        FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, transaction);
         // For Vlan-Trunk Interface, remove the trunk-member operstates as well...
-        InterfaceKey interfaceKey = new InterfaceKey(interfaceOld.getName());
-        org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
-                InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
-        if (iface == null) {
-            return;
-        }
 
-        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceOld.getName());
         InterfaceParentEntry interfaceParentEntry =
                 InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
-        if (interfaceParentEntry == null) {
-            return;
-        }
-
-        List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
-        if (interfaceChildEntries == null) {
+        if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
             return;
         }
 
         //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
-        for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
-            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
-                    IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
-            t.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
-            InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
-            FlowBasedServicesUtils.removeIngressFlow(InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker), dpId, t);
+        for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+            InterfaceManagerCommonUtils.deleteStateEntry(interfaceChildEntry.getChildInterface(), transaction);
+            FlowBasedServicesUtils.removeIngressFlow(interfaceChildEntry.getChildInterface(), dpId, transaction);
         }
     }
 
index 328c37c10e7457b33794515028a4c6518121ea54..73e3830947912cdd7ad0bc2d8a9dc8acf30d58cc 100644 (file)
@@ -70,67 +70,34 @@ public class OvsInterfaceConfigUpdateHelper{
 
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
         if (interfaceNew.isEnabled() != interfaceOld.isEnabled()) {
-            OperStatus operStatus;
-            if (!interfaceNew.isEnabled()) {
-                operStatus = OperStatus.Down;
-            } else {
-                String ncStr = ifState.getLowerLayerIf().get(0);
-                NodeConnectorId nodeConnectorId = new NodeConnectorId(ncStr);
-                NodeConnector nodeConnector =
-                        InterfaceManagerCommonUtils.getNodeConnectorFromInventoryOperDS(nodeConnectorId, dataBroker);
-                FlowCapableNodeConnector flowCapableNodeConnector =
-                        nodeConnector.getAugmentation(FlowCapableNodeConnector.class);
-                //State state = flowCapableNodeConnector.getState();
-                operStatus = flowCapableNodeConnector == null ? OperStatus.Down : OperStatus.Up;
-            }
-
-            String ifName = interfaceNew.getName();
-            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
-                    IfmUtil.buildStateInterfaceId(interfaceNew.getName());
-            InterfaceBuilder ifaceBuilder = new InterfaceBuilder();
-            ifaceBuilder.setOperStatus(operStatus);
-            ifaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifName));
-            t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build());
+            OperStatus operStatus = InterfaceManagerCommonUtils.updateStateEntry(interfaceNew, dataBroker, t, ifState);
 
-            IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
-            if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
-                futures.add(t.submit());
+            IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class);
+            if(ifTunnel != null){
                 // stop tunnel monitoring if admin state is disabled for a vxlan trunk interface
                 if(!interfaceNew.isEnabled()){
                     AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, interfaceNew);
+                    futures.add(t.submit());
+                    return futures;
                 }
-                return futures;
             }
 
-            InterfaceKey interfaceKey = new InterfaceKey(ifName);
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
-                    InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
-            if (iface == null) {
+            IfL2vlan ifL2vlan = interfaceNew.getAugmentation(IfL2vlan.class);
+            if (ifL2vlan == null || ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
                 futures.add(t.submit());
                 return futures;
             }
 
-            InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+            InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(interfaceNew.getName());
             InterfaceParentEntry interfaceParentEntry =
                     InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
-            if (interfaceParentEntry == null) {
-                futures.add(t.submit());
-                return futures;
-            }
-
-            List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
-            if (interfaceChildEntries == null) {
+            if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
                 futures.add(t.submit());
                 return futures;
             }
 
-            for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
-                InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
-                        IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
-                InterfaceBuilder ifaceBuilderChild = new InterfaceBuilder();
-                ifaceBuilderChild.setOperStatus(operStatus);
-                ifaceBuilderChild.setKey(IfmUtil.getStateInterfaceKeyFromName(interfaceChildEntry.getChildInterface()));
-                t.merge(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilderChild.build());
+            for (InterfaceChildEntry interfaceChildEntry : interfaceParentEntry.getInterfaceChildEntry()) {
+                InterfaceManagerCommonUtils.updateOperStatus(interfaceChildEntry.getChildInterface(), operStatus, t);
             }
         }
 
index 808fa7ec1944cb6d7b7c1e56103f0415fad5c6f2..92b60e6f6b9bbe161e2ff4b1e006b6da142a9285 100644 (file)
@@ -12,8 +12,6 @@ import com.google.common.util.concurrent.ListenableFuture;
 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.VpnUtil;
 import org.opendaylight.vpnservice.interfacemgr.IfmConstants;
 import org.opendaylight.vpnservice.interfacemgr.IfmUtil;
 import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils;
@@ -28,12 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.
 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.meta.rev151007._interface.child.info.InterfaceParentEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
 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;
@@ -52,9 +44,8 @@ public class OvsVlanMemberConfigAddHelper {
         List<ListenableFuture<Void>> futures = new ArrayList<>();
         WriteTransaction t = dataBroker.newWriteOnlyTransaction();
 
-        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(parentRefs.getParentInterface());
-        createInterfaceParentEntryIfNotPresent(dataBroker, t, interfaceParentEntryKey, parentRefs.getParentInterface());
-        createInterfaceChildEntry(dataBroker, idManager, t, interfaceParentEntryKey, interfaceNew.getName());
+        InterfaceManagerCommonUtils.createInterfaceParentEntryIfNotPresent(dataBroker, t, parentRefs.getParentInterface());
+        InterfaceManagerCommonUtils.createInterfaceChildEntry(t, parentRefs.getParentInterface(), interfaceNew.getName());
 
         InterfaceKey interfaceKey = new InterfaceKey(parentRefs.getParentInterface());
         Interface ifaceParent = InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
@@ -87,7 +78,7 @@ public class OvsVlanMemberConfigAddHelper {
                     IfmUtil.buildStateInterfaceId(interfaceNew.getName());
             List<String> lowerLayerIfList = new ArrayList<>();
             lowerLayerIfList.add(ifState.getLowerLayerIf().get(0));
-            lowerLayerIfList.add(parentRefs.getParentInterface());
+            //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);
@@ -137,35 +128,4 @@ public class OvsVlanMemberConfigAddHelper {
         futures.add(t.submit());
         return futures;
     }
-
-    private static void createInterfaceParentEntryIfNotPresent(DataBroker dataBroker, WriteTransaction t,
-                                                               InterfaceParentEntryKey interfaceParentEntryKey,
-                                                               String 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);
-        }
-    }
-
-    private static long createInterfaceChildEntry(DataBroker dataBroker, IdManagerService idManager, WriteTransaction t,
-                                                InterfaceParentEntryKey interfaceParentEntryKey, String childInterface){
-
-        long lportTag = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, childInterface);
-        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 lportTag;
-    }
 }
index 83c7c042b17a6ca76032d461c9fec05feba6bf64..af0645691c50b7d3bdcd951971d30aa0c84c10c6 100644 (file)
@@ -47,6 +47,10 @@ public class OvsVlanMemberConfigRemoveHelper {
         InterfaceParentEntry interfaceParentEntry =
                 InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryIid, dataBroker);
 
+        if(interfaceParentEntry == null){
+            return futures;
+        }
+
         List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
         if (interfaceChildEntries.size() <= 1) {
             t.delete(LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIid);
@@ -90,7 +94,7 @@ public class OvsVlanMemberConfigRemoveHelper {
             InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifStateId =
                     IfmUtil.buildStateInterfaceId(interfaceOld.getName());
             t.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
-            FlowBasedServicesUtils.removeIngressFlow(interfaceOld, dpId, t);
+            FlowBasedServicesUtils.removeIngressFlow(interfaceOld.getName(), dpId, t);
         }
 
         futures.add(t.submit());
index f43d40be54e9b370fc962fddcff2a13ba13c2cbd..7d90a44adb7fc1e3abb8d60ecccf411f883c576a 100644 (file)
@@ -10,34 +10,26 @@ package org.opendaylight.vpnservice.interfacemgr.renderer.ovs.statehelpers;
 import com.google.common.util.concurrent.ListenableFuture;
 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.VpnConstants;
 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.*;
+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.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface;
-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.flow.inventory.rev130819.FlowCapableNodeConnector;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor.rev150629.AlivenessMonitorService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
-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;
 
@@ -49,8 +41,8 @@ import java.util.List;
  * This worker is responsible for adding the openflow-interfaces/of-port-info container
  * in odl-interface-openflow yang.
  * Where applicable:
   * Create the entries in Interface-State OperDS.
   * Create the entries in Inventory OperDS.
+ * Create the entries in Interface-State OperDS.
+ * Create the entries in Inventory OperDS.
  */
 
 public class OvsInterfaceStateAddHelper {
@@ -73,128 +65,77 @@ public class OvsInterfaceStateAddHelper {
         */
         Interface.OperStatus operStatus = Interface.OperStatus.Up;
         Interface.AdminStatus adminStatus = Interface.AdminStatus.Up;
+
+        // Fetch the interface name corresponding to the port Name
         InterfaceKey interfaceKey = new InterfaceKey(portName);
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
                 InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
 
-        if (iface != null && !iface.isEnabled()) {
-            operStatus = Interface.OperStatus.Down;
-        }
-
-        List<String> lowerLayerIfList = new ArrayList<>();
-        lowerLayerIfList.add(nodeConnectorId.getValue());
-
-        Integer ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, portName);
-        InstanceIdentifier<Interface> ifStateId = IfmUtil.buildStateInterfaceId(portName);
-        InterfaceBuilder ifaceBuilder = new InterfaceBuilder().setOperStatus(operStatus)
-                .setAdminStatus(adminStatus).setPhysAddress(physAddress).setIfIndex(ifIndex).setLowerLayerIf(lowerLayerIfList)
-                .setKey(IfmUtil.getStateInterfaceKeyFromName(portName));
-        if(iface != null) {
-            ifaceBuilder.setType(iface.getType());
-        }
-        transaction.put(LogicalDatastoreType.OPERATIONAL, ifStateId, ifaceBuilder.build(), true);
-
-        // allocate lport tag and set in if-index
-        InterfaceMetaUtils.createLportTagInterfaceMap(transaction, portName, ifIndex);
-        if (iface == null) {
-            futures.add(transaction.submit());
-            return futures;
-        }
-
+        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
-        IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
-        if(tunnel != null){
-            InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel,dpId, portNo, iface,
-                    ifIndex, NwConstants.ADD_FLOW);
-            futures.add(transaction.submit());
-            AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
-            return futures;
+        if(iface != null) {
+            IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
+            if (tunnel != null) {
+                InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface,
+                        ifState.getIfIndex(), NwConstants.ADD_FLOW);
+                futures.add(transaction.submit());
+                AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+                return futures;
+            }
         }
 
-        // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members
-        // should also be created here.
-        IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
-        if (ifL2vlan == null) {
-            futures.add(transaction.submit());
-            return futures;
-        }
-        if(operStatus == Interface.OperStatus.Up) {
-            List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, iface);
-            FlowBasedServicesUtils.installVlanFlow(dpId, portNo, iface, transaction, matches, ifIndex);
-        }
-        if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
-            futures.add(transaction.submit());
-            return futures;
-        }
-        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+        // For all other interfaces except tunnel interfaces, interface name won't be same as port name.
+        // In that case fetch the interface corresponding to the portName, and update the state accordingly
+        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName);
         InterfaceParentEntry interfaceParentEntry =
                 InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
-        if (interfaceParentEntry == null) {
-            futures.add(transaction.submit());
-            return futures;
-        }
-
-        List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
-        if (interfaceChildEntries == null) {
+        if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
             futures.add(transaction.submit());
             return futures;
         }
 
         //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
         //List<Trunks> trunks = new ArrayList<>();
-        for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
-            InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
-            org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface ifaceChild =
-                    InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker);
 
-            // IfL2vlan ifL2vlanChild = iface.getAugmentation(IfL2vlan.class);
-            // trunks.add(new TrunksBuilder().setTrunk(ifL2vlanChild.getVlanId()).build());
+        String higherlayerChild = interfaceParentEntry.getInterfaceChildEntry().get(0).getChildInterface();
+        InterfaceManagerCommonUtils.addStateEntry(higherlayerChild, transaction, dataBroker, idManager,
+                ifState);
 
-            if (!ifaceChild.isEnabled()) {
-                operStatus = Interface.OperStatus.Down;
-            }
-            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
-                    IfmUtil.buildStateInterfaceId(ifaceChild.getName());
-            List<String> childLowerLayerIfList = new ArrayList<>();
-            childLowerLayerIfList.add(0, nodeConnectorId.getValue());
-            childLowerLayerIfList.add(1, iface.getName());
-            ifIndex = IfmUtil.allocateId(idManager, IfmConstants.IFM_IDPOOL_NAME, ifaceChild.getName());
-            InterfaceBuilder childIfaceBuilder = new InterfaceBuilder().setAdminStatus(adminStatus).setOperStatus(operStatus)
-                    .setPhysAddress(physAddress).setLowerLayerIf(childLowerLayerIfList).setIfIndex(ifIndex);
-            childIfaceBuilder.setKey(IfmUtil.getStateInterfaceKeyFromName(ifaceChild.getName())).setType(ifaceChild.getType());
-            transaction.put(LogicalDatastoreType.OPERATIONAL, ifChildStateId, childIfaceBuilder.build(), true);
-
-            // create lportTag Interface Map
-            InterfaceMetaUtils.createLportTagInterfaceMap(transaction, ifaceChild.getName(), ifIndex);
-            if (operStatus == Interface.OperStatus.Up) {
-                List<MatchInfo> matches = FlowBasedServicesUtils.getMatchInfoForVlanPortAtIngressTable(dpId, portNo, ifaceChild);
-                FlowBasedServicesUtils.installVlanFlow(dpId, portNo, ifaceChild, transaction, matches, ifIndex);
+        // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members
+        // should also be created here.
+        InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild);
+        InterfaceParentEntry higherLayerParent =
+                InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker);
+        if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) {
+            for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()){
+                InterfaceManagerCommonUtils.addStateEntry(interfaceChildEntry.getChildInterface(), transaction, dataBroker, idManager,
+                        ifState);
             }
         }
-
         /** Below code will be needed if we want to update the vlan-trunks on the of-port
-        if (trunks.isEmpty()) {
-            futures.add(t.submit());
-            return futures;
-        }
-
-        BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
-
-        BridgeRefEntryKey BridgeRefEntryKey = new BridgeRefEntryKey(dpId);
-        InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid =
-                InterfaceMetaUtils.getBridgeRefEntryIdentifier(BridgeRefEntryKey);
-        BridgeRefEntry bridgeRefEntry =
-                InterfaceMetaUtils.getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
-        if (bridgeRefEntry == null) {
-            futures.add(t.submit());
-            return futures;
-        }
-
-        InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
-                (InstanceIdentifier<OvsdbBridgeAugmentation>)bridgeRefEntry.getBridgeReference().getValue();
-        VlanTrunkSouthboundUtils.addTerminationPointWithTrunks(bridgeIid, trunks, iface.getName(), t);
+         if (trunks.isEmpty()) {
+         futures.add(t.submit());
+         return futures;
+         }
+
+         BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
+
+         BridgeRefEntryKey BridgeRefEntryKey = new BridgeRefEntryKey(dpId);
+         InstanceIdentifier<BridgeRefEntry> dpnBridgeEntryIid =
+         InterfaceMetaUtils.getBridgeRefEntryIdentifier(BridgeRefEntryKey);
+         BridgeRefEntry bridgeRefEntry =
+         InterfaceMetaUtils.getBridgeRefEntryFromOperDS(dpnBridgeEntryIid, dataBroker);
+         if (bridgeRefEntry == null) {
+         futures.add(t.submit());
+         return futures;
+         }
+
+         InstanceIdentifier<OvsdbBridgeAugmentation> bridgeIid =
+         (InstanceIdentifier<OvsdbBridgeAugmentation>)bridgeRefEntry.getBridgeReference().getValue();
+         VlanTrunkSouthboundUtils.addTerminationPointWithTrunks(bridgeIid, trunks, iface.getName(), t);
          */
 
         futures.add(transaction.submit());
index d742a35458d0bcdf1b5db4f40151605064802a84..65cc3e3e0dd771cbba7d96c73ca337c9853279df 100644 (file)
@@ -65,67 +65,66 @@ public class OvsInterfaceStateRemoveHelper {
 
         transaction.delete(LogicalDatastoreType.OPERATIONAL, ifStateId);
 
-        // For Vlan-Trunk Interface, remove the trunk-member operstates as well...
         InterfaceKey interfaceKey = new InterfaceKey(portName);
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface iface =
                 InterfaceManagerCommonUtils.getInterfaceFromConfigDS(interfaceKey, dataBroker);
-        if (iface == null) {
-            futures.add(transaction.submit());
-            return futures;
-        }
 
         NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
         BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
         // If this interface is a tunnel interface, remove the tunnel ingress flow and stop lldp monitoring
-        IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
-        if(tunnel != null){
-            long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
-            InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface, -1,
-                    NwConstants.DEL_FLOW);
-            futures.add(transaction.submit());
-            AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
-            return futures;
-        }
-
-        IfL2vlan ifL2vlan = iface.getAugmentation(IfL2vlan.class);
-        if (ifL2vlan == null) {
-            futures.add(transaction.submit());
-            return futures;
-        }
-        FlowBasedServicesUtils.removeIngressFlow(iface, dpId, transaction);
-        if (ifL2vlan.getL2vlanMode() != IfL2vlan.L2vlanMode.Trunk) {
-            futures.add(transaction.submit());
-            return futures;
+        if(iface != null) {
+            IfTunnel tunnel = iface.getAugmentation(IfTunnel.class);
+            if (tunnel != null) {
+                long portNo = Long.valueOf(IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId));
+                InterfaceManagerCommonUtils.makeTunnelIngressFlow(futures, mdsalApiManager, tunnel, dpId, portNo, iface, -1,
+                        NwConstants.DEL_FLOW);
+                futures.add(transaction.submit());
+                AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+                return futures;
+            }
         }
 
-        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(iface.getName());
+        InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName);
         InterfaceParentEntry interfaceParentEntry =
                 InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
-        if (interfaceParentEntry == null) {
-            futures.add(transaction.submit());
-            return futures;
-        }
-
-        List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
-        if (interfaceChildEntries == null) {
+        if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
             futures.add(transaction.submit());
             return futures;
         }
 
         //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
-        for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
-            InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
-                    IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
-            /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
-            Interface childInterfaceState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceChildEntry.getChildInterface(), dataBroker);
-            if(interfaceState != null) {
-                InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, childInterfaceState.getName(), childInterfaceState.getIfIndex());
-                transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
-                InterfaceKey childIfKey = new InterfaceKey(interfaceChildEntry.getChildInterface());
-                FlowBasedServicesUtils.removeIngressFlow(InterfaceManagerCommonUtils.getInterfaceFromConfigDS(childIfKey, dataBroker), dpId, transaction);
+        InterfaceChildEntry higherlayerChild = interfaceParentEntry.getInterfaceChildEntry().get(0);
+        InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface>
+                higerLayerChildIfStateId = IfmUtil.buildStateInterfaceId(higherlayerChild.getChildInterface());
+                /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
+        Interface higherLayerIfChildState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(higherlayerChild.getChildInterface(), dataBroker);
+        if (interfaceState != null) {
+            InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, higherLayerIfChildState.getName(),
+                    higherLayerIfChildState.getIfIndex());
+            transaction.delete(LogicalDatastoreType.OPERATIONAL, higerLayerChildIfStateId);
+            FlowBasedServicesUtils.removeIngressFlow(higherLayerIfChildState.getName(), dpId, transaction);
+        }
+        // If this interface maps to a Vlan trunk entity, operational states of all the vlan-trunk-members
+        // should also be created here.
+        InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild.getChildInterface());
+        InterfaceParentEntry higherLayerParent =
+                InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker);
+
+        if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) {
+            for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()) {
+                InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> ifChildStateId =
+                        IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
+                /* Remove entry from if-index-interface-name map and deallocate Id from Idmanager. */
+                Interface childInterfaceState = InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceChildEntry.getChildInterface(), dataBroker);
+                if (interfaceState != null) {
+                    InterfaceMetaUtils.removeLportTagInterfaceMap(transaction, idManager, dataBroker, childInterfaceState.getName(), childInterfaceState.getIfIndex());
+                    transaction.delete(LogicalDatastoreType.OPERATIONAL, ifChildStateId);
+                    FlowBasedServicesUtils.removeIngressFlow(childInterfaceState.getName(), dpId, transaction);
+                }
             }
         }
 
+
        /* Below code will be needed if we want to update the vlan-trunk in the of-port.
        NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(key.firstIdentifierOf(NodeConnector.class)).getId();
         BigInteger dpId = new BigInteger(IfmUtil.getDpnFromNodeConnectorId(nodeConnectorId));
index 9b99aee56065aaa9aa7ad88c69bcb4cb59b0a172..d3acbc741b08b14444f05a505ed5036f0fc55c17 100644 (file)
@@ -25,6 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -116,28 +117,34 @@ public class OvsInterfaceStateUpdateHelper {
             InterfaceParentEntryKey interfaceParentEntryKey = new InterfaceParentEntryKey(portName);
             InterfaceParentEntry interfaceParentEntry =
                     InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(interfaceParentEntryKey, dataBroker);
-            if (interfaceParentEntry == null) {
+            if (interfaceParentEntry == null || interfaceParentEntry.getInterfaceChildEntry() == null) {
                 futures.add(t.submit());
                 // start/stop monitoring based on opState
-                if(operStatusNew == Interface.OperStatus.Down )
-                    AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
-                else
-                    AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService,dataBroker, iface);
+                IfTunnel ifTunnel = iface.getAugmentation(IfTunnel.class);
+                if(ifTunnel != null) {
+                    if (operStatusNew == Interface.OperStatus.Down)
+                        AlivenessMonitorUtils.stopLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+                    else
+                        AlivenessMonitorUtils.startLLDPMonitoring(alivenessMonitorService, dataBroker, iface);
+                }
                 return futures;
             }
-
-            List<InterfaceChildEntry> interfaceChildEntries = interfaceParentEntry.getInterfaceChildEntry();
-            if (interfaceChildEntries == null) {
-                futures.add(t.submit());
-                return futures;
-            }
-
-            LOG.debug("Updating if-state entries for Vlan-Trunk Members for port: {}", portName);
-            //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
-            for (InterfaceChildEntry interfaceChildEntry : interfaceChildEntries) {
-                InstanceIdentifier<Interface> ifChildStateId =
-                        IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
-                t.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilder.build());
+            for(InterfaceChildEntry higherlayerChild : interfaceParentEntry.getInterfaceChildEntry()) {
+                InstanceIdentifier<Interface> higherLayerIfChildStateId =
+                        IfmUtil.buildStateInterfaceId(higherlayerChild.getChildInterface());
+                t.merge(LogicalDatastoreType.OPERATIONAL, higherLayerIfChildStateId, ifaceBuilder.build());
+                InterfaceParentEntryKey higherLayerParentEntryKey = new InterfaceParentEntryKey(higherlayerChild.getChildInterface());
+                InterfaceParentEntry higherLayerParent =
+                        InterfaceMetaUtils.getInterfaceParentEntryFromConfigDS(higherLayerParentEntryKey, dataBroker);
+                if(higherLayerParent != null && higherLayerParent.getInterfaceChildEntry() != null) {
+                    for (InterfaceChildEntry interfaceChildEntry : higherLayerParent.getInterfaceChildEntry()) {
+                        LOG.debug("Updating if-state entries for Vlan-Trunk Members for port: {}", portName);
+                        //FIXME: If the no. of child entries exceeds 100, perform txn updates in batches of 100.
+                        InstanceIdentifier<Interface> ifChildStateId =
+                                IfmUtil.buildStateInterfaceId(interfaceChildEntry.getChildInterface());
+                        t.merge(LogicalDatastoreType.OPERATIONAL, ifChildStateId, ifaceBuilder.build());
+                    }
+                }
             }
         }
 
index daa613aac4ddaa81d10686fa650b5052ba1a9a52..c29c7ac4607a396c95f5c9e81d35231a2dfe82ae 100644 (file)
@@ -349,28 +349,29 @@ public class InterfaceManagerRpcService implements OdlInterfaceRpcService {
         List<ActionInfo> listActionInfo = new ArrayList<ActionInfo>();
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface ifState =
                 InterfaceManagerCommonUtils.getInterfaceStateFromOperDS(interfaceName, dataBroker);
-
-        String lowerLayerIf = ifState.getLowerLayerIf().get(0);
-        NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
-        String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
-        Class<? extends InterfaceType> ifType = interfaceInfo.getType();
-        if(L2vlan.class.equals(ifType)){
-            IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
-            LOG.trace("L2Vlan: {}",vlanIface);
-            long vlanVid = 0;
-            boolean isVlanTransparent = false;
-            if (vlanIface != null) {
-                vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
-                isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
-            }
-            if (vlanVid != 0 && !isVlanTransparent) {
-                listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[] {}));
-                listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
-                        new String[] { Long.toString(vlanVid) }));
+        if(ifState != null) {
+            String lowerLayerIf = ifState.getLowerLayerIf().get(0);
+            NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
+            String portNo = IfmUtil.getPortNoFromNodeConnectorId(nodeConnectorId);
+            Class<? extends InterfaceType> ifType = interfaceInfo.getType();
+            if (L2vlan.class.equals(ifType)) {
+                IfL2vlan vlanIface = interfaceInfo.getAugmentation(IfL2vlan.class);
+                LOG.trace("L2Vlan: {}", vlanIface);
+                long vlanVid = 0;
+                boolean isVlanTransparent = false;
+                if (vlanIface != null) {
+                    vlanVid = vlanIface.getVlanId() == null ? 0 : vlanIface.getVlanId().getValue();
+                    isVlanTransparent = vlanIface.getL2vlanMode() == IfL2vlan.L2vlanMode.Transparent;
+                }
+                if (vlanVid != 0 && !isVlanTransparent) {
+                    listActionInfo.add(new ActionInfo(ActionType.push_vlan, new String[]{}));
+                    listActionInfo.add(new ActionInfo(ActionType.set_field_vlan_vid,
+                            new String[]{Long.toString(vlanVid)}));
+                }
+                listActionInfo.add(new ActionInfo(ActionType.output, new String[]{portNo}));
+            } else if (Tunnel.class.equals(ifType)) {
+                listActionInfo.add(new ActionInfo(ActionType.output, new String[]{portNo}));
             }
-            listActionInfo.add(new ActionInfo(ActionType.output, new String[] {portNo}));
-        }else if(Tunnel.class.equals(ifType)){
-            listActionInfo.add(new ActionInfo(ActionType.output, new String[] { portNo}));
         }
         return listActionInfo;
     }
index 517240f065d61b3be715ae071b65f72e9c7424ce..36730e4c2eb75085138a6aa445eac2130e53a4c3 100644 (file)
@@ -353,9 +353,9 @@ public class FlowBasedServicesUtils {
         return String.format("%d:%s:%s", tableId, dpnId, infName);
     }
 
-    public static void removeIngressFlow(Interface iface, BigInteger dpId, WriteTransaction t) {
+    public static void removeIngressFlow(String interfaceName, BigInteger dpId, WriteTransaction t) {
         LOG.debug("Removing Ingress Flows");
-        String flowKeyStr = getFlowRef(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, dpId, iface.getName());
+        String flowKeyStr = getFlowRef(IfmConstants.VLAN_INTERFACE_INGRESS_TABLE, dpId, interfaceName);
         FlowKey flowKey = new FlowKey(new FlowId(flowKeyStr));
         Node nodeDpn = buildInventoryDpnNode(dpId);
         InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
index 0da5c10dce4bd19393ccaefd97c405ddc951e98d..47827d8f89919a030b6155a540d0cb64a874ba39 100644 (file)
@@ -146,11 +146,11 @@ public class InterfaceManagerTestUtil {
                                            BigInteger dpn) {
         InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(ifName)).setName(ifName)
                 .setDescription(desc).setEnabled(enabled).setType((Class<? extends InterfaceType>) ifType);
-        ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).build();
+        ParentRefs parentRefs = new ParentRefsBuilder().setDatapathNodeIdentifier(dpn).setParentInterface(ifName).build();
         builder.addAugmentation(ParentRefs.class, parentRefs);
         if(ifType.equals(L2vlan.class)){
             IfL2vlan l2vlan = new IfL2vlanBuilder().setVlanId(VlanId.getDefaultInstance("0"))
-                    .setL2vlanMode(IfL2vlan.L2vlanMode.Access).build();
+                    .setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
             builder.addAugmentation(IfL2vlan.class, l2vlan);
         }else if(ifType.equals(IfTunnel.class)){
             IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(null).setTunnelGateway(null).setTunnelSource(null)
index 168188648eb08d924b2e10523a43f17eb9b867bb..894713a69b35d7d47aaf195dc8fb78d711a0bf24 100644 (file)
@@ -73,6 +73,7 @@ public class StateInterfaceTest {
     InterfaceParentEntryKey interfaceParentEntryKey = null;
     IfIndexInterface IfindexInterface = null;
     InstanceIdentifier<Interface> interfaceInstanceIdentifier = null;
+    InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryInstanceIdentifier = null;
     InstanceIdentifier<FlowCapableNodeConnector> fcNodeConnectorId = null;
     InstanceIdentifier<IfIndexInterface> ifIndexId =null;
     InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> interfaceStateIdentifier = null;
@@ -144,6 +145,8 @@ public class StateInterfaceTest {
 
         doReturn(Futures.immediateCheckedFuture(expectedInterface)).when(mockReadTx).read(
                 LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
+        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+                LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
         AllocateIdInput getIdInput = new AllocateIdInputBuilder()
                 .setPoolName(IfmConstants.IFM_IDPOOL_NAME)
                 .setIdKey(InterfaceManagerTestUtil.interfaceName).build();
@@ -167,6 +170,8 @@ public class StateInterfaceTest {
                 LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
         doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
                 LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
+        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+                LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
 
         ReleaseIdInput getIdInput = new ReleaseIdInputBuilder()
                 .setPoolName(IfmConstants.IFM_IDPOOL_NAME)
index 8030fff7166ff944b9c2dc02bedbfbe6399c2336..b3ce8e90b52d49ff471d2c87ae62e123935e4459 100644 (file)
@@ -32,6 +32,7 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataCh
 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.InterfaceMetaUtils;
 import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigAddHelper;
 import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.confighelpers.OvsInterfaceConfigRemoveHelper;
 import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
@@ -44,6 +45,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.alivenessmonitor
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.AllocateIdOutputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -70,6 +77,9 @@ public class VlanInterfaceConfigurationTest {
     Interface vlanInterfaceDisabled;
     InstanceIdentifier<Interface> interfaceInstanceIdentifier;
     InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier;
+    InstanceIdentifier<InterfaceParentEntry> interfaceParentEntryIdentifier = null;
+    InterfaceChildEntry interfaceChildEntry = null;
+    InstanceIdentifier<InterfaceChildEntry> interfaceChildEntryInstanceIdentifier;
     InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> interfaceStateIdentifier;
     org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface stateInterface;
 
@@ -101,7 +111,12 @@ public class VlanInterfaceConfigurationTest {
         RpcResultBuilder<AllocateIdOutput> allocateIdRpcBuilder = RpcResultBuilder.success();
         allocateIdRpcBuilder.withResult(output);
         ListenableFuture<RpcResult<AllocateIdOutput>> future = Futures.immediateFuture(allocateIdRpcBuilder.build());
-
+        interfaceParentEntryIdentifier = InterfaceMetaUtils.getInterfaceParentEntryIdentifier(
+                new InterfaceParentEntryKey(InterfaceManagerTestUtil.interfaceName));
+        interfaceChildEntryInstanceIdentifier = InterfaceMetaUtils.getInterfaceChildEntryIdentifier(new InterfaceParentEntryKey("s1-eth1"),
+                new InterfaceChildEntryKey(vlanInterfaceEnabled.getName()));
+        interfaceChildEntry = new InterfaceChildEntryBuilder().setKey(new InterfaceChildEntryKey(vlanInterfaceEnabled.getName())).
+                setChildInterface(vlanInterfaceEnabled.getName()).build();
         // Setup mocks
         when(dataBroker.newReadOnlyTransaction()).thenReturn(mockReadTx);
         when(dataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTx);
@@ -118,8 +133,10 @@ public class VlanInterfaceConfigurationTest {
                         LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
         doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
                LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+                LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
 
-        addHelper.addConfiguration(dataBroker, null, vlanInterfaceEnabled, idManager,
+        addHelper.addConfiguration(dataBroker, vlanInterfaceEnabled.getAugmentation(ParentRefs.class), vlanInterfaceEnabled, idManager,
                 alivenessMonitorService, mdsalApiManager);
 
         //Nothing to verify, since when switch is not connected we don't do any datastore operation
@@ -129,14 +146,17 @@ public class VlanInterfaceConfigurationTest {
     @Test
     public void testAddVlanInterfaceWhenSwitchIsConnected() {
         Optional<Interface> expectedInterface = Optional.of(vlanInterfaceEnabled);
-        Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface> expectedStateInterface = Optional.of(stateInterface);
+        Optional<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface>
+                expectedStateInterface = Optional.of(stateInterface);
 
         doReturn(Futures.immediateCheckedFuture(expectedInterface)).when(mockReadTx).read(
                 LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
         doReturn(Futures.immediateCheckedFuture(expectedStateInterface)).when(mockReadTx).read(
                 LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+                LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
 
-        addHelper.addConfiguration(dataBroker, null, vlanInterfaceEnabled, idManager,
+        addHelper.addConfiguration(dataBroker, vlanInterfaceEnabled.getAugmentation(ParentRefs.class), vlanInterfaceEnabled, idManager,
                 alivenessMonitorService, mdsalApiManager);
 
         //Nothing to verify, since when adminstate is enabled and switch opstate is already up,
@@ -153,6 +173,8 @@ public class VlanInterfaceConfigurationTest {
                 LogicalDatastoreType.CONFIGURATION, interfaceInstanceIdentifier);
         doReturn(Futures.immediateCheckedFuture(expectedStateInterface)).when(mockReadTx).read(
                 LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+                LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
 
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
         ifaceBuilder.setOperStatus(OperStatus.Down);
@@ -160,11 +182,11 @@ public class VlanInterfaceConfigurationTest {
         ifaceBuilder.setType(L2vlan.class);
         stateInterface = ifaceBuilder.build();
 
-        addHelper.addConfiguration(dataBroker, null, vlanInterfaceDisabled, idManager,
+        addHelper.addConfiguration(dataBroker, vlanInterfaceDisabled.getAugmentation(ParentRefs.class), vlanInterfaceDisabled, idManager,
                 alivenessMonitorService, mdsalApiManager);
 
         //verification
-        verify(mockWriteTx).merge(LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier, stateInterface);
+        verify(mockWriteTx).put(LogicalDatastoreType.CONFIGURATION, interfaceChildEntryInstanceIdentifier, interfaceChildEntry, true);
     }
 
     @Test
@@ -178,6 +200,8 @@ public class VlanInterfaceConfigurationTest {
                         LogicalDatastoreType.OPERATIONAL, nodeConnectorInstanceIdentifier);
         doReturn(Futures.immediateCheckedFuture(expectedStateIf)).when(mockReadTx).read(
                         LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier);
+        doReturn(Futures.immediateCheckedFuture(Optional.absent())).when(mockReadTx).read(
+                LogicalDatastoreType.CONFIGURATION, interfaceParentEntryIdentifier);
 
         org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder ifaceBuilder = new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder();
         ifaceBuilder.setOperStatus(OperStatus.Down);
@@ -185,7 +209,7 @@ public class VlanInterfaceConfigurationTest {
         stateInterface = ifaceBuilder.build();
 
         removeHelper.removeConfiguration(dataBroker,alivenessMonitorService, vlanInterfaceEnabled, idManager,
-                mdsalApiManager, null);
+                mdsalApiManager, vlanInterfaceEnabled.getAugmentation(ParentRefs.class));
 
         //verification
         verify(mockWriteTx).merge(LogicalDatastoreType.OPERATIONAL, interfaceStateIdentifier, stateInterface);