Rework provider interface to allow different providers
authorSam Hague <shague@redhat.com>
Sun, 8 Nov 2015 15:14:29 +0000 (10:14 -0500)
committerSam Hague <shague@redhat.com>
Sun, 8 Nov 2015 15:14:29 +0000 (10:14 -0500)
Change-Id: Iaa36bc040e82005c3a8d419e23ad9ac8696c1215
Signed-off-by: Sam Hague <shague@redhat.com>
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/AbstractDataTreeListener.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/INetvirtSfcOF13Provider.java [moved from openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/openflow13/INetvirtSfcOF13Provider.java with 93% similarity]
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcAclListener.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcClassifierListener.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcProvider.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NshUtils.java [moved from openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/openflow13/NshUtils.java with 98% similarity]
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/openflow13/NetvirtSfcOF13Provider.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/openflow13/SfcClassifier.java
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcIT.java

index dfbe6f0eb790506b9b3e487ca20dc4ae31dba555..87a9db615cdd7ffb3e9cd672e73ed574ce7f414d 100644 (file)
@@ -14,7 +14,6 @@ import com.google.common.base.Preconditions;
 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13;
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
 
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.Bridges;
@@ -37,4 +37,7 @@ public interface INetvirtSfcOF13Provider {
      * @param acl - Access list includes rules that need to be installed in a SFF.
      */
     void removeClassifierRules(Sff sff, Acl acl);
+
+    void addClassifierRules(Acl acl);
+    void removeClassifierRules(Acl acl);
 }
index 139add1676b2e62d3d7496464a41816f50691aaf..74776698cb219d469a354acd76910172fd8556a4 100644 (file)
@@ -12,18 +12,9 @@ import com.google.common.base.Preconditions;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclKey;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.AccessListEntries;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.Ace;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.AceKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.bridges.Bridge;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -35,7 +26,6 @@ import org.slf4j.LoggerFactory;
 public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
     private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcAclListener.class);
     private ListenerRegistration<NetvirtSfcAclListener> listenerRegistration;
