OpenDaylight Networking SFC Flow Classifier REST APIs 43/40843/7
authorAnil Vishnoi <vishnoianil@gmail.com>
Sat, 25 Jun 2016 03:10:14 +0000 (20:10 -0700)
committerAnil Vishnoi <vishnoianil@gmail.com>
Wed, 29 Jun 2016 23:36:45 +0000 (16:36 -0700)
This patch defines REST API's for the networking sfc flow
classifier API and implementation the translation code
to convert these REST API data to the networking-sfc
Yang models. These Neutron Northbound REST API's are defined
based on the OpenStack Networking-SFC Flow Classifier APIs
available at following URL.

http://docs.openstack.org/developer/networking-sfc/api.html#rest-api

Change-Id: Ifcdec7025715c1e9fa5f90aa9cbc475e7a1e9427
Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
13 files changed:
model/src/main/yang/neutron-sfc-flow-classifier.yang
neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSFCFlowClassifierCRUD.java [new file with mode: 0644]
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronCRUDInterfaces.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort.java
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronResourceMapPropertyAdapter.java [moved from neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFAdapter.java with 93% similarity]
neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSFCFlowClassifier.java [new file with mode: 0644]
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSFCFlowClassifierJAXBTest.java [new file with mode: 0644]
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronNorthboundRSApplication.java
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifierRequest.java [new file with mode: 0644]
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifiersNorthbound.java [new file with mode: 0644]
resources/Neutron_Northbound_SFC_Rest_and_Restconf_calls.postman_collection.json [new file with mode: 0644]
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSFCFlowClassifierInterface.java [new file with mode: 0644]
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronTranscriberProvider.java

