initial framework for sfc workaround and IT tests 22/29422/1
authorSam Hague <shague@redhat.com>
Mon, 9 Nov 2015 03:21:15 +0000 (22:21 -0500)
committerSam Hague <shague@redhat.com>
Mon, 9 Nov 2015 03:21:15 +0000 (22:21 -0500)
Change-Id: I94a4a40659fb4f0a1ecc815a7d132ffcadd991de
Signed-off-by: Sam Hague <shague@redhat.com>
14 files changed:
openstack/net-virt-sfc/impl/src/main/config/default-config.xml
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/SfcUtils.java [new file with mode: 0644]
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/standalone/openflow13/NetvirtSfcStandaloneOF13Provider.java [moved from openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/standalone/openflow13/NetvirtSfcOF13Provider.java with 96% similarity]
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/standalone/openflow13/services/SfcClassifierService.java
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/NetvirtSfcWorkaroundOF13Provider.java [new file with mode: 0644]
openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/SfcClassifierService.java [new file with mode: 0644]
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/NetvirtSfcIT.java
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/AbstractUtils.java [new file with mode: 0644]
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/AclUtils.java
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ClassifierUtils.java
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ServiceFunctionForwarderUtils.java [new file with mode: 0644]
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ServiceFunctionUtils.java [new file with mode: 0644]
openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/SfcUtils.java

index 99c34553263e9a6392c03a803baf1d441439c29a..a794e579218c8e05d2352cad7e5c369af812b445 100644 (file)
@@ -21,7 +21,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
         <module>
           <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:netvirt:sfc">prefix:netvirt-sfc</type>
           <name>netvirt-sfc-default</name>
-          <of13provider>standalone</of13provider>
+          <of13provider>workaround</of13provider>
           <broker>
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
             <name>binding-osgi-broker</name>
index 01274752c280584ccc9d77c837dc82038c281b87..0289d60eea94f71fa9ae0931a72375eac549394d 100644 (file)
@@ -17,8 +17,10 @@ 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.standalone.openflow13.NetvirtSfcOF13Provider;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.NetvirtSfcStandaloneOF13Provider;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.services.SfcClassifierService;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services.NetvirtSfcWorkaroundOF13Provider;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
 import org.slf4j.Logger;
@@ -53,12 +55,14 @@ public class NetvirtSfcProvider implements BindingAwareProvider, AutoCloseable {
         LOG.info("NetvirtSfcProvider Session Initiated");
         DataBroker dataBroker = session.getSALService(DataBroker.class);
 
+        MdsalUtils mdsalUtils = new MdsalUtils(dataBroker);
+        SfcUtils sfcUtils = new SfcUtils(mdsalUtils);
         // Allocate provider based on config
         INetvirtSfcOF13Provider provider;
         if (of13Provider.equals("standalone")) {
-            provider = new NetvirtSfcOF13Provider(dataBroker);
+            provider = new NetvirtSfcStandaloneOF13Provider(dataBroker);
         } else {
-            provider = new NetvirtSfcOF13Provider(dataBroker);
+            provider = new NetvirtSfcWorkaroundOF13Provider(dataBroker, mdsalUtils, sfcUtils);
         }
         aclListener = new NetvirtSfcAclListener(provider, dataBroker);
         classifierListener = new NetvirtSfcClassifierListener(provider, dataBroker);
diff --git a/openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/SfcUtils.java b/openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/SfcUtils.java
new file mode 100644 (file)
index 0000000..4114b1f
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2015 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc;
+
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.sfc.provider.api.SfcProviderServicePathAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.RspName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.RenderedServicePaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePathKey;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.ServiceFunctionPaths;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.Classifiers;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+public class SfcUtils {
+    private MdsalUtils mdsalUtils;
+
+    public SfcUtils(MdsalUtils mdsalUtils) {
+        this.mdsalUtils = mdsalUtils;
+    }
+
+    public InstanceIdentifier<Classifiers> getClassifierIid() {
+        return InstanceIdentifier.create(Classifiers.class);
+    }
+
+    public InstanceIdentifier<RenderedServicePaths> getRspsId() {
+        return InstanceIdentifier.builder(RenderedServicePaths.class).build();
+    }
+
+    public InstanceIdentifier<RenderedServicePath> getRspId(String rspName) {
+        return InstanceIdentifier.builder(RenderedServicePaths.class)
+                .child(RenderedServicePath.class, new RenderedServicePathKey(new RspName(rspName))).build();
+    }
+
+    public RenderedServicePath getRspforSfp(String sfpName) {
+        RenderedServicePath rspFound = null;
+        RenderedServicePaths rsps = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, this.getRspsId());
+        if (rsps != null) {
+            for (RenderedServicePath rsp : rsps.getRenderedServicePath()) {
+                if (rsp.getParentServiceFunctionPath() != null) {
+                    if (rsp.getParentServiceFunctionPath().getValue().equals(sfpName)) {
+                        rspFound = rsp;
+                    }
+                }
+            }
+        }
+        return rspFound;
+    }
+
+    public ServiceFunctionPath getSfp(String redirectSfc) {
+        ServiceFunctionPath sfpFound = null;
+        ServiceFunctionPaths sfps = SfcProviderServicePathAPI.readAllServiceFunctionPaths();
+        if (sfps != null) {
+            for (ServiceFunctionPath sfp: sfps.getServiceFunctionPath()) {
+                if (sfp.getServiceChainName().getValue().equalsIgnoreCase(redirectSfc)) {
+                    sfpFound = sfp;
+                }
+            }
+        }
+        return sfpFound;
+    }
+}
@@ -56,8 +56,8 @@ import org.slf4j.LoggerFactory;
  * Open vSwitch OpenFlow 1.3 Networking Provider for Netvirt SFC
  * @author Arun Yerra
  */