-    private MdsalUtils dbutils;
 
     /**
      * {@link NetvirtSfcAclListener} constructor.
@@ -46,7 +36,6 @@ public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
         super(provider, Acl.class);
         Preconditions.checkNotNull(db, "DataBroker can not be null!");
 
-        dbutils = new MdsalUtils(db);
         registrationListener(db);
     }
 
@@ -54,12 +43,11 @@ public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
         final DataTreeIdentifier<Acl> treeId =
                 new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getIetfAclIid());
         try {
-            LOG.info("Registering Data Change Listener for NetvirtSfc AccesList configuration.");
+            LOG.info("Registering Data Change Listener for NetvirtSfc AccessList configuration.");
             listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
         } catch (final Exception e) {
             LOG.warn("Netvirt AccesList DataChange listener registration fail!");
-            LOG.debug("Netvirt AccesList DataChange listener registration fail!", e);
-            throw new IllegalStateException("NetvirtSfcAccesListListener startup fail! System needs restart.", e);
+            throw new IllegalStateException("NetvirtSfcAccessListListener startup fail! System needs restart.", e);
         }
     }
 
@@ -80,20 +68,7 @@ public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
     public void remove(final InstanceIdentifier<Acl> identifier,
                        final Acl removeDataObj) {
         Preconditions.checkNotNull(removeDataObj, "Removed object can not be null!");
-        String aclName = removeDataObj.getAclName();
-
-        Classifiers classifiers = dbutils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
-        if (classifiers != null) {
-            for (Classifier classifier : classifiers.getClassifier()) {
-                if (classifier.getAcl().equalsIgnoreCase(aclName)) {
-                    if (classifier.getSffs() != null) {
-                        for (Sff sff : classifier.getSffs().getSff()) {
-                            provider.removeClassifierRules(sff, removeDataObj);
-                        }
-                    }
-                }
-            }
-        }
+        provider.removeClassifierRules(removeDataObj);
     }
 
     @Override
@@ -105,43 +80,11 @@ public class NetvirtSfcAclListener extends AbstractDataTreeListener<Acl> {
     public void add(final InstanceIdentifier<Acl> identifier,
                     final Acl addDataObj) {
         Preconditions.checkNotNull(addDataObj, "Added object can not be null!");
-        String aclName = addDataObj.getAclName();
         LOG.debug("Adding accesslist iid = {}, dataObj = {}", identifier, addDataObj);
-        Classifiers classifiers = dbutils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
-        if (classifiers == null) {
-            LOG.debug("add: No Classifiers found");
-            return;
-        }
-
-        LOG.debug("add: Classifiers: {}", classifiers);
-        for (Classifier classifier : classifiers.getClassifier()) {
-            if (classifier.getAcl().equals(aclName)) {
-                if (classifier.getBridges() != null) {
-                    for (Bridge bridge : classifier.getBridges().getBridge()) {
-                        provider.addClassifierRules(bridge, addDataObj);
-                    }
-                }
-            }
-        }
-    }
-
-    private InstanceIdentifier<Classifiers> getClassifierIid() {
-        return InstanceIdentifier.create(Classifiers.class);
+        provider.addClassifierRules(addDataObj);
     }
 
     public InstanceIdentifier<Acl> getIetfAclIid() {
         return InstanceIdentifier.create(AccessLists.class).child(Acl.class);
     }
-
-    /**
-     * Create an {@link Ace} {@link InstanceIdentifier}.
-     * @param aclName is the name of the ACL
-     * @param ruleName is the name of the rule
-     * @return the {@link Ace} {@link InstanceIdentifier}
-     */
-    public InstanceIdentifier<Ace> getIetfAclEntryIid(String aclName, String ruleName) {
-        return InstanceIdentifier.create(AccessLists.class).child(Acl.class,
-                new AclKey(aclName)).child(AccessListEntries.class).child(Ace.class,
-                new AceKey(ruleName));
-    }
 }
index 34fc5a380045d05de11141e7d76df976d94f3d51..1562a41f0fd461505fc4366bd949982255c93c50 100644 (file)
@@ -12,14 +12,12 @@ import com.google.common.base.Preconditions;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.AccessLists;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.Acl;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.bridges.Bridge;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -33,7 +31,7 @@ import org.slf4j.LoggerFactory;
  */
 public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Classifier> {
     private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcClassifierListener.class);