index fa653f0c212e594454ef075763c68807badf9e06..5f43ce5c2ac4a4f99bf4a7010f971719bef18c08 100644 (file)
      }
 
      grouping sfc-flow-classifiers-attributes {
-         container flow-classifiers {
+         container sfc-flow-classifiers {
              description "Contains list of Service Function Chaining flow classifiers";
-             list flow-classifier {
+             list sfc-flow-classifier {
                  description "
                     Defines high level model of SFC Flow Classifier. This models is based on the flow classifier APIs
                     defined by OpenStack Neutron networking-sfc project.";
diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSFCFlowClassifierCRUD.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSFCFlowClassifierCRUD.java
new file mode 100644 (file)
index 0000000..f46c4f2
--- /dev/null
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, 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.neutron.spi;
+
+/**
+ * This interface defines the methods for CRUD of NB SFC Flow Classifier objects
+ *
+ */
+public interface INeutronSFCFlowClassifierCRUD extends INeutronCRUD<NeutronSFCFlowClassifier> {
+    // Nothing Here.
+    // This class is defined to use reflection.
+}
index 5a9477ee8ea4078b94a0250f76b5a47efabf4b17..f51d0e1886b247517dc1971f146b5a358d901993 100644 (file)
@@ -41,6 +41,7 @@ public class NeutronCRUDInterfaces {
     private INeutronBgpvpnCRUD bgpvpnInterface;
     private INeutronL2gatewayCRUD l2gatewayInterface;
     private INeutronL2gatewayConnectionCRUD l2gatewayConnectionInterface;
+    private INeutronSFCFlowClassifierCRUD sfcFlowClassifierInterface;
 
     public NeutronCRUDInterfaces() {
     }
@@ -141,6 +142,10 @@ public class NeutronCRUDInterfaces {
         return bgpvpnInterface;
     }
 
+    public INeutronSFCFlowClassifierCRUD getSFCFlowClassifierInterface() {
+        return sfcFlowClassifierInterface;
+    }
+
     public NeutronCRUDInterfaces fetchINeutronNetworkCRUD(Object obj) {
         networkInterface = (INeutronNetworkCRUD) getInstances(INeutronNetworkCRUD.class, obj);
         return this;
@@ -256,6 +261,12 @@ public class NeutronCRUDInterfaces {
         return this;
     }
 
+    public NeutronCRUDInterfaces fetchINeutronSFCFlowClassifierCRUD (Object obj) {
+        sfcFlowClassifierInterface =
+                (INeutronSFCFlowClassifierCRUD) getInstances(INeutronSFCFlowClassifierCRUD.class, obj);
+        return this;
+    }
+
     public Object getInstances(Class<?> clazz, Object bundle) {
         try {
             BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass()).getBundleContext();
index 80ef344bc9768b44eeae7b875d64cd8d0e43634f..540486f099fb90a74f6f81db294fc9e3280c70d5 100644 (file)
@@ -74,7 +74,7 @@ public class NeutronPort extends NeutronObject implements Serializable, INeutron
 
     //@XmlElement (name = "binding:vif_details")
     @XmlElement (namespace = "binding", name = "vif_details")
-    @XmlJavaTypeAdapter(NeutronPort_VIFAdapter.class)
+    @XmlJavaTypeAdapter(NeutronResourceMapPropertyAdapter.class)
     Map<String, String> vifDetails;
 
     @XmlElement (name = "extra_dhcp_opts")
similarity index 93%
rename from neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronPort_VIFAdapter.java
rename to neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronResourceMapPropertyAdapter.java
index 7675376cdd5a7876778eea02541d3288f5b6bde8..d748027dc093536739caf468872b9211754775e0 100644 (file)
@@ -22,9 +22,9 @@ import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
 import org.w3c.dom.Text;
 
-public class NeutronPort_VIFAdapter extends XmlAdapter<Object, Map<String, String>> {
+public class NeutronResourceMapPropertyAdapter extends XmlAdapter<Object, Map<String, String>> {
     private static final Logger LOGGER = LoggerFactory
-        .getLogger(NeutronPort_VIFAdapter.class);
+        .getLogger(NeutronResourceMapPropertyAdapter.class);
 
     @Override
     public Map<String, String> unmarshal(Object domTree) {
diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSFCFlowClassifier.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSFCFlowClassifier.java
new file mode 100644 (file)
index 0000000..28b6f00
--- /dev/null
@@ -0,0 +1,239 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, 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.neutron.spi;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.io.Serializable;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSFCFlowClassifier extends NeutronObject implements Serializable, INeutronObject {
+    private static final long serialVersionUID = 1L;
+
+    // See OpenStack Networking SFC (networking-sfc) API v1.0 Reference for description of
+    // annotated attributes
+    @XmlElement(name = "name")
+    String name;
+
+    @XmlElement(defaultValue = "IPv4", name = "ethertype")
+    String ethertype;
+
+    @XmlElement(name = "protocol")
+    String protocol;
+
+    @XmlElement(name = "source_port_range_min")
+    Integer sourcePortRangeMin;
+
+    @XmlElement(name = "source_port_range_max")
+    Integer sourcePortRangeMax;
+
+    @XmlElement(name = "destination_port_range_min")
+    Integer destinationPortRangeMin;
+
+    @XmlElement(name = "destination_port_range_max")
+    Integer destinationPortRangeMax;
+
+    @XmlElement(name = "source_ip_prefix")
+    String sourceIpPrefix;
+
+    @XmlElement(name = "destination_ip_prefix")
+    String destinationIpPrefix;
+
+    @XmlElement(name = "logical_source_port")
+    String logicalSourcePortUUID;
+
+    @XmlElement(name = "logical_destination_port")
+    String logicalDestinationPortUUID;
+
+    @XmlElement(name = "l7_parameters")
+    @XmlJavaTypeAdapter(NeutronResourceMapPropertyAdapter.class)
+    Map<String, String> l7Parameters;
+
+    public NeutronSFCFlowClassifier() {
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getEthertype() {
+        return ethertype;
+    }
+
+    public void setEthertype(String ethertype) {
+        this.ethertype = ethertype;
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
+    public Integer getSourcePortRangeMin() {
+        return sourcePortRangeMin;
+    }
+
+    public void setSourcePortRangeMin(Integer sourcePortRangeMin) {
+        this.sourcePortRangeMin = sourcePortRangeMin;
+    }
+
+    public Integer getSourcePortRangeMax() {
+        return sourcePortRangeMax;
+    }
+
+    public void setSourcePortRangeMax(Integer sourcePortRangeMax) {
+        this.sourcePortRangeMax = sourcePortRangeMax;
+    }
+
+    public Integer getDestinationPortRangeMin() {
+        return destinationPortRangeMin;
+    }
+
+    public void setDestinationPortRangeMin(Integer destinationPortRangeMin) {
+        this.destinationPortRangeMin = destinationPortRangeMin;
+    }
+
+    public Integer getDestinationPortRangeMax() {
+        return destinationPortRangeMax;
+    }
+
+    public void setDestinationPortRangeMax(Integer destinationPortRangeMax) {
+        this.destinationPortRangeMax = destinationPortRangeMax;
+    }
+
+    public String getSourceIpPrefix() {
+        return sourceIpPrefix;
+    }
+
+    public void setSourceIpPrefix(String sourceIpPrefix) {
+        this.sourceIpPrefix = sourceIpPrefix;
+    }
+
+    public String getLogicalSourcePortUUID() {
+        return logicalSourcePortUUID;
+    }
+
+    public void setLogicalSourcePortUUID(String logicalSourcePortUUID) {
+        this.logicalSourcePortUUID = logicalSourcePortUUID;
+    }
+
+    public String getDestinationIpPrefix() {
+        return destinationIpPrefix;
+    }
+
+    public void setDestinationIpPrefix(String destinationIpPrefix) {
+        this.destinationIpPrefix = destinationIpPrefix;
+    }
+
+    public String getLogicalDestinationPortUUID() {
+        return logicalDestinationPortUUID;
+    }
+
+    public void setLogicalDestinationPortUUID(String logicalDestinationPortUUID) {
+        this.logicalDestinationPortUUID = logicalDestinationPortUUID;
+    }
+
+    public Map<String, String> getL7Parameters() {
+        return l7Parameters;
+    }
+
+    public void setL7Parameters(Map<String, String> l7Parameters) {
+        this.l7Parameters = l7Parameters;
+    }
+
+    /**
+     * This method copies selected fields from the object and returns them
+     * as a new object, suitable for marshaling.
+     *
+     * @param fields List of attributes to be extracted
+     * @return an OpenStack NeutronSFCFlowClassifier object with only the selected fields
+     * populated
+     */
+
+    public NeutronSFCFlowClassifier extractFields(List<String> fields) {
+        NeutronSFCFlowClassifier ans = new NeutronSFCFlowClassifier();
+        Iterator<String> i = fields.iterator();
+        while (i.hasNext()) {
+            String s = i.next();
+            if (s.equals("id")) {
+                ans.setID(this.getID());
+            }
+            if (s.equals("tenant_id")) {
+                ans.setTenantID(this.getTenantID());
+            }
+            if (s.equals("name")) {
+                ans.setName(this.getName());
+            }
+            if (s.equals("ethertype")) {
+                ans.setEthertype(this.getEthertype());
+            }
+            if (s.equals("source_port_range_min")) {
+                ans.setSourcePortRangeMin(this.getSourcePortRangeMin());
+            }
+            if (s.equals("source_port_range_max")) {
+                ans.setSourcePortRangeMax(this.getSourcePortRangeMax());
+            }
+            if (s.equals("destination_port_range_min")) {
+                ans.setDestinationPortRangeMin(this.getDestinationPortRangeMin());
+            }
+            if (s.equals("destination_port_range_max")) {
+                ans.setDestinationPortRangeMax(this.getDestinationPortRangeMax());
+            }
+            if (s.equals("source_ip_prefix")) {
+                ans.setSourceIpPrefix(this.getSourceIpPrefix());
+            }
+            if (s.equals("destination_ip_prefix")) {
+                ans.setDestinationIpPrefix(this.getDestinationIpPrefix());
+            }
+            if (s.equals("logical_source_port")) {
+                ans.setLogicalDestinationPortUUID(this.getLogicalDestinationPortUUID());
+            }
+            if (s.equals("logical_destination_port")) {
+                ans.setLogicalDestinationPortUUID(this.getLogicalDestinationPortUUID());
+            }
+            if (s.equals("l7_parameters")) {
+                ans.setL7Parameters(new HashMap<String, String>(this.getL7Parameters()));
+            }
+        }
+        return ans;
+    }
+
+    @Override
+    public String toString() {
+        return "NeutronSFCFlowClassifier[" +
+                "name='" + name + '\'' +
+                ", ethertype='" + ethertype + '\'' +
+                ", protocol='" + protocol + '\'' +
+                ", sourcePortRangeMin=" + sourcePortRangeMin +
+                ", sourcePortRangeMax=" + sourcePortRangeMax +
+                ", destinationPortRangeMin=" + destinationPortRangeMin +
+                ", destinationPortRangeMax=" + destinationPortRangeMax +
+                ", sourceIpPrefix='" + sourceIpPrefix + '\'' +
+                ", destinationIpPrefix='" + destinationIpPrefix + '\'' +
+                ", logicalSourcePortUUID='" + logicalSourcePortUUID + '\'' +
+                ", logicalDestinationPortUUID='" + logicalDestinationPortUUID + '\'' +
+                ", l7Parameters=" + l7Parameters +
+                ']';
+    }
+}
diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSFCFlowClassifierJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSFCFlowClassifierJAXBTest.java
new file mode 100644 (file)
index 0000000..a5e9bec
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, 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.neutron.spi;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import javax.xml.bind.JAXBException;
+import java.util.Map;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 6/24/16.
+ */
+public class NeutronSFCFlowClassifierJAXBTest {
+
+    private static final String NeutronSFCFlowClassifier_sourceJson = "{ "
+            + "\"name\": \"flowclassifier1\", "
+            + "\"ethertype\": \"IPv4\", "
+            + "\"protocol\": \"UDP\", "
+            + "\"source_port_range_min\": 100, "
+            + "\"source_port_range_max\": 200, "
+            + "\"destination_port_range_min\": 100, "
+            + "\"destination_port_range_max\": 200, "
+            + "\"source_ip_prefix\": \"10.0.0.0/24\", "
+            + "\"destination_ip_prefix\": \"11.0.0.0/24\", "
+            + "\"logical_source_port\": \"5e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+            + "\"logical_destination_port\": \"6e8e5957-649f-477b-9e5b-f1f75b21c03c\", "
+            + "\"l7_parameters\": [ "
+            + "{ "
+            + "\"Key\": \"value\" "
+            + "} "
+            + "], "
+            + "\"tenant_id\": \"4969c491a3c74ee4af974e6d800c62de\", "
+            + "\"id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\" }";
+
+    @Test
+    public void test_NeutronSFCFlowClassifier_JAXB() throws JAXBException {
+        NeutronSFCFlowClassifier testObject = new NeutronSFCFlowClassifier();
+        NeutronSFCFlowClassifier neutronObject
+                = (NeutronSFCFlowClassifier) JaxbTestHelper.jaxbUnmarshall(testObject
+                , NeutronSFCFlowClassifier_sourceJson);
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 1: Testing id failed"
+                , "4e8e5957-649f-477b-9e5b-f1f75b21c03c",neutronObject.getID());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 2: Testing tenant_id failed",
+                "4969c491a3c74ee4af974e6d800c62de", neutronObject.getTenantID());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 3: Testing ethertype failed",
+                "IPv4", neutronObject.getEthertype());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 4: Testing protocol failed",
+                "UDP", neutronObject.getProtocol());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 5: Testing source_port_range_min failed",
+                new Integer(100), neutronObject.getSourcePortRangeMin());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 6: Testing source_port_range_max failed",
+                new Integer(200), neutronObject.getSourcePortRangeMax());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 7: Testing destination_port_range_min failed",
+                new Integer(100), neutronObject.getDestinationPortRangeMin());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 8: Testing destination_port_range_max failed",
+                new Integer(200), neutronObject.getDestinationPortRangeMax());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 9: Testing source_ip_prefix failed",
+                "10.0.0.0/24", neutronObject.getSourceIpPrefix());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 10: Testing destination_ip_prefix failed",
+                "11.0.0.0/24", neutronObject.getDestinationIpPrefix());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 11: Testing logical_source_port failed",
+                "5e8e5957-649f-477b-9e5b-f1f75b21c03c", neutronObject.getLogicalSourcePortUUID());
+
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 12: Testing logical_destination_port failed",
+                "6e8e5957-649f-477b-9e5b-f1f75b21c03c", neutronObject.getLogicalDestinationPortUUID());
+
+        Map<String, String> l7Param = neutronObject.getL7Parameters();
+        Assert.assertEquals("NeutronSFCFlowClassifier JAXB Test 13: Testing L7_parameters list length failed", 1,
+                l7Param.size());
+    }
+}
index a5b7acd6139edde37251380f4e61581ed15084f0..718095e2d0041ca0161a291dcd4de108ab16b912 100644 (file)
@@ -53,6 +53,7 @@ public class NeutronNorthboundRSApplication extends Application {
         classes.add(NeutronBgpvpnsNorthbound.class);
         classes.add(NeutronL2gatewayNorthbound.class);
         classes.add(NeutronL2gatewayConnectionNorthbound.class);
+        classes.add(NeutronSFCFlowClassifiersNorthbound.class);
 
       classes.add(MOXyJsonProvider.class);
         return classes;
diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifierRequest.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifierRequest.java
new file mode 100644 (file)
index 0000000..9740bc2
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, 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.neutron.northbound.api;
+
+import org.opendaylight.neutron.spi.NeutronSFCFlowClassifier;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.List;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSFCFlowClassifierRequest implements INeutronRequest<NeutronSFCFlowClassifier> {
+
+    // See OpenStack Networking SFC (networking-sfc) API v1.0 Reference for description of
+    // annotated attributes
+
+    @XmlElement(name="flowclassifier")
+    NeutronSFCFlowClassifier singletonSFCFlowClassifier;
+
+    @XmlElement(name="flowclassifiers")
+    List<NeutronSFCFlowClassifier> bulkRequest;
+
+    NeutronSFCFlowClassifierRequest() {
+    }
+
+    NeutronSFCFlowClassifierRequest(List<NeutronSFCFlowClassifier> bulkRequest) {
+        this.bulkRequest = bulkRequest;
+        this.singletonSFCFlowClassifier = null;
+    }
+
+    NeutronSFCFlowClassifierRequest(NeutronSFCFlowClassifier sfcFlowClassifier) {
+        this.singletonSFCFlowClassifier = sfcFlowClassifier;
+    }
+
+    @Override
+    public NeutronSFCFlowClassifier getSingleton() {
+        return this.singletonSFCFlowClassifier;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return singletonSFCFlowClassifier != null;
+    }
+
+    @Override
+    public List<NeutronSFCFlowClassifier> getBulk() {
+        return this.bulkRequest;
+    }
+}
diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifiersNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCFlowClassifiersNorthbound.java
new file mode 100644 (file)
index 0000000..9d251ad
--- /dev/null
@@ -0,0 +1,215 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, 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.neutron.northbound.api;
+
+import org.codehaus.enunciate.jaxrs.ResponseCode;
+import org.codehaus.enunciate.jaxrs.StatusCodes;
+import org.codehaus.enunciate.jaxrs.TypeHint;
+import org.opendaylight.neutron.spi.INeutronSFCFlowClassifierCRUD;
+import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
+import org.opendaylight.neutron.spi.NeutronSFCFlowClassifier;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import java.net.HttpURLConnection;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * Neutron Northbound REST APIs for OpenStack SFC Flow Classifier.<br>
+ * This class provides REST APIs for managing OpenStack SFC Flow Classifier
+ *
+ * <br>
+ * <br>
+ * Authentication scheme : <b>HTTP Basic</b><br>
+ * Authentication realm : <b>opendaylight</b><br>
+ * Transport : <b>HTTP and HTTPS</b><br>
+ * <br>
+ * HTTPS Authentication is disabled by default. Administrator can enable it in
+ * tomcat-server.xml after adding a proper keystore / SSL certificate from a
+ * trusted authority.<br>
+ * More info :
+ * http://tomcat.apache.org/tomcat-7.0-doc/ssl-howto.html#Configuration
+ *
+ */
+
+@Path("/sfc/flowclassifiers")
+public class NeutronSFCFlowClassifiersNorthbound
+        extends AbstractNeutronNorthbound<NeutronSFCFlowClassifier,
+        NeutronSFCFlowClassifierRequest,INeutronSFCFlowClassifierCRUD>{
+    private static final String RESOURCE_NAME = "Sfc Flow Classifier";
+
+    @Override
+    protected String getResourceName() {
+        return RESOURCE_NAME;
+    }
+
+    @Override
+    protected NeutronSFCFlowClassifier extractFields(NeutronSFCFlowClassifier o, List<String> fields) {
+        return o.extractFields(fields);
+    }
+
+    @Override
+    protected NeutronSFCFlowClassifierRequest newNeutronRequest(NeutronSFCFlowClassifier o) {
+        return new NeutronSFCFlowClassifierRequest(o);
+    }
+
+    @Override
+    protected INeutronSFCFlowClassifierCRUD getNeutronCRUD() {
+        NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCFlowClassifierCRUD(this);
+        if (answer.getSFCFlowClassifierInterface() == null) {
+            throw new ServiceUnavailableException(serviceUnavailable());
+        }
+        return answer.getSFCFlowClassifierInterface();
+    }
+
+    /**
+     * Returns a list of all SFC Flow Classifiers */
+
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON })
+    @StatusCodes({
+            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+    public Response listSFCFlowClassifiers(
+            // return fields
+            @QueryParam("fields") List<String> fields,
+            // note: openstack isn't clear about filtering on lists, so we aren't handling them
+            @QueryParam("id") String queryID,
+            @QueryParam("name") String queryName,
+            @QueryParam("ethertype") String queryEthertype,
+            @QueryParam("protocol") String queryProtocol,
+            @QueryParam("source_port_range_min") Integer querySourcePortRangeMin,
+            @QueryParam("source_port_range_max") Integer querySourcePortRangeMax,
+            @QueryParam("tenant_id") String queryTenantID,
+            @QueryParam("destination_port_range_min") Integer queryDestinationPortRangeMin,
+            @QueryParam("destination_port_range_max") Integer queryDestinationPortRangeMax,
+            @QueryParam("source_ip_prefix") String querySourceIpPrefix,
+            @QueryParam("destination_ip_prefix") String queryDestinationIpPrefix,
+            @QueryParam("logical_source_port") String queryLogicalSourcePort,
+            @QueryParam("logical_destination_port") String queryLogicalDestinationPort
+    ) {
+        INeutronSFCFlowClassifierCRUD sfcFlowClassifierInterface = getNeutronCRUD();
+        List<NeutronSFCFlowClassifier> allSFCFlowClassifier = sfcFlowClassifierInterface.getAll();
+        List<NeutronSFCFlowClassifier> ans = new ArrayList<>();
+        Iterator<NeutronSFCFlowClassifier> i = allSFCFlowClassifier.iterator();
+        while (i.hasNext()) {
+            NeutronSFCFlowClassifier oSFC = i.next();
+            if ((queryID == null || queryID.equals(oSFC.getID())) &&
+                    (queryName == null || queryName.equals(oSFC.getName())) &&
+                    (queryEthertype == null || queryEthertype.equals(oSFC.getEthertype())) &&
+                    (queryProtocol == null || queryProtocol.equals(oSFC.getProtocol())) &&
+                    (querySourcePortRangeMin == null || querySourcePortRangeMin.equals(oSFC.getSourcePortRangeMin())) &&
+                    (querySourcePortRangeMax == null || querySourcePortRangeMax.equals(oSFC.getSourcePortRangeMax())) &&
+                    (queryDestinationPortRangeMin == null
+                            || queryDestinationPortRangeMin.equals(oSFC.getDestinationPortRangeMin())) &&
+                    (queryDestinationPortRangeMax == null
+                            || queryDestinationPortRangeMax.equals(oSFC.getDestinationPortRangeMax())) &&
+                    (querySourceIpPrefix == null || querySourceIpPrefix.equals(oSFC.getSourceIpPrefix())) &&
+                    (queryDestinationIpPrefix == null || queryDestinationIpPrefix.equals(oSFC.getDestinationIpPrefix())) &&
+                    (queryLogicalSourcePort == null || queryLogicalSourcePort.equals(oSFC.getLogicalSourcePortUUID())) &&
+                    (queryLogicalDestinationPort == null || queryLogicalDestinationPort.equals(oSFC.getLogicalDestinationPortUUID())) &&
+                    (queryTenantID == null || queryTenantID.equals(oSFC.getTenantID()))) {
+                if (fields.size() > 0) {
+                    ans.add(extractFields(oSFC,fields));
+                } else {
+                    ans.add(oSFC);
+                }
+            }
+        }
+
+        return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronSFCFlowClassifierRequest(ans)).build();
+
+    }
+
+    /**
+     * Returns a specific SFC Flow Classifier */
+
+    @Path("{flowClassifierUUID}")
+    @GET
+    @Produces({ MediaType.APPLICATION_JSON })
+    @StatusCodes({
+            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAUTHORIZED, condition = "Unauthorized"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_IMPLEMENTED, condition = "Not Implemented"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+    public Response showSFCFlowClassifier(
+            @PathParam("flowClassifierUUID") String sfcFlowClassifierUUID,
+            // return fields
+            @QueryParam("fields") List<String> fields
+    ) {
+        return show(sfcFlowClassifierUUID, fields);
+    }
+
+    /**
+     * Creates new SFC Flow Classifier */
+    @POST
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @StatusCodes({
+            @ResponseCode(code = HttpURLConnection.HTTP_CREATED, condition = "Created"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+    public Response createSFCFlowClassifier(final NeutronSFCFlowClassifierRequest input) {
+        return create(input);
+    }
+
+    @Override
+    protected void updateDelta(String uuid, NeutronSFCFlowClassifier delta, NeutronSFCFlowClassifier original) {
+        /*
+         *  note: what we get appears to not be a delta but
+         * rather an incomplete updated object.  So we need to set
+         * the ID to complete the object and then send that down
+         * for folks to check
+         */
+
+        delta.setID(uuid);
+        delta.setTenantID(original.getTenantID());
+    }
+
+    /**
+     * Updates an existing SFC Flow Classifier */
+    @Path("{flowClassifierUUID}")
+    @PUT
+    @Produces({ MediaType.APPLICATION_JSON })
+    @Consumes({ MediaType.APPLICATION_JSON })
+    @StatusCodes({
+            @ResponseCode(code = HttpURLConnection.HTTP_OK, condition = "Operation successful"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+    public Response updateSFCFlowClassifier(
+            @PathParam("flowClassifierUUID") String sfcFlowClassifierUUID, final NeutronSFCFlowClassifierRequest input
+    ) {
+        return update(sfcFlowClassifierUUID, input);
+    }
+
+    /**
+     * Deletes the SFC Flow Classifier */
+    @Path("{flowClassifierUUID}")
+    @DELETE
+    @StatusCodes({
+            @ResponseCode(code = HttpURLConnection.HTTP_NO_CONTENT, condition = "No Content"),
+            @ResponseCode(code = HttpURLConnection.HTTP_NOT_FOUND, condition = "Not Found"),
+            @ResponseCode(code = HttpURLConnection.HTTP_UNAVAILABLE, condition = "No providers available") })
+    public Response deleteSFCFlowClassifier(
+            @PathParam("flowClassifierUUID") String sfcFlowClassifierUUID) {
+        return delete(sfcFlowClassifierUUID);
+    }
+}
diff --git a/resources/Neutron_Northbound_SFC_Rest_and_Restconf_calls.postman_collection.json b/resources/Neutron_Northbound_SFC_Rest_and_Restconf_calls.postman_collection.json
new file mode 100644 (file)
index 0000000..7444286
--- /dev/null
@@ -0,0 +1,109 @@
+{
+       "id": "bd69cf69-88f9-1294-33f2-8579727f07a7",
+       "name": "Neutron-Northbound-SFC-Rest-and-Restconf-calls",
+       "description": "",
+       "order": [
+               "11ff4e31-5708-d346-b8a2-d6cb6e838693",
+               "bb773371-1f84-bd3d-3754-9e9d43f68cfc",
+               "909e053e-a877-1594-1929-9ccb8f1a517a",
+               "2950721e-bc1a-6cde-1322-a4ce974aec55"
+       ],
+       "folders": [],
+       "timestamp": 1466797738971,
+       "owner": "128022",
+       "remoteLink": "",
+       "public": false,
+       "published": false,
+       "requests": [
+               {
+                       "id": "11ff4e31-5708-d346-b8a2-d6cb6e838693",
+                       "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+                       "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/flowclassifiers/",
+                       "preRequestScript": "",
+                       "pathVariables": {},
+                       "method": "POST",
+                       "data": [],
+                       "dataMode": "raw",
+                       "version": 2,
+                       "tests": "",
+                       "currentHelper": "basicAuth",
+                       "helperAttributes": {
+                               "id": "basic",
+                               "username": "admin",
+                               "password": "admin",
+                               "saveToRequest": true
+                       },
+                       "time": 1466891330305,
+                       "name": "Create Flow Classifier (non-MDSAL)",
+                       "description": "This REST call create flow classifier using the handcrafted REST API (not through the RESTCONF yang based modles).",
+                       "collectionId": "bd69cf69-88f9-1294-33f2-8579727f07a7",
+                       "responses": [],
+                       "rawModeData": "{\n    \"flowclassifier\":{\n    \"id\": \"444e5957-649f-477b-9e5b-f1f75b21c03c\",\n    \"name\": \"fc1\", \n    \"ethertype\": \"IPv4\", \n    \"protocol\": \"UDP\", \n    \"source_port_range_min\": 100, \n    \"source_port_range_max\": 200, \n    \"destination_port_range_min\": 100, \n    \"destination_port_range_max\": 200, \n    \"source_ip_prefix\": \"10.0.0.0/24\", \n    \"destination_ip_prefix\": \"11.0.0.0/24\", \n    \"logical_source_port\": \"5e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"logical_destination_port\": \"6e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"l7_parameters\": [\n        {\n            \"key\":\"value\"\n        }\n     ],\n     \"tenant_id\":\"4969c491a3c74ee4af974e6d800c62de\"\n    }\n\n}"
+               },
+               {
+                       "id": "2950721e-bc1a-6cde-1322-a4ce974aec55",
+                       "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+                       "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/flowclassifiers/",
+                       "pathVariables": {},
+                       "preRequestScript": "",
+                       "method": "GET",
+                       "collectionId": "bd69cf69-88f9-1294-33f2-8579727f07a7",
+                       "data": [],
+                       "dataMode": "raw",
+                       "name": "All Flow Classifier Data (non-MDSAL)",
+                       "description": "This REST call fetch all flow classifier data  using the handcrafted REST API (not through the RESTCONF yang based modles).",
+                       "descriptionFormat": "html",
+                       "time": 1466891619190,
+                       "version": 2,
+                       "responses": [],
+                       "tests": "",
+                       "currentHelper": "basicAuth",
+                       "helperAttributes": {
+                               "id": "basic",
+                               "username": "admin",
+                               "password": "admin",
+                               "saveToRequest": true
+                       },
+                       "rawModeData": "{\n    \"flowclassifier\":{\n    \"id\": \"444e5957-649f-477b-9e5b-f1f75b21c03c\",\n    \"name\": \"fc1\", \n    \"ethertype\": \"IPv4\", \n    \"protocol\": \"UDP\", \n    \"source_port_range_min\": 100, \n    \"source_port_range_max\": 200, \n    \"destination_port_range_min\": 100, \n    \"destination_port_range_max\": 200, \n    \"source_ip_prefix\": \"10.0.0.0/24\", \n    \"destination_ip_prefix\": \"11.0.0.0/24\", \n    \"logical_source_port\": \"5e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"logical_destination_port\": \"6e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"l7_parameters\": [\n        {\n            \"key\":\"value\"\n        }\n     ],\n     \"tenant_id\":\"4969c491a3c74ee4af974e6d800c62de\"\n    }\n\n}"
+               },
+               {
+                       "id": "909e053e-a877-1594-1929-9ccb8f1a517a",
+                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
+                       "url": "http://localhost:8181/restconf/config/neutron:neutron/sfc-flow-classifiers/sfc-flow-classifier/444e5957-649f-477b-9e5b-f1f75b21c03c",
+                       "pathVariables": {},
+                       "preRequestScript": "",
+                       "method": "GET",
+                       "collectionId": "bd69cf69-88f9-1294-33f2-8579727f07a7",
+                       "data": [],
+                       "dataMode": "params",
+                       "name": "Specific FlowClassifier Data from MDSAL",
+                       "description": "Fetch specific SFC Flow Classifier data from the MD-SAL Data Store using the MD-SAL RESTCONF URL. This restconf call can be used to verify that the SFC flow classifier created through handcrafted REST request is indeed present in the MD-SAL Data store.",
+                       "descriptionFormat": "html",
+                       "time": 1466891306497,
+                       "version": 2,
+                       "responses": [],
+                       "tests": "",
+                       "currentHelper": "normal",
+                       "helperAttributes": {}
+               },
+               {
+                       "id": "bb773371-1f84-bd3d-3754-9e9d43f68cfc",
+                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
+                       "url": "http://localhost:8181/restconf/config/neutron:neutron/sfc-flow-classifiers/",
+                       "preRequestScript": "",
+                       "pathVariables": {},
+                       "method": "GET",
+                       "data": [],
+                       "dataMode": "params",
+                       "version": 2,
+                       "tests": "",
+                       "currentHelper": "normal",
+                       "helperAttributes": {},
+                       "time": 1466891257026,
+                       "name": "All FlowClassifier Data from MDSAL",
+                       "description": "Fetch SFC Flow Classifier data from the MD-SAL Data Store using the MD-SAL RESTCONF URL. This restconf call can be used to verify that the SFC flow classifier created through handcrafted REST request is indeed present in the MD-SAL Data store.  ",
+                       "collectionId": "bd69cf69-88f9-1294-33f2-8579727f07a7",
+                       "responses": []
+               }
+       ]
+}
\ No newline at end of file
diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSFCFlowClassifierInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSFCFlowClassifierInterface.java
new file mode 100644 (file)
index 0000000..2a22585
--- /dev/null
@@ -0,0 +1,199 @@
+/*
+ * Copyright (c) 2016 Brocade Communications Systems, 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.neutron.transcriber;
+
+import com.google.common.collect.ImmutableBiMap;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.neutron.spi.INeutronSFCFlowClassifierCRUD;
+import org.opendaylight.neutron.spi.NeutronSFCFlowClassifier;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.EthertypeV6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolBase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolUdp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.flow.classifier.match.attributes.L7Parameter;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.flow.classifier.match.attributes.L7ParameterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.flow.classifier.match.attributes.L7ParameterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.SfcFlowClassifiers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifier;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.flow.classifier.rev160511.sfc.flow.classifiers.attributes.sfc.flow.classifiers.SfcFlowClassifierBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com) on 6/24/16.
+ */
+public class NeutronSFCFlowClassifierInterface
+        extends AbstractNeutronInterface<SfcFlowClassifier, SfcFlowClassifiers, NeutronSFCFlowClassifier>
+        implements INeutronSFCFlowClassifierCRUD {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSFCFlowClassifierInterface.class);
+
+    private static final ImmutableBiMap<Class<? extends EthertypeBase>,String> ETHERTYPE_MAP
+            = new ImmutableBiMap.Builder<Class<? extends EthertypeBase>,String>()
+            .put(EthertypeV4.class,"IPv4")
+            .put(EthertypeV6.class,"IPv6")
+            .build();
+
+    private static final ImmutableBiMap<Class<? extends ProtocolBase>,String> PROTOCOL_MAP
+            = new ImmutableBiMap.Builder<Class<? extends ProtocolBase>,String>()
+            .put(ProtocolTcp.class,"TCP")
+            .put(ProtocolUdp.class,"UDP")
+            .put(ProtocolIcmp.class,"ICMP")
+            .build();
+
+    NeutronSFCFlowClassifierInterface(DataBroker db) {
+        super(db);
+    }
+
+    @Override
+    protected List<SfcFlowClassifier> getDataObjectList(SfcFlowClassifiers dataObjects) {
+        return dataObjects.getSfcFlowClassifier();
+    }
+
+    @Override
+    protected InstanceIdentifier<SfcFlowClassifier> createInstanceIdentifier(SfcFlowClassifier classifier) {
+        return InstanceIdentifier.create(Neutron.class).child(SfcFlowClassifiers.class)
+                .child(SfcFlowClassifier.class, classifier.getKey());
+    }
+
+    @Override
+    protected InstanceIdentifier<SfcFlowClassifiers> createInstanceIdentifier() {
+        return InstanceIdentifier.create(Neutron.class).child(SfcFlowClassifiers.class);
+    }
+
+    @Override
+    protected SfcFlowClassifier toMd(NeutronSFCFlowClassifier neutronClassifier) {
+
+        LOGGER.trace("toMd: REST SFC Flow Classifier data : {}", neutronClassifier);
+
+        SfcFlowClassifierBuilder result = new SfcFlowClassifierBuilder();
+        if(neutronClassifier.getID() != null) {
+            result.setUuid(new Uuid(neutronClassifier.getID()));
+        }
+        if(neutronClassifier.getName() != null) {
+            result.setName(neutronClassifier.getName());
+        }
+        if(neutronClassifier.getTenantID() != null) {
+            result.setTenantId(toUuid(neutronClassifier.getTenantID()));
+        }
+        if(neutronClassifier.getEthertype() != null) {
+            final ImmutableBiMap<String, Class<? extends EthertypeBase>> mapper =
+                    ETHERTYPE_MAP.inverse();
+
+            result.setEthertype(mapper.get(neutronClassifier.getEthertype()));
+        }
+        if(neutronClassifier.getProtocol() != null) {
+            final ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
+                    PROTOCOL_MAP.inverse();
+            result.setProtocol(mapper.get(neutronClassifier.getProtocol()));
+        }
+        if(neutronClassifier.getSourcePortRangeMin() != null) {
+            result.setSourcePortRangeMin(neutronClassifier.getSourcePortRangeMin());
+        }
+        if(neutronClassifier.getSourcePortRangeMax() != null) {
+            result.setSourcePortRangeMax(neutronClassifier.getSourcePortRangeMax());
+        }
+        if(neutronClassifier.getDestinationPortRangeMin() != null) {
+            result.setDestinationPortRangeMin(neutronClassifier.getDestinationPortRangeMin());
+        }
+        if(neutronClassifier.getDestinationPortRangeMax() != null) {
+            result.setDestinationPortRangeMax(neutronClassifier.getDestinationPortRangeMax());
+        }
+        if(neutronClassifier.getSourceIpPrefix() != null) {
+            result.setSourceIpPrefix(new IpPrefix(neutronClassifier.getSourceIpPrefix().toCharArray()));
+        }
+        if(neutronClassifier.getDestinationIpPrefix() != null) {
+            result.setDestinationIpPrefix(new IpPrefix(neutronClassifier.getDestinationIpPrefix().toCharArray()));
+        }
+        if(neutronClassifier.getLogicalSourcePortUUID() !=null ) {
+            result.setLogicalSourcePort(new Uuid(neutronClassifier.getLogicalSourcePortUUID()));
+        }
+        if(neutronClassifier.getLogicalDestinationPortUUID() != null) {
+            result.setLogicalDestinationPort(new Uuid(neutronClassifier.getLogicalDestinationPortUUID()));
+        }
+        if(neutronClassifier.getL7Parameters()!= null) {
+            List<L7Parameter> l7Params = new ArrayList<>();
+            for(String paramKey : neutronClassifier.getL7Parameters().keySet()) {
+                L7ParameterBuilder param = new L7ParameterBuilder();
+                param.setKey(new L7ParameterKey(paramKey));
+                param.setMatchParameter(paramKey);
+                param.setMatchParameterValue(neutronClassifier.getL7Parameters().get(paramKey));
+                l7Params.add(param.build());
+            }
+            result.setL7Parameter(l7Params);
+        }
+        LOGGER.trace("toMd: Yang SFC Flow Classifier data : {}", result);
+        return result.build();
+    }
+
+    @Override
+    protected SfcFlowClassifier toMd(String uuid) {
+        final SfcFlowClassifierBuilder sfcFlowClassifierBuilder = new SfcFlowClassifierBuilder();
+        sfcFlowClassifierBuilder.setUuid(toUuid(uuid));
+        return sfcFlowClassifierBuilder.build();
+    }
+
+    @Override
+    protected NeutronSFCFlowClassifier fromMd(SfcFlowClassifier mdClassifier) {
+        LOGGER.trace("fromMd: Yang SFC flow classifier data : {}", mdClassifier);
+        NeutronSFCFlowClassifier result = new NeutronSFCFlowClassifier();
+        result.setID(mdClassifier.getUuid().getValue());
+        result.setName(mdClassifier.getName());
+        result.setTenantID(mdClassifier.getTenantId());
+        if(mdClassifier.getEthertype() != null) {
+            result.setEthertype(ETHERTYPE_MAP.get(mdClassifier.getEthertype()));
+        }
+        if(mdClassifier.getProtocol() != null) {
+            result.setProtocol(PROTOCOL_MAP.get(mdClassifier.getProtocol()));
+        }
+        if(mdClassifier.getSourcePortRangeMin() != null) {
+            result.setSourcePortRangeMin(mdClassifier.getSourcePortRangeMin());
+        }
+        if(mdClassifier.getSourcePortRangeMax() != null) {
+            result.setSourcePortRangeMax(mdClassifier.getSourcePortRangeMax());
+        }
+        if(mdClassifier.getDestinationPortRangeMin() != null) {
+            result.setDestinationPortRangeMin(mdClassifier.getDestinationPortRangeMin());
+        }
+        if(mdClassifier.getDestinationPortRangeMax() != null) {
+            result.setDestinationPortRangeMax(mdClassifier.getDestinationPortRangeMax());
+        }
+        if(mdClassifier.getSourceIpPrefix() != null) {
+            result.setSourceIpPrefix(String.valueOf(mdClassifier.getSourceIpPrefix().getValue()));
+        }
+        if(mdClassifier.getDestinationIpPrefix() != null) {
+            result.setDestinationIpPrefix(String.valueOf(mdClassifier.getDestinationIpPrefix()));
+        }
+        if(mdClassifier.getLogicalSourcePort() !=null ) {
+            result.setLogicalSourcePortUUID(mdClassifier.getLogicalSourcePort().getValue());
+        }
+        if(mdClassifier.getLogicalDestinationPort() != null) {
+            result.setLogicalDestinationPortUUID(mdClassifier.getLogicalDestinationPort().getValue());
+        }
+        if(mdClassifier.getL7Parameter()!= null) {
+            HashMap<String, String> l7Param = new HashMap<>();
+            for(L7Parameter param : mdClassifier.getL7Parameter()) {
+                l7Param.put(param.getMatchParameter(),param.getMatchParameterValue());
+            }
+            result.setL7Parameters(l7Param);
+        }
+        LOGGER.trace("fromMd: REST SFC Flow Classifier data : {}", result);
+        return result;
+    }
+}
index fd81da6c998d7e26858fd4a37aec55b461ab0da0..11631dd2e60fb1682f9824de0a3bae9e5eac7273 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.neutron.spi.INeutronMeteringLabelRuleCRUD;
 import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
 import org.opendaylight.neutron.spi.INeutronPortCRUD;
 import org.opendaylight.neutron.spi.INeutronRouterCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCFlowClassifierCRUD;
 import org.opendaylight.neutron.spi.INeutronSecurityGroupCRUD;
 import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
 import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
@@ -75,6 +76,7 @@ public class NeutronTranscriberProvider
     private NeutronVPNIPSECPolicyInterface vPNIPSECPolicyInterface;
     private NeutronVPNIPSECSiteConnectionsInterface vPNIPSECSiteConnectionsInterface;
     private NeutronVPNServiceInterface vPNServiceInterface;
+    private NeutronSFCFlowClassifierInterface sfcFlowClassifierInterface;
 
     public NeutronTranscriberProvider(BundleContext context, DataBroker db) {
         LOGGER.debug("DataBroker set to: {}", db);
@@ -160,6 +162,9 @@ public class NeutronTranscriberProvider
         vPNServiceInterface = new NeutronVPNServiceInterface(db);
         registerCRUDInterface(INeutronVPNServiceCRUD.class, vPNServiceInterface);
 
+        sfcFlowClassifierInterface = new NeutronSFCFlowClassifierInterface(db);
+        registerCRUDInterface(INeutronSFCFlowClassifierCRUD.class,sfcFlowClassifierInterface);
+
         // We don't need context any more
         this.context = null;
     }