-public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider {
-    private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcOF13Provider.class);
+public class NetvirtSfcStandaloneOF13Provider implements INetvirtSfcOF13Provider {
+    private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcStandaloneOF13Provider.class);
     private static final short TABLE_0_CLASSIFIER = 0;
     private static final short TABLE_3_INGR_ACL = 50;
 
@@ -76,10 +76,10 @@ public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider {
     private static final String INTERFACE_TYPE_VXLAN_GPE = "vxlangpe";
 
     /**
-     * {@link NetvirtSfcOF13Provider} constructor.
+     * {@link NetvirtSfcStandaloneOF13Provider} constructor.
      * @param dataBroker MdSal {@link DataBroker}
      */
-    public NetvirtSfcOF13Provider(final DataBroker dataBroker) {
+    public NetvirtSfcStandaloneOF13Provider(final DataBroker dataBroker) {
         Preconditions.checkNotNull(dataBroker, "Input dataBroker cannot be NULL!");
         mdsalUtils = new MdsalUtils(dataBroker);
         this.setDependencies(null);
@@ -103,9 +103,7 @@ public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider {
         for (Classifier classifier : classifiers.getClassifier()) {
             if (classifier.getAcl().equals(aclName)) {
                 if (classifier.getBridges() != null) {
-                    for (Bridge bridge : classifier.getBridges().getBridge()) {
-                        addClassifierRules(bridge, acl);
-                    }
+                    addClassifierRules(classifier.getBridges(), acl);
                 }
             }
         }
@@ -135,16 +133,9 @@ public class NetvirtSfcOF13Provider implements INetvirtSfcOF13Provider {
 
     @Override
     public void addClassifierRules(Bridges bridges, Acl acl) {
-        Preconditions.checkNotNull(bridges, "Input bridge cannot be NULL!");
+        Preconditions.checkNotNull(bridges, "Input bridges cannot be NULL!");
         Preconditions.checkNotNull(acl, "Input accesslist cannot be NULL!");
 
-        //Node bridgeNode = getBridgeNode(bridge.getName());
-        //if (bridgeNode == null) {
-        //    LOG.debug("bridge {} not yet configured. Skip processing !!", bridge.getName());
-        //    return;
-        //}
-
-        // TODO: Find all nodes needing the classifier and add classifier to them
         for (Ace ace : acl.getAccessListEntries().getAce()) {
             processAclEntry(ace, bridges, true);
         }
index 6726ef656334378d193f0571231c219323061ab4..bc0140fa79893c8ba1279929a3a6bdbe5223cbb7 100644 (file)
@@ -13,8 +13,12 @@ import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractSer
 import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public class SfcClassifierService extends AbstractServiceInstance implements ConfigInterface {
+    private static final Logger LOG = LoggerFactory.getLogger(SfcClassifierService.class);
+
     public SfcClassifierService(Service service) {
         super(service);
     }
diff --git a/openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/NetvirtSfcWorkaroundOF13Provider.java b/openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/NetvirtSfcWorkaroundOF13Provider.java
new file mode 100644 (file)
index 0000000..fa26ee5
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright © 2015 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services;
+
+import com.google.common.base.Preconditions;
+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.SfcUtils;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
+import org.opendaylight.sfc.provider.api.SfcProviderRenderedPathAPI;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInput;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.CreateRenderedPathInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.rsp.rev140701.rendered.service.paths.RenderedServicePath;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sfp.rev140701.service.function.paths.ServiceFunctionPath;
+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.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.ace.Matches;
+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;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NetvirtSfcWorkaroundOF13Provider implements INetvirtSfcOF13Provider {
+    private static final Logger LOG = LoggerFactory.getLogger(NetvirtSfcWorkaroundOF13Provider.class);
+    private volatile NodeCacheManager nodeCacheManager;
+    private volatile Southbound southbound;
+    private MdsalUtils mdsalUtils;
+    private SfcUtils sfcUtils;
+    private SfcClassifierService sfcClassifierService;
+
+    public NetvirtSfcWorkaroundOF13Provider(final DataBroker dataBroker, MdsalUtils mdsalUtils, SfcUtils sfcUtils) {
+        Preconditions.checkNotNull(dataBroker, "Input dataBroker cannot be NULL!");
+        Preconditions.checkNotNull(mdsalUtils, "Input mdsalUtils cannot be NULL!");
+        Preconditions.checkNotNull(sfcUtils, "Input sfcUtils cannot be NULL!");
+
+        this.mdsalUtils = mdsalUtils;
+        this.sfcUtils = sfcUtils;
+        this.setDependencies(null);
+    }
+
+    @Override
+    public void addClassifierRules(Bridge bridge, Acl acl) {
+
+    }
+
+    @Override
+    public void addClassifierRules(Bridges bridges, Acl acl) {
+        Preconditions.checkNotNull(bridges, "Input bridges cannot be NULL!");
+        Preconditions.checkNotNull(acl, "Input acl cannot be NULL!");
+
+        for (Ace ace : acl.getAccessListEntries().getAce()) {
+            processAclEntry(ace, bridges);
+        }
+    }
+
+    @Override
+    public void removeClassifierRules(Sff sff, Acl acl) {
+
+    }
+
+    @Override
+    public void addClassifierRules(Acl acl) {
+        String aclName = acl.getAclName();
+        Classifiers classifiers = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, sfcUtils.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) {
+                    addClassifierRules(classifier.getBridges(), acl);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void removeClassifierRules(Acl acl) {
+
+    }
+
+    private void processAclEntry(Ace entry, Bridges bridges) {
+        Matches matches = entry.getMatches();
+        Preconditions.checkNotNull(matches, "Input bridges cannot be NULL!");
+
+        RenderedServicePath rsp = getRenderedServicePath(entry);
+        if (rsp == null) {
+            LOG.warn("Failed to get renderedServicePatch for entry: {}", entry);
+            return;
+        }
+
+        //handleIngressClassifier();
+        //handleEgressClassifier();
+        //handleSfLoopback();
+
+    }
+
+    // loop through sf's:
+    // - program arp responder
+    // - program sf to sff
+    // - program sff to sf
+    private void handleSfWorkaround(RenderedServicePath rsp) {
+
+    }
+
+    private RenderedServicePath getRenderedServicePath (Ace entry) {
+        RedirectToSfc sfcRedirect = entry.getActions().getAugmentation(RedirectToSfc.class);
+        LOG.debug("Processing ACL entry = {} sfcRedirect = {}", entry.getRuleName(), sfcRedirect);
+        if (sfcRedirect == null) {
+            LOG.warn("processAClEntry: sfcRedirect is null");
+            return null;
+        }
+
+        String sfcName = sfcRedirect.getRedirectSfc();
+        ServiceFunctionPath sfp = sfcUtils.getSfp(sfcName);
+        if (sfp == null || sfp.getName() == null) {
+            LOG.warn("There is no configured SFP with sfcName = {}; so skip installing the ACL entry!!", sfcName);
+            return null;
+        }
+
+        LOG.debug("Processing Redirect to SFC = {}, SFP = {}", sfcRedirect.getRedirectSfc(), sfp);
+        // If RSP doesn't exist, create an RSP.
+        String sfpName = sfp.getName().getValue();
+        RenderedServicePath rsp = sfcUtils.getRspforSfp(sfpName);
+        String rspName = sfp.getName().getValue() + "_rsp";
+        if (rsp == null) {
+            LOG.info("No configured RSP corresponding to SFP = {}, Creating new RSP = {}", sfpName, rspName);
+            CreateRenderedPathInput rspInput = new CreateRenderedPathInputBuilder()
+                    .setParentServiceFunctionPath(sfpName)
+                    .setName(rspName)
+                    .setSymmetric(sfp.isSymmetric())
+                    .build();
+            rsp = SfcProviderRenderedPathAPI.createRenderedServicePathAndState(sfp, rspInput);
+            if (rsp == null) {
+                LOG.warn("failed to add RSP");
+                return null;
+            }
+
+            // If SFP is symmetric, create RSP in the reverse direction.
+            if (sfp.isSymmetric()) {
+                LOG.info("SFP = {} is symmetric, installing RSP in the reverse direction!!", sfpName);
+                String rspNameRev = rspName + "-Reverse";
+                RenderedServicePath rspReverse = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
+                        sfcUtils.getRspId(rspNameRev));
+                if (rspReverse == null) {
+                    rspReverse = SfcProviderRenderedPathAPI.createSymmetricRenderedServicePathAndState(rsp);
+                    if (rspReverse == null) {
+                        LOG.warn("failed to add reverse RSP");
+                        return null;
+                    }
+                }
+            }
+        }
+        return rsp;
+    }
+
+    private void setDependencies(ServiceReference serviceReference) {
+        nodeCacheManager = (NodeCacheManager) ServiceHelper.getGlobalInstance(NodeCacheManager.class, this);
+        southbound = (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
+        sfcClassifierService = (SfcClassifierService) ServiceHelper.getGlobalInstance(SfcClassifierService.class, this);
+    }
+}
diff --git a/openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/SfcClassifierService.java b/openstack/net-virt-sfc/impl/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/workaround/services/SfcClassifierService.java
new file mode 100644 (file)
index 0000000..59e4c6b
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2015 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.workaround.services;
+
+import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance;
+import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+
+public class SfcClassifierService extends AbstractServiceInstance implements ConfigInterface {
+    public SfcClassifierService(Service service) {
+        super(service);
+    }
+
+    public SfcClassifierService() {
+        super(Service.SFC_CLASSIFIER);
+    }
+
+    @Override
+    public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+        super.setDependencies(bundleContext.getServiceReference(SfcClassifierService.class.getName()), this);
+    }
+
+    @Override
+    public void setDependencies(Object impl) {}
+}
index 95b2f7517a12548f52add477b848a1997bc73464..a53c1bbcb3989930600302206d3717af61c438f1 100644 (file)
@@ -26,6 +26,7 @@ import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfi
 import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
 
 import java.math.BigInteger;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -44,6 +45,8 @@ import org.opendaylight.ovsdb.openstack.netvirt.sfc.standalone.openflow13.SfcCla
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.AclUtils;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ClassifierUtils;
 import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.SfcUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ServiceFunctionForwarderUtils;
+import org.opendaylight.ovsdb.openstack.netvirt.sfc.utils.ServiceFunctionUtils;
 import org.opendaylight.ovsdb.southbound.SouthboundConstants;
 import org.opendaylight.ovsdb.southbound.SouthboundUtil;
 import org.opendaylight.ovsdb.utils.mdsal.openflow.FlowUtils;
@@ -51,6 +54,24 @@ import org.opendaylight.ovsdb.utils.mdsal.openflow.MatchUtils;
 import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
 import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctions;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwarders;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwardersBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Dpi;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.Firewall;
 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.AccessListsBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.AclBuilder;
@@ -105,6 +126,8 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
     private static AclUtils aclUtils = new AclUtils();
     private static ClassifierUtils classifierUtils = new ClassifierUtils();
     private static SfcUtils sfcUtils = new SfcUtils();
+    private static ServiceFunctionUtils serviceFunctionUtils = new ServiceFunctionUtils();
+    private static ServiceFunctionForwarderUtils serviceFunctionForwarderUtils = new ServiceFunctionForwarderUtils();
     private static MdsalUtils mdsalUtils;
     private static AtomicBoolean setup = new AtomicBoolean(false);
     private static SouthboundUtils southboundUtils;
@@ -195,6 +218,9 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
                 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.sfc",
+                        LogLevel.TRACE.name()),
                 super.getLoggingOption());
     }
 
@@ -306,61 +332,140 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
     }
 
     private AccessListsBuilder setAccessLists () {
-        MatchesBuilder matchesBuilder = aclUtils.createMatches(new MatchesBuilder(), 80);
-        ActionsBuilder actionsBuilder = aclUtils.createActions(new ActionsBuilder(), Boolean.TRUE);
-        AceBuilder accessListEntryBuilder = aclUtils.createAccessListEntryBuilder(
+        MatchesBuilder matchesBuilder = aclUtils.matchesBuilder(new MatchesBuilder(), 80);
+        ActionsBuilder actionsBuilder = aclUtils.actionsBuilder(new ActionsBuilder(), Boolean.TRUE);
+        AceBuilder accessListEntryBuilder = aclUtils.aceBuilder(
                 new AceBuilder(), "http", matchesBuilder, actionsBuilder);
-        AccessListEntriesBuilder accessListEntriesBuilder = aclUtils.createAccessListEntries(
+        AccessListEntriesBuilder accessListEntriesBuilder = aclUtils.accessListEntriesBuidler(
                 new AccessListEntriesBuilder(), accessListEntryBuilder);
-        AclBuilder accessListBuilder = aclUtils.createAccessList(new AclBuilder(),
+        AclBuilder accessListBuilder = aclUtils.aclBuilder(new AclBuilder(),
                 "http", accessListEntriesBuilder);
-        AccessListsBuilder accessListsBuilder = aclUtils.createAccessLists(new AccessListsBuilder(),
+        AccessListsBuilder accessListsBuilder = aclUtils.accessListsBuidler(new AccessListsBuilder(),
                 accessListBuilder);
         LOG.info("AccessLists: {}", accessListsBuilder.build());
         return accessListsBuilder;
     }
 
     @Test
-    public void testAccessLists() {
-        testModel(setAccessLists(), AccessLists.class);
+    public void testAccessLists() throws InterruptedException {
+        testModel(setAccessLists(), AccessLists.class, 0);
     }
 
     private ClassifiersBuilder setClassifiers() {
-        SffBuilder sffBuilder = classifierUtils.createSff(new SffBuilder(), "sffname");
-        SffsBuilder sffsBuilder = classifierUtils.createSffs(new SffsBuilder(), sffBuilder);
-        ClassifierBuilder classifierBuilder = classifierUtils.createClassifier(new ClassifierBuilder(),
+        SffBuilder sffBuilder = classifierUtils.sffBuilder(new SffBuilder(), "sffname");
+        SffsBuilder sffsBuilder = classifierUtils.sffsBuilder(new SffsBuilder(), sffBuilder);
+        ClassifierBuilder classifierBuilder = classifierUtils.classifierBuilder(new ClassifierBuilder(),
                 "classifierName", "aclName", sffsBuilder);
-        ClassifiersBuilder classifiersBuilder = classifierUtils.createClassifiers(new ClassifiersBuilder(),
+        ClassifiersBuilder classifiersBuilder = classifierUtils.ClassifiersBuilder(new ClassifiersBuilder(),
                 classifierBuilder);
         LOG.info("Classifiers: {}", classifiersBuilder.build());
         return classifiersBuilder;
     }
 
     @Test
-    public void testClassifiers() {
-        testModel(setClassifiers(), Classifiers.class);
+    public void testClassifiers() throws InterruptedException {
+        testModel(setClassifiers(), Classifiers.class, 0);
     }
 
-    private SfcBuilder setSfc() {
-        return sfcUtils.createSfc(new SfcBuilder(), "sfc");
+    private SfcBuilder netvirtSfcBuilder() {
+        return sfcUtils.sfcBuilder(new SfcBuilder(), "sfc");
     }
 
     @Test
-    public void testSfc() {
-        testModel(setSfc(), Sfc.class);
+    public void testNetvirtSfcModel() throws InterruptedException {
+        testModel(netvirtSfcBuilder(), Sfc.class, 0);
     }
 
-    private <T extends DataObject> void testModel(Builder<T> builder, Class<T> clazz) {
+    private <T extends DataObject> void testModel(Builder<T> builder, Class<T> clazz, long wait)
+            throws InterruptedException {
         InstanceIdentifier<T> path = InstanceIdentifier.create(clazz);
         assertTrue(mdsalUtils.put(LogicalDatastoreType.CONFIGURATION, path, builder.build()));
         T result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
         assertNotNull(clazz.getSimpleName() + " should not be null", result);
+        Thread.sleep(wait);
         assertTrue("Failed to remove " + clazz.getSimpleName(),
                 mdsalUtils.delete(LogicalDatastoreType.CONFIGURATION, path));
         result = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
         assertNull(clazz.getSimpleName() + " should be null", result);
     }
 
+    private ServiceFunctionsBuilder serviceFunctionsBuilder() {
+        SfDataPlaneLocatorBuilder sfDataPlaneLocator =
+                serviceFunctionUtils.sfDataPlaneLocatorBuilder(new SfDataPlaneLocatorBuilder(),
+                        "192.168.120.31", 6633, "testDpl1-1234-uuid", "testSff1");
+        List<SfDataPlaneLocator> sfDataPlaneLocatorList = serviceFunctionUtils.list(
+                new ArrayList<SfDataPlaneLocator>(), sfDataPlaneLocator);
+        ServiceFunctionBuilder serviceFunctionBuilder =
+                serviceFunctionUtils.serviceFunctionBuidler(new ServiceFunctionBuilder(),
+                        "192.168.120.31", "testSf", sfDataPlaneLocatorList, Firewall.class);
+        List<ServiceFunction> serviceFunctionList = serviceFunctionUtils.list(
+                new ArrayList<ServiceFunction>(), serviceFunctionBuilder);
+
+        sfDataPlaneLocator =
+                serviceFunctionUtils.sfDataPlaneLocatorBuilder(new SfDataPlaneLocatorBuilder(),
+                        "192.168.120.32", 6633, "testDpl2-1234-uuid", "testSff2");
+        sfDataPlaneLocatorList = serviceFunctionUtils.list(
+                new ArrayList<SfDataPlaneLocator>(), sfDataPlaneLocator);
+        serviceFunctionBuilder =
+                serviceFunctionUtils.serviceFunctionBuidler(new ServiceFunctionBuilder(),
+                        "192.168.120.32", "testSf2", sfDataPlaneLocatorList, Dpi.class);
+        serviceFunctionList = serviceFunctionUtils.list(
+                serviceFunctionList, serviceFunctionBuilder);
+
+        ServiceFunctionsBuilder serviceFunctionsBuilder =
+                serviceFunctionUtils.serviceFunctionsBuilder(new ServiceFunctionsBuilder(),
+                        serviceFunctionList);
+        LOG.info("ServiceFunctions: {}", serviceFunctionsBuilder.build());
+        return serviceFunctionsBuilder;
+    }
+
+    private ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder() {
+        String sf1Name = "firewall-72";
+        String sff1Ip = "192.168.120.31";
+        String sff1Name = "SFF1";
+        String sffDpl1Name = "sfc-tun2";
+        String sn1Name = "OVSDB2";
+        String bridge1Name= "sw2";
+        int port = 6633;
+
+        DataPlaneLocatorBuilder dataPlaneLocatorBuilder =
+                serviceFunctionForwarderUtils.dataPlaneLocatorBuilder(
+                        new DataPlaneLocatorBuilder(), sff1Ip, port);
+        SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder =
+                serviceFunctionForwarderUtils.sffDataPlaneLocatorBuilder(
+                        new SffDataPlaneLocatorBuilder(), dataPlaneLocatorBuilder, sffDpl1Name);
+        List<SffDataPlaneLocator> sffDataPlaneLocatorList = serviceFunctionForwarderUtils.list(
+                new ArrayList<SffDataPlaneLocator>(), sffDataPlaneLocatorBuilder);
+
+        SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder =
+                serviceFunctionForwarderUtils.sffSfDataPlaneLocatorBuilder(
+                        new SffSfDataPlaneLocatorBuilder(), sff1Ip, port);
+        ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder =
+                serviceFunctionForwarderUtils.serviceFunctionDictionaryBuilder(
+                        new ServiceFunctionDictionaryBuilder(), sf1Name, Firewall.class,
+                        sffSfDataPlaneLocatorBuilder);
+        List<ServiceFunctionDictionary> serviceFunctionDictionaryList = serviceFunctionForwarderUtils.list(
+                new ArrayList<ServiceFunctionDictionary>(), serviceFunctionDictionaryBuilder);
+
+        ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder =
+                serviceFunctionForwarderUtils.serviceFunctionForwarderBuilder(
+                        new ServiceFunctionForwarderBuilder(), sff1Name, sn1Name, bridge1Name,
+                        sffDataPlaneLocatorList, serviceFunctionDictionaryList);
+        List<ServiceFunctionForwarder>  serviceFunctionForwarderList = serviceFunctionForwarderUtils.list(
+                new ArrayList<ServiceFunctionForwarder>(), serviceFunctionForwarderBuilder);
+        ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder =
+                serviceFunctionForwarderUtils.serviceFunctionForwardersBuilder(
+                        new ServiceFunctionForwardersBuilder(), serviceFunctionForwarderList);
+        LOG.info("ServiceFunctionForwarders: {}", serviceFunctionForwardersBuilder.build());
+        return serviceFunctionForwardersBuilder;
+    }
+
+    @Test
+    public void testSfcModel() throws InterruptedException {
+        testModel(serviceFunctionsBuilder(), ServiceFunctions.class, 3000);
+        testModel(serviceFunctionForwardersBuilder(), ServiceFunctionForwarders.class, 3000);
+    }
+
     /*
      * Connect to an ovsdb node. Netvirt should add br-int, add the controller address
      * and program the pipeline flows.
@@ -450,7 +555,7 @@ public class NetvirtSfcIT extends AbstractMdsalTestBase {
 
         NshUtils nshUtils = new NshUtils(new Ipv4Address("192.168.50.71"), new PortNumber(6633),
                 (long)10, (short)255, (long)4096, (long)4096);
-        MatchesBuilder matchesBuilder = aclUtils.createMatches(new MatchesBuilder(), 80);
+        MatchesBuilder matchesBuilder = aclUtils.matchesBuilder(new MatchesBuilder(), 80);
         sfcClassifier.programSfcClassiferFlows(datapathId, (short)0, "test", matchesBuilder.build(),
                 nshUtils, (long)2, true);
 
diff --git a/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/AbstractUtils.java b/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/AbstractUtils.java
new file mode 100644 (file)
index 0000000..5258547
--- /dev/null
@@ -0,0 +1,29 @@
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.data.plane.locator.locator.type.IpBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yangtools.concepts.Builder;
+
+public abstract class AbstractUtils {
+    public <T> List<T> list(List<T> list, Builder<T> builder) {
+        list.add(builder.build());
+        return list;
+    }
+
+    public IpBuilder ipBuilder(String ip, int port) {
+        return new IpBuilder()
+                .setIp(new IpAddress(ip.toCharArray()))
+                .setPort(new PortNumber(port));
+    }
+
+    public DataPlaneLocatorBuilder dataPlaneLocatorBuilder(DataPlaneLocatorBuilder dataPlaneLocatorBuilder,
+                                                           String ip, int port) {
+        return dataPlaneLocatorBuilder
+                .setLocatorType(ipBuilder(ip, port).build())
+                .setTransport(VxlanGpe.class);
+    }
+}
index 6880841f523af11d239361ec69b791cac142360c..bae8a7261bd355da8b155113a7ff4e39b621bec6 100644 (file)
@@ -20,65 +20,57 @@ 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.MatchesBuilder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.actions.packet.handling.PermitBuilder;
 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.AceIpBuilder;
-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.access.control.list.rev150317.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.ace.ip.version.AceIpv4Builder;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev150611.acl.transport.header.fields.DestinationPortRangeBuilder;
 
-public class AclUtils {
-    public MatchesBuilder createMatches (MatchesBuilder matchesBuilder, int destPort) {
+public class AclUtils extends AbstractUtils {
+    public MatchesBuilder matchesBuilder(MatchesBuilder matchesBuilder, int destPort) {
         PortNumber portNumber = new PortNumber(destPort);
-        DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder();
-        destinationPortRangeBuilder.setLowerPort(portNumber);
-        destinationPortRangeBuilder.setUpperPort(portNumber);
+        DestinationPortRangeBuilder destinationPortRangeBuilder = new DestinationPortRangeBuilder()
+                .setLowerPort(portNumber)
+                .setUpperPort(portNumber);
 
-        AceIpBuilder aceIpBuilder = new AceIpBuilder();
-        aceIpBuilder.setDestinationPortRange(destinationPortRangeBuilder.build());
-        aceIpBuilder.setProtocol((short)6);
-        aceIpBuilder.setAceIpVersion(new AceIpv4Builder().build());
-        matchesBuilder.setAceType(aceIpBuilder.build());
+        AceIpBuilder aceIpBuilder = new AceIpBuilder()
+                .setDestinationPortRange(destinationPortRangeBuilder.build())
+                .setProtocol((short)6)
+                .setAceIpVersion(new AceIpv4Builder().build());
 
-        return matchesBuilder;
+        return matchesBuilder.setAceType(aceIpBuilder.build());
     }
 
-    public ActionsBuilder createActions (ActionsBuilder actionsBuilder, Boolean permit) {
-        PermitBuilder permitBuilder = new PermitBuilder();
-        permitBuilder.setPermit(Boolean.TRUE);
-        actionsBuilder.setPacketHandling(permitBuilder.build());
-
-        return actionsBuilder;
+    public ActionsBuilder actionsBuilder(ActionsBuilder actionsBuilder, Boolean permit) {
+        return actionsBuilder.setPacketHandling(new PermitBuilder().setPermit(permit).build());
     }
 
-    public AceBuilder createAccessListEntryBuilder(AceBuilder accessListEntryBuilder,
-                                                   String ruleName,
-                                                   MatchesBuilder matchesBuilder,
-                                                   ActionsBuilder actionsBuilder) {
-        accessListEntryBuilder.setRuleName(ruleName);
-        accessListEntryBuilder.setMatches(matchesBuilder.build());
-        accessListEntryBuilder.setActions(actionsBuilder.build());
-
-        return accessListEntryBuilder;
+    public AceBuilder aceBuilder(AceBuilder accessListEntryBuilder,
+                                 String ruleName,
+                                 MatchesBuilder matchesBuilder,
+                                 ActionsBuilder actionsBuilder) {
+        return accessListEntryBuilder
+                .setRuleName(ruleName)
+                .setMatches(matchesBuilder.build())
+                .setActions(actionsBuilder.build());
     }
 
-    public AccessListEntriesBuilder createAccessListEntries(AccessListEntriesBuilder accessListEntriesBuilder,
-                                                            AceBuilder accessListEntryBuilder) {
+    public AccessListEntriesBuilder accessListEntriesBuidler(AccessListEntriesBuilder accessListEntriesBuilder,
+                                                             AceBuilder accessListEntryBuilder) {
         List<Ace> accessListEntriesList = new ArrayList<>();
         accessListEntriesList.add(accessListEntryBuilder.build());
 
         return accessListEntriesBuilder;
     }
 
-    public AclBuilder createAccessList(AclBuilder accessListBuilder,
-                                       String aclName,
-                                       AccessListEntriesBuilder accessListEntriesBuilder) {
-        accessListBuilder.setAclName(aclName);
-        accessListBuilder.setAccessListEntries(accessListEntriesBuilder.build());
-
-        return accessListBuilder;
+    public AclBuilder aclBuilder(AclBuilder accessListBuilder,
+                                 String aclName,
+                                 AccessListEntriesBuilder accessListEntriesBuilder) {
+        return accessListBuilder
+                .setAclName(aclName)
+                .setAccessListEntries(accessListEntriesBuilder.build());
     }
 
-    public AccessListsBuilder createAccessLists(AccessListsBuilder accessListsBuilder,
-                                                AclBuilder accessListBuilder) {
+    public AccessListsBuilder accessListsBuidler(AccessListsBuilder accessListsBuilder,
+                                                 AclBuilder accessListBuilder) {
         List<Acl> accessListList = new ArrayList<>();
         accessListList.add(accessListBuilder.build());
         accessListsBuilder.setAcl(accessListList);
index f99ca664cf46acb49839cdd7a84bdf8360c17349..54d31dbab720b96ac853517e539cead1c817bed1 100644 (file)
@@ -17,14 +17,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.Sff;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.classifier.rev150105.classifiers.classifier.sffs.SffBuilder;
 
-public class ClassifierUtils {
-    public SffBuilder createSff(SffBuilder sffBuilder, String sffName) {
-        sffBuilder.setName(sffName);
-
-        return sffBuilder;
+public class ClassifierUtils extends AbstractUtils {
+    public SffBuilder sffBuilder(SffBuilder sffBuilder, String sffName) {
+        return sffBuilder.setName(sffName);
     }
 
-    public SffsBuilder createSffs(SffsBuilder sffsBuilder, SffBuilder sffBuilder) {
+    public SffsBuilder sffsBuilder(SffsBuilder sffsBuilder, SffBuilder sffBuilder) {
         List<Sff> sffList = new ArrayList<>();
         sffList.add(sffBuilder.build());
         sffsBuilder.setSff(sffList);
@@ -32,17 +30,16 @@ public class ClassifierUtils {
         return sffsBuilder;
     }
 
-    public ClassifierBuilder createClassifier(ClassifierBuilder classifierBuilder,
-                                       String classifierName, String aclName,
-                                       SffsBuilder sffsBuilder) {
-        classifierBuilder.setName(classifierName);
-        classifierBuilder.setAcl(aclName);
-
-        return classifierBuilder;
+    public ClassifierBuilder classifierBuilder(ClassifierBuilder classifierBuilder,
+                                               String classifierName, String aclName,
+                                               SffsBuilder sffsBuilder) {
+        return classifierBuilder
+                .setName(classifierName)
+                .setAcl(aclName);
     }
 
-    public ClassifiersBuilder createClassifiers(ClassifiersBuilder classifiersBuilder,
-                                                ClassifierBuilder classifierBuilder) {
+    public ClassifiersBuilder ClassifiersBuilder(ClassifiersBuilder classifiersBuilder,
+                                                 ClassifierBuilder classifierBuilder) {
         List<Classifier> classifierList = new ArrayList<>();
         classifierList.add(classifierBuilder.build());
         classifiersBuilder.setClassifier(classifierList);
diff --git a/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ServiceFunctionForwarderUtils.java b/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ServiceFunctionForwarderUtils.java
new file mode 100644 (file)
index 0000000..0d92935
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2015 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffDataPlaneLocatorName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SnName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.SffOvsLocatorOptionsAugmentation;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.SffOvsLocatorOptionsAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.ovs.rev140701.options.OvsOptionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.ServiceFunctionForwardersBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.ServiceFunctionForwarderBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionary;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.ServiceFunctionDictionaryBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.SffDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.service.function.dictionary.SffSfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sff.rev140701.service.function.forwarders.service.function.forwarder.sff.data.plane.locator.DataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
+
+public class ServiceFunctionForwarderUtils extends AbstractUtils {
+    public OvsOptionsBuilder ovsOptionsBuilder(OvsOptionsBuilder ovsOptionsBuilder, int port) {
+        String flow = "flow";
+        return ovsOptionsBuilder
+                .setDstPort(String.valueOf(port))
+                .setRemoteIp(flow)
+                .setKey(flow)
+                .setNsi(flow)
+                .setNsp(flow)
+                .setNshc1(flow)
+                .setNshc2(flow)
+                .setNshc3(flow)
+                .setNshc4(flow);
+    }
+
+    public SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder(SffDataPlaneLocatorBuilder sffDataPlaneLocatorBuilder,
+                                                                 DataPlaneLocatorBuilder dataPlaneLocatorBuilder,
+                                                                 String dplName) {
+        SffOvsLocatorOptionsAugmentationBuilder sffOvsLocatorOptionsAugmentationBuilder =
+                new SffOvsLocatorOptionsAugmentationBuilder();
+        sffOvsLocatorOptionsAugmentationBuilder.setOvsOptions(
+                ovsOptionsBuilder(new OvsOptionsBuilder(), 6633).build());
+
+        return sffDataPlaneLocatorBuilder
+                .setName(new SffDataPlaneLocatorName(dplName))
+                .setDataPlaneLocator(dataPlaneLocatorBuilder.build())
+                .addAugmentation(SffOvsLocatorOptionsAugmentation.class,
+                        sffOvsLocatorOptionsAugmentationBuilder.build());
+    }
+
+    public SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder(
+            SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder, String ip, int port) {
+        return sffSfDataPlaneLocatorBuilder
+                .setLocatorType(ipBuilder(ip, port).build())
+                .setTransport(VxlanGpe.class);
+    }
+
+    public ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder(
+            ServiceFunctionDictionaryBuilder serviceFunctionDictionaryBuilder,
+            String sfName, Class<? extends ServiceFunctionTypeIdentity> type,
+            SffSfDataPlaneLocatorBuilder sffSfDataPlaneLocatorBuilder) {
+
+        return serviceFunctionDictionaryBuilder
+                .setName(new SfName(sfName))
+                .setType(type)
+                .setSffSfDataPlaneLocator(sffSfDataPlaneLocatorBuilder.build());
+    }
+
+    public ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder(
+            ServiceFunctionForwarderBuilder serviceFunctionForwarderBuilder,
+            String sffName, String serviceNodeName, String bridgeName,
+            List<SffDataPlaneLocator> sffDataPlaneLocatorList,
+            List<ServiceFunctionDictionary> serviceFunctionDictionaryList) {
+
+        return serviceFunctionForwarderBuilder
+                .setName(new SffName(sffName))
+                .setServiceNode(new SnName(serviceNodeName))
+                .setServiceFunctionDictionary(serviceFunctionDictionaryList)
+                .setSffDataPlaneLocator(sffDataPlaneLocatorList);
+    }
+
+    public ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder(
+            ServiceFunctionForwardersBuilder serviceFunctionForwardersBuilder,
+            List<ServiceFunctionForwarder> serviceFunctionForwarderList) {
+        return serviceFunctionForwardersBuilder.setServiceFunctionForwarder(serviceFunctionForwarderList);
+    }
+}
diff --git a/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ServiceFunctionUtils.java b/openstack/net-virt-sfc/it/src/test/java/org/opendaylight/ovsdb/openstack/netvirt/sfc/utils/ServiceFunctionUtils.java
new file mode 100644 (file)
index 0000000..6c70675
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright © 2015 Red Hat, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.ovsdb.openstack.netvirt.sfc.utils;
+
+import java.util.List;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfDataPlaneLocatorName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SfName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.common.rev151017.SffName;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.ServiceFunctionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocator;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.function.entry.SfDataPlaneLocatorBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunction;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sf.rev140701.service.functions.ServiceFunctionBuilder;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sft.rev140701.ServiceFunctionTypeIdentity;
+import org.opendaylight.yang.gen.v1.urn.cisco.params.xml.ns.yang.sfc.sl.rev140701.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+
+public class ServiceFunctionUtils extends AbstractUtils {
+    public SfDataPlaneLocatorBuilder sfDataPlaneLocatorBuilder(SfDataPlaneLocatorBuilder sfDataPlaneLocatorBuilder,
+                                                               String ip, int port, String dplName, String sffName) {
+        return sfDataPlaneLocatorBuilder
+                .setLocatorType(ipBuilder(ip, port).build())
+                .setName(new SfDataPlaneLocatorName(dplName))
+                .setTransport(VxlanGpe.class)
+                .setServiceFunctionForwarder(new SffName(sffName));
+    }
+
+    public ServiceFunctionBuilder serviceFunctionBuidler(ServiceFunctionBuilder serviceFunctionBuilder,
+                                                         String ip, String sfName,
+                                                         List<SfDataPlaneLocator> sfDataPlaneLocatorList,
+                                                         Class<? extends ServiceFunctionTypeIdentity> type) {
+        return serviceFunctionBuilder
+                .setSfDataPlaneLocator(sfDataPlaneLocatorList)
+                .setName(new SfName(sfName))
+                .setIpMgmtAddress(new IpAddress(ip.toCharArray()))
+                .setType(type)
+                .setNshAware(true);
+    }
+
+    public ServiceFunctionsBuilder serviceFunctionsBuilder(ServiceFunctionsBuilder serviceFunctionsBuilder,
+                                                           List<ServiceFunction> serviceFunctionList) {
+        return serviceFunctionsBuilder.setServiceFunction(serviceFunctionList);
+    }
+}
index 99fd35e1ce250723968dfa3e3776c48ebf24f4da..5b24ef437a6e73ed5bf2c4ae513e688d99fefba0 100644 (file)
@@ -11,9 +11,7 @@ package org.opendaylight.ovsdb.openstack.netvirt.sfc.utils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netvirt.sfc.rev150105.SfcBuilder;
 
 public class SfcUtils {
-    public SfcBuilder createSfc(SfcBuilder sfcBuilder, String sfcName) {
-        sfcBuilder.setName(sfcName);
-
-        return sfcBuilder;
+    public SfcBuilder sfcBuilder(SfcBuilder sfcBuilder, String sfcName) {
+        return sfcBuilder.setName(sfcName);
     }
 }