-    private MdsalUtils dbutils;
+    private MdsalUtils mdsalUtils;
     private ListenerRegistration<NetvirtSfcClassifierListener> listenerRegistration;
 
     /**
@@ -44,7 +42,7 @@ public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Class
     public NetvirtSfcClassifierListener(final INetvirtSfcOF13Provider provider, final DataBroker db) {
         super(provider, Classifier.class);
         Preconditions.checkNotNull(db, "DataBroker can not be null!");
-        dbutils = new MdsalUtils(db);
+        mdsalUtils = new MdsalUtils(db);
         registrationListener(db);
     }
 
@@ -56,7 +54,6 @@ public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Class
             listenerRegistration = db.registerDataTreeChangeListener(treeId, this);
         } catch (final Exception e) {
             LOG.warn("Netvirt Classifier DataChange listener registration fail!");
-            LOG.debug("Netvirt Classifier DataChange listener registration fail!", e);
             throw new IllegalStateException("NetvirtSfcClassifierListener startup fail! System needs restart.", e);
         }
     }
@@ -68,7 +65,6 @@ public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Class
                 listenerRegistration.close();
             } catch (final Exception e) {
                 LOG.warn("Error to stop Netvirt Classifier DataChange listener: {}", e.getMessage());
-                LOG.debug("Error to stop Netvirt Classifier DataChange listener..", e);
             }
             listenerRegistration = null;
         }
@@ -80,20 +76,13 @@ public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Class
         Preconditions.checkNotNull(removeDataObj, "Added object can not be null!");
         String aclName = removeDataObj.getAcl();
         // Read the ACL information from data store and make sure it exists.
-        Acl acl = dbutils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
+        Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
         if (acl == null) {
             LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
             return;
         }
 
-        if (removeDataObj.getSffs() != null) {
-            for (Sff sff : removeDataObj.getSffs().getSff()) {
-                // Netvirt classifier binds an ACL with service function forwarder that is identified by SFF name.
-                // SFF validation can be done with SFC Provider APIs, as SFF is configured within SFC project.  
-                // Netvirt SFC provider will validate the SFF using SFC provider APIs.
-                provider.removeClassifierRules(sff, acl);
-            }
-        }
+        provider.removeClassifierRules(acl);
     }
 
     @Override
@@ -110,17 +99,13 @@ public class NetvirtSfcClassifierListener extends AbstractDataTreeListener<Class
         String aclName = addDataObj.getAcl();
         LOG.debug("Adding classifier iid = {}, dataObj = {}", identifier, addDataObj);
         // Read the ACL information from data store and make sure it exists.
-        Acl acl = dbutils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
+        Acl acl = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getIetfAclIid(aclName));
         if (acl == null) {
             LOG.debug("IETF ACL with name ={} is not yet configured. skip this operation", aclName);
             return;
         }
 
-        //if (addDataObj.getBridges() != null) {
-        //    for (Bridge bridge : addDataObj.getBridges().getBridge()) {
-                provider.addClassifierRules(addDataObj.getBridges(), acl);
-        //    }
-        //}
+        provider.addClassifierRules(acl);
     }
 
     public InstanceIdentifier<Classifier> getClassifierIid() {
index b967b759aaab1906912be4df60cf904dd37d5a42..deddd8779a6904b3f414fd55ce40b24b9caf587f 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.OF13Provider;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.INetvirtSfcOF13Provider;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.NetvirtSfcOF13Provider;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.services.SfcClassifierService;
 import org.osgi.framework.BundleContext;
@@ -47,6 +46,7 @@ public class NetvirtSfcProvider implements BindingAwareProvider, AutoCloseable {
         LOG.info("NetvirtSfcProvider Session Initiated");
         DataBroker dataBroker = session.getSALService(DataBroker.class);
 
+        // Allocate provider based on config
         INetvirtSfcOF13Provider provider = new NetvirtSfcOF13Provider(dataBroker);
         aclListener = new NetvirtSfcAclListener(provider, dataBroker);
         classfierListener = new NetvirtSfcClassifierListener(provider, dataBroker);
similarity index 98%
rename from openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/openflow13/NshUtils.java
rename to openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NshUtils.java
index d8aca3bd930094bfe97abef367b86ce351574348..f28f030741577ab1add58386c7460e6ee951c332 100644 (file)
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13;
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
 
 import com.google.common.net.InetAddresses;
 
index 1c83d5370bb6ddfdbb30cbc7f4ce79752c874cec..41b3e465cc77bddb0531c77492f8f8b7d22b881c 100644 (file)
@@ -18,6 +18,8 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.INetvirtSfcOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
 import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
@@ -39,6 +41,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.cont
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.acl.rev150105.RedirectToSfc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.Classifier;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.Bridges;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.bridges.Bridge;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
@@ -86,6 +90,44 @@ public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider {
         // TODO Auto-generated method stub
     }
 
+    @Override
+    public void addClassifierRules(Acl acl) {
+        String aclName = acl.getAclName();
+        Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
+        if (classifiers == null) {
+            LOG.debug("add: No Classifiers found");
+            return;
+        }
+
+        LOG.debug("add: Classifiers: {}", classifiers);
+        for (Classifier classifier : classifiers.getClassifier()) {
+            if (classifier.getAcl().equals(aclName)) {
+                if (classifier.getBridges() != null) {
+                    for (Bridge bridge : classifier.getBridges().getBridge()) {
+                        addClassifierRules(bridge, acl);
+                    }
+                }
+            }
+        }
+    }
+
+    @Override
+    public void removeClassifierRules(Acl acl) {
+        String aclName = acl.getAclName();
+        Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, getClassifierIid());
+        if (classifiers != null) {
+            for (Classifier classifier : classifiers.getClassifier()) {
+                if (classifier.getAcl().equalsIgnoreCase(aclName)) {
+                    if (classifier.getSffs() != null) {
+                        for (Sff sff : classifier.getSffs().getSff()) {
+                            removeClassifierRules(sff, acl);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
     @Override
     public void addClassifierRules(Bridge bridge, Acl acl) {
 
@@ -365,6 +407,10 @@ public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider {
         return null;
     }
 
+    private InstanceIdentifier<Classifiers> getClassifierIid() {
+        return InstanceIdentifier.create(Classifiers.class);
+    }
+
     public void handleLocalInPort(long dpidLong, String segmentationId, Long inPort,
                                   short writeTable, short goToTableId, Matches matches, boolean write) {
         sfcClassifier.programLocalInPort(dpidLong, segmentationId, inPort, writeTable, goToTableId, matches, write);
index 414db06f1fc47ecaa591875bdf25e012b5659df4..eefaf7ff5baf33c95ad642f159ccac8b385aced8 100644 (file)
@@ -15,6 +15,7 @@ import java.util.List;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.NshUtils;
 import org.opendaylight.ovsdb.utils.mdsal.openflow.ActionUtils;
 import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
 import org.opendaylight.ovsdb.utils.mdsal.openflow.InstructionUtils;
index 87cdaa5df867187388f7a13aa7e277a386909a6e..19ef2667af27f158cf6b97198e4a7063e73d3427 100644 (file)
@@ -30,6 +30,7 @@ import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
 import org.junit.Assert;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
@@ -37,9 +38,7 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.mdsal.it.base.AbstractMdsalTestBase;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Southbound;
-import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
-import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.NshUtils;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.openflow13.SfcClassifier;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.AclUtils;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ClassifierUtils;
@@ -68,7 +67,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.ta
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.match.rev140421.oxm.container.match.entry.value.Nshc1CaseValue;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.ClassifiersBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.ClassifierBuilder;
@@ -184,15 +182,15 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
     @Override
     public Option getLoggingOption() {
         return composite(
+                editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
+                        "log4j.logger.org.opendaylight.ovsdb",
+                        LogLevelOption.LogLevel.TRACE.name()),
                 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
                         logConfiguration(NetvirtSfcIT.class),
                         LogLevel.INFO.name()),
                 editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
                         "log4j.logger.org.opendaylight.ovsdb.openstack.netvirt.sfc",
                         LogLevel.TRACE.name()),
-                editConfigurationFilePut(ORG_OPS4J_PAX_LOGGING_CFG,
-                        "log4j.logger.org.opendaylight.ovsdb",
-                        LogLevelOption.LogLevel.TRACE.name()),
                 super.getLoggingOption());
     }
 
@@ -362,6 +360,7 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
      * Connect to an ovsdb node. Netvirt should add br-int, add the controller address
      * and program the pipeline flows.
      */
+    @Ignore
     @Test
     public void testNetvirtSfc() throws InterruptedException {
         String bridgeName = INTEGRATION_BRIDGE_NAME;
@@ -394,9 +393,6 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
         assertNotNull("bridge " + bridgeName + " was not found", bridgeNode);
         long datapathId = southbound.getDataPathId(bridgeNode);
 
-        /* TODO: add code to write to mdsal to exercise the sfc dataChangeListener */
-        /* allow some time to let the impl code do it's work to push flows */
-        /* or just comment out below lines and just manually verify on the bridges and reset them */
         //Thread.sleep(10000);
 
         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
@@ -411,62 +407,9 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
         assertTrue(southboundUtils.disconnectOvsdbNode(connectionInfo));
     }
 
+    @Ignore
     @Test
-    public void testDemo() throws InterruptedException {
-        for (DemoVm vm : demoVms){
-            ConnectionInfo connectionInfo = southboundUtils.getConnectionInfo(vm.ipAddr, vm.ipPort);
-            assertNotNull("connection failed", southboundUtils.connectOvsdbNode(connectionInfo));
-            Node ovsdbNode = southboundUtils.getOvsdbNode(connectionInfo);
-            assertNotNull("node is not connected", ovsdbNode);
-            String controllerTarget = SouthboundUtil.getControllerTarget(ovsdbNode);
-            assertNotNull("Failed to get controller target", controllerTarget);
-            List<ControllerEntry> setControllerEntry = southboundUtils.createControllerEntry(controllerTarget);
-            Uri setUri = new Uri(controllerTarget);
-            assertTrue(southboundUtils.addBridge(connectionInfo, null, vm.name, null, true,
-                    SouthboundConstants.OVSDB_FAIL_MODE_MAP.inverse().get("secure"), true, null, null,
-                    setControllerEntry, null));
-
-            for (int i = 0; i < 10; i++) {
-                OvsdbBridgeAugmentation bridge = southboundUtils.getBridge(connectionInfo, vm.name);
-                assertNotNull("bridge was not found: " + vm.name, bridge);
-                assertNotNull("ControllerEntry was not found: "
-                                + southboundUtils.createControllerEntry(controllerTarget),
-                        bridge.getControllerEntry());
-                List<ControllerEntry> getControllerEntries = bridge.getControllerEntry();
-                for (ControllerEntry entry : getControllerEntries) {
-                    if (entry.isIsConnected()) {
-                        assertTrue(entry.isIsConnected());
-                        break;
-                    }
-                }
-                Thread.sleep(1000);
-            }
-
-            assertTrue(southboundUtils.deleteBridge(connectionInfo, vm.name));
-            Thread.sleep(1000);
-            assertTrue(southboundUtils.disconnectOvsdbNode(connectionInfo));
-        }
-    }
-
-    private class DemoVm {
-        String name;
-        String ipAddr;
-        String ipPort;
-
-        DemoVm(String name, String ipAddr, String ipPort) {
-            this.name = name;
-            this.ipAddr = ipAddr;
-            this.ipPort = ipPort;
-        }
-    }
-
-    private DemoVm[] demoVms = {
-            new DemoVm("sw1", "192.168.50.70", "6640"),
-            //new DemoVm("sw2", "192.168.50.71", "6640"),
-    };
-
-    @Test
-    public void testDoIt2() throws InterruptedException {
+    public void testStandalone() throws InterruptedException {
         String bridgeName = "sw1";
         ConnectionInfo connectionInfo = southboundUtils.getConnectionInfo(addressStr, portStr);
         assertNotNull("connection failed", southboundUtils.connectOvsdbNode(connectionInfo));
@@ -517,12 +460,12 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
         //    e.printStackTrace();
         //}
 
-        /*NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
-        FlowBuilder flowBuilder = getLocalInPortFlow(datapathId, "4096", (long) 1, (short) 0);
-        Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
-        assertNotNull("Could not find flow in config", flow);
-        flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
-        assertNotNull("Could not find flow in operational", flow);*/
+        //NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);
+        //FlowBuilder flowBuilder = getLocalInPortFlow(datapathId, "4096", (long) 1, (short) 0);
+        //Flow flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.CONFIGURATION);
+        //assertNotNull("Could not find flow in config", flow);
+        //flow = getFlow(flowBuilder, nodeBuilder, LogicalDatastoreType.OPERATIONAL);
+        //assertNotNull("Could not find flow in operational", flow);
 
         MatchBuilder matchBuilder = sfcClassifier.buildMatch(matchesBuilder.build());
         NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(datapathId);