OpenDaylight Networking SFC Port Pair Group REST APIs 47/40847/9
authorAnil Vishnoi <vishnoianil@gmail.com>
Sun, 26 Jun 2016 23:10:56 +0000 (16:10 -0700)
committerAnil Vishnoi <vishnoianil@gmail.com>
Thu, 30 Jun 2016 22:56:31 +0000 (22:56 +0000)
This patch defines REST API's in Neutron Northbound project
for the networking sfc port pair group APIs and implementation of
the translation code to convert these REST API data to the
networking-sfc port pair group Yang models. These Neutron
Northbound REST API's are defined based on the OpenStack
Networking-SFC Port Pair Group APIs available at following URL.

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

Signed-off-by: Anil Vishnoi <vishnoianil@gmail.com>
Change-Id: Ib25544b711873983be7733ec552328220fd8a85d

neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSFCPortPairGroupCRUD.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/NeutronSFCPortPairGroup.java [new file with mode: 0644]
neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSFCPortPairGroupJAXBTest.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/NeutronSFCPortPairGroupRequest.java [new file with mode: 0644]
northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairGroupsNorthbound.java [new file with mode: 0644]
resources/Neutron_Northbound_SFC_Rest_and_Restconf_calls.postman_collection.json
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSFCPortPairGroupInterface.java [new file with mode: 0644]
transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronTranscriberProvider.java

diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSFCPortPairGroupCRUD.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/INeutronSFCPortPairGroupCRUD.java
new file mode 100644 (file)
index 0000000..81453fa
--- /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 Port Pair Group objects
+ *
+ */
+public interface INeutronSFCPortPairGroupCRUD extends INeutronCRUD<NeutronSFCPortPairGroup> {
+    // Nothing Here.
+    // This class is defined to use reflection.
+}
index a91750b7a43aa676fd03b4a8118d096bc28d554c..53e48710c283073c672221566713bdbddfe5a779 100644 (file)
@@ -43,6 +43,7 @@ public class NeutronCRUDInterfaces {
     private INeutronL2gatewayConnectionCRUD l2gatewayConnectionInterface;
     private INeutronSFCFlowClassifierCRUD sfcFlowClassifierInterface;
     private INeutronSFCPortPairCRUD sfcPortPairInterface;
+    private INeutronSFCPortPairGroupCRUD sfcPortPairGroupInterface;
 
     public NeutronCRUDInterfaces() {
     }
@@ -151,6 +152,10 @@ public class NeutronCRUDInterfaces {
         return sfcPortPairInterface;
     }
 
+    public INeutronSFCPortPairGroupCRUD getSFCPortPairGroupInterface() {
+        return sfcPortPairGroupInterface;
+    }
+
     public NeutronCRUDInterfaces fetchINeutronNetworkCRUD(Object obj) {
         networkInterface = (INeutronNetworkCRUD) getInstances(INeutronNetworkCRUD.class, obj);
         return this;
@@ -278,6 +283,12 @@ public class NeutronCRUDInterfaces {
         return this;
     }
 
+    public NeutronCRUDInterfaces fetchINeutronSFCPortPairGroupCRUD (Object obj) {
+        sfcPortPairGroupInterface =
+                (INeutronSFCPortPairGroupCRUD) getInstances(INeutronSFCPortPairGroupCRUD.class, obj);
+        return this;
+    }
+
     public Object getInstances(Class<?> clazz, Object bundle) {
         try {
             BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass()).getBundleContext();
diff --git a/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSFCPortPairGroup.java b/neutron-spi/src/main/java/org/opendaylight/neutron/spi/NeutronSFCPortPairGroup.java
new file mode 100644 (file)
index 0000000..0b3e765
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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 java.io.Serializable;
+import java.util.Iterator;
+import java.util.List;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSFCPortPairGroup extends NeutronObject implements Serializable, INeutronObject {
+    private static final long serialVersionUID = 1L;
+
+    // See OpenStack Networking SFC (networking-sfc) Port Pair Group API v1.0
+    // Reference for description of annotated attributes
+
+    @XmlElement(name = "name")
+    String name;
+
+    @XmlElement(name = "port_pairs")
+    List<String> portPairs;
+
+    public NeutronSFCPortPairGroup() {
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public List<String> getPortPairs() {
+        return portPairs;
+    }
+
+    public void setPortPairs(List<String> portPairs) {
+        this.portPairs = portPairs;
+    }
+
+    /**
+     * 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 Neutron SFC Port Pair Group object with only the selected fields
+     * populated
+     */
+
+    public NeutronSFCPortPairGroup extractFields(List<String> fields) {
+        NeutronSFCPortPairGroup ans = new NeutronSFCPortPairGroup();
+        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("port_pairs")) {
+                ans.setPortPairs(this.getPortPairs());
+            }
+        }
+        return ans;
+    }
+
+    @Override
+    public String toString() {
+        return "NeutronSFCPortPairGroup[" +
+                "tenantID='" + tenantID + '\'' +
+                ", name='" + name + '\'' +
+                ", portPairs=" + portPairs +
+                ']';
+    }
+}
diff --git a/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSFCPortPairGroupJAXBTest.java b/neutron-spi/src/test/java/org/opendaylight/neutron/spi/NeutronSFCPortPairGroupJAXBTest.java
new file mode 100644 (file)
index 0000000..8665c90
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com)
+ */
+public class NeutronSFCPortPairGroupJAXBTest {
+    private static final String NeutronSFCPortPairGroup_sourceJson = "{ "
+            + "\"name\": \"portpair1\", "
+            + "\"port_pairs\": [ "
+            + "\"d11e9190-73d4-11e5-b392-2c27d72acb4c\""
+            + "], "
+            + "\"tenant_id\": \"4969c491a3c74ee4af974e6d800c62de\", "
+            + "\"id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\" }";
+
+    @Test
+    public void test_NeutronSFCPortPairGroup_JAXB() throws JAXBException {
+        NeutronSFCPortPairGroup testObject = new NeutronSFCPortPairGroup();
+        NeutronSFCPortPairGroup neutronObject
+                = (NeutronSFCPortPairGroup) JaxbTestHelper.jaxbUnmarshall(testObject
+                , NeutronSFCPortPairGroup_sourceJson);
+
+        Assert.assertEquals("NeutronSFCPortPairGroup JAXB Test 1: Testing id failed"
+                , "4e8e5957-649f-477b-9e5b-f1f75b21c03c",neutronObject.getID());
+
+        Assert.assertEquals("NeutronSFCPortPairGroup JAXB Test 2: Testing tenant_id failed",
+                "4969c491a3c74ee4af974e6d800c62de", neutronObject.getTenantID());
+
+        Assert.assertEquals("NeutronSFCPortPairGroup JAXB Test 3: Testing port_pairs failed",
+                "d11e9190-73d4-11e5-b392-2c27d72acb4c", neutronObject.getPortPairs().get(0));
+    }
+}
index 0f80fe8143cc34b04ffa9cd9882278b0bc051139..5b69e3af854dade00f52b9ba359a93e0330c57e3 100644 (file)
@@ -55,6 +55,7 @@ public class NeutronNorthboundRSApplication extends Application {
         classes.add(NeutronL2gatewayConnectionNorthbound.class);
         classes.add(NeutronSFCFlowClassifiersNorthbound.class);
         classes.add(NeutronSFCPortPairsNorthbound.class);
+        classes.add(NeutronSFCPortPairGroupsNorthbound.class);
 
       classes.add(MOXyJsonProvider.class);
         return classes;
diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairGroupRequest.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairGroupRequest.java
new file mode 100644 (file)
index 0000000..37f6781
--- /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.NeutronSFCPortPairGroup;
+
+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 NeutronSFCPortPairGroupRequest implements INeutronRequest<NeutronSFCPortPairGroup> {
+    // See OpenStack Networking SFC (networking-sfc) Port Pair Group API v1.0 Reference
+    // for description of annotated attributes
+
+    @XmlElement(name="portpairgroup")
+    NeutronSFCPortPairGroup singletonPortPairGroup;
+
+    @XmlElement(name="portpairgroups")
+    List<NeutronSFCPortPairGroup> bulkRequest;
+
+    NeutronSFCPortPairGroupRequest() {
+    }
+
+    NeutronSFCPortPairGroupRequest(List<NeutronSFCPortPairGroup> bulkRequest) {
+        this.bulkRequest = bulkRequest;
+        this.singletonPortPairGroup = null;
+    }
+
+    NeutronSFCPortPairGroupRequest(NeutronSFCPortPairGroup sfcPortPair) {
+        this.singletonPortPairGroup = sfcPortPair;
+    }
+
+    @Override
+    public NeutronSFCPortPairGroup getSingleton() {
+        return this.singletonPortPairGroup;
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return singletonPortPairGroup != null;
+    }
+
+    @Override
+    public List<NeutronSFCPortPairGroup> getBulk() {
+        return this.bulkRequest;
+    }
+
+}
diff --git a/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairGroupsNorthbound.java b/northbound-api/src/main/java/org/opendaylight/neutron/northbound/api/NeutronSFCPortPairGroupsNorthbound.java
new file mode 100644 (file)
index 0000000..5f3af34
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * 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.opendaylight.neutron.spi.INeutronSFCPortPairGroupCRUD;
+import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
+import org.opendaylight.neutron.spi.NeutronSFCPortPairGroup;
+
+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 Port Pair.<br>
+ * This class provides REST APIs for managing OpenStack SFC Port Pair
+ *
+ * <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/portpairgroups")
+public class NeutronSFCPortPairGroupsNorthbound
+        extends AbstractNeutronNorthbound<NeutronSFCPortPairGroup,
+        NeutronSFCPortPairGroupRequest, INeutronSFCPortPairGroupCRUD> {
+
+    private static final String RESOURCE_NAME = "Sfc Port Pair Group";
+
+    @Override
+    protected String getResourceName() {
+        return RESOURCE_NAME;
+    }
+
+    @Override
+    protected NeutronSFCPortPairGroup extractFields(NeutronSFCPortPairGroup o, List<String> fields) {
+        return o.extractFields(fields);
+    }
+
+    @Override
+    protected NeutronSFCPortPairGroupRequest newNeutronRequest(NeutronSFCPortPairGroup o) {
+        return new NeutronSFCPortPairGroupRequest(o);
+    }
+
+    @Override
+    protected INeutronSFCPortPairGroupCRUD getNeutronCRUD() {
+        NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCPortPairGroupCRUD(this);
+        if (answer.getSFCPortPairGroupInterface() == null) {
+            throw new ServiceUnavailableException(serviceUnavailable());
+        }
+        return answer.getSFCPortPairGroupInterface();
+    }
+
+    /**
+     * Returns a list of all SFC Port Pair Groups*/
+
+    @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 listSFCPortPairGroups(
+            // return fields
+            @QueryParam("fields") List<String> fields,
+            @QueryParam("id") String queryID,
+            @QueryParam("name") String queryName,
+            @QueryParam("tenant_id") String queryTenantID,
+            @QueryParam("port_pairs") List<String> queryPortPairsUUID ) {
+        INeutronSFCPortPairGroupCRUD sfcPortPairGroupInterface = getNeutronCRUD();
+        List<NeutronSFCPortPairGroup> allSFCPortPairGroup = sfcPortPairGroupInterface.getAll();
+        List<NeutronSFCPortPairGroup> ans = new ArrayList<>();
+        Iterator<NeutronSFCPortPairGroup> i = allSFCPortPairGroup.iterator();
+        while (i.hasNext()) {
+            NeutronSFCPortPairGroup oSFCPPG = i.next();
+            if ((queryID == null || queryID.equals(oSFCPPG.getID())) &&
+                    (queryName == null || queryName.equals(oSFCPPG.getName())) &&
+                    (queryTenantID == null || queryTenantID.equals(oSFCPPG.getTenantID()))) {
+                if (fields.size() > 0) {
+                    ans.add(extractFields(oSFCPPG,fields));
+                } else {
+                    ans.add(oSFCPPG);
+                }
+            }
+        }
+
+        return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronSFCPortPairGroupRequest(ans)).build();
+
+    }
+
+    /**
+     * Returns a specific SFC Port Pair Group*/
+
+    @Path("{portPairGroupUUID}")
+    @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 showSFCPortPairGroup(
+            @PathParam("portPairGroupUUID") String sfcPortPairGroupUUID,
+            // return fields
+            @QueryParam("fields") List<String> fields ){
+        return show(sfcPortPairGroupUUID, fields);
+    }
+
+    /**
+     * Creates new SFC Port Pair Group*/
+    @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 createSFCPortPairGroup(final NeutronSFCPortPairGroupRequest input) {
+        return create(input);
+    }
+
+    @Override
+    protected void updateDelta(String uuid, NeutronSFCPortPairGroup delta, NeutronSFCPortPairGroup 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 Port Pair Group*/
+    @Path("{portPairGroupUUID}")
+    @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 updateSFCPortPairGroup(
+            @PathParam("portPairGroupUUID") String sfcPortPairGroupUUID, final NeutronSFCPortPairGroupRequest input ) {
+        return update(sfcPortPairGroupUUID, input);
+    }
+
+    /**
+     * Deletes the SFC Port Pair Group*/
+
+    @Path("{portPairGroupUUID}")
+    @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 deleteSFCPortPairGroup(
+            @PathParam("portPairGroupUUID") String sfcPortPairGroupUUID) {
+        return delete(sfcPortPairGroupUUID);
+    }
+}
index f801bc1778c51c05d97dc370a6c470666ca0f9d4..3e0601e7ab3db920fe82ab73871a9803bec68cea 100644 (file)
                "4deeda6e-d087-3833-8349-cc7233f1ca88",
                "96110c74-ae51-7bb3-e94c-d4c0044ccccc",
                "8676edc8-697a-aef2-b203-2f840fa648b6",
-               "3d8a5b17-f6f6-c004-5686-5a38ffb3d064"
+               "3d8a5b17-f6f6-c004-5686-5a38ffb3d064",
+               "be3dce07-d900-7e45-6cf7-04f077d28989",
+               "535c75b8-b722-79ea-a7fb-ad79a6510b02",
+               "9a716ae1-b9b8-a1e7-8278-c655b5333909",
+               "7039b324-34c2-e024-1339-1314bbaa6b6d",
+               "842a23f9-bde0-d639-1b06-663e711ef19a"
        ],
        "folders": [],
        "timestamp": 1466797738971,
                        "id": "4deeda6e-d087-3833-8349-cc7233f1ca88",
                        "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
                        "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portpairs/",
-                       "pathVariables": {},
                        "preRequestScript": "",
+                       "pathVariables": {},
                        "method": "POST",
-                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
                        "data": [],
                        "dataMode": "raw",
-                       "name": "Create Port Pair (non-MDSAL)",
-                       "description": "This REST call create SFC Port Pairr using the handcrafted REST API (not through the RESTCONF yang based modles).",
-                       "descriptionFormat": "html",
-                       "time": 1466977029811,
                        "version": 2,
-                       "responses": [],
                        "tests": "",
                        "currentHelper": "basicAuth",
                        "helperAttributes": {
                                "password": "admin",
                                "saveToRequest": true
                        },
-                       "rawModeData": "{\n    \"portpair\":{\n    \"id\": \"444e5957-649f-477b-9e5b-f1f75b21c03c\",\n    \"name\": \"fc1\", \n    \"ingress\": \"5e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"egress\": \"6e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"service_function_parameters\": [\n        {\n            \"correlation\":\"value\"\n        }\n     ],\n     \"tenant_id\":\"4969c491a3c74ee4af974e6d800c62de\"\n    }\n\n}"
+                       "time": 1466982369300,
+                       "name": "Create Port Pair (non-MDSAL)",
+                       "description": "This REST call create SFC Port Pairr using the handcrafted REST API (not through the RESTCONF yang based modles).",
+                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+                       "responses": [],
+                       "rawModeData": "{\n    \"portpair\":{\n    \"id\": \"444e5957-649f-477b-9e5b-f1f75b21c03c\",\n    \"name\": \"portpair\", \n    \"ingress\": \"5e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"egress\": \"6e8e5957-649f-477b-9e5b-f1f75b21c03c\", \n    \"service_function_parameters\": [\n        {\n            \"correlation\":\"value\"\n        }\n     ],\n     \"tenant_id\":\"4969c491a3c74ee4af974e6d800c62de\"\n    }\n\n}"
+               },
+               {
+                       "id": "535c75b8-b722-79ea-a7fb-ad79a6510b02",
+                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
+                       "url": "http://localhost:8181/restconf/config/neutron:neutron/port-pair-groups/",
+                       "pathVariables": {},
+                       "preRequestScript": "",
+                       "method": "GET",
+                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+                       "data": [],
+                       "dataMode": "params",
+                       "name": "All PortPairGroups Data from MDSAL",
+                       "description": "Fetch SFC Port Pair Groups data from the MD-SAL Data Store using the MD-SAL RESTCONF URL. This restconf call can be used to verify that the SFC Port Pair Groups created through handcrafted REST request is indeed present in the MD-SAL Data store.  ",
+                       "descriptionFormat": "html",
+                       "time": 1466981252619,
+                       "version": 2,
+                       "responses": [],
+                       "tests": "",
+                       "currentHelper": "normal",
+                       "helperAttributes": {}
                },
                {
                        "id": "5e12f74c-5edd-dfa7-56e5-4b3c426664c5",
                        "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
                        "responses": []
                },
+               {
+                       "id": "7039b324-34c2-e024-1339-1314bbaa6b6d",
+                       "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+                       "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portpairgroups/",
+                       "pathVariables": {},
+                       "preRequestScript": "",
+                       "method": "GET",
+                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+                       "data": [],
+                       "dataMode": "raw",
+                       "name": "All Port Pair Group Data (non-MDSAL)",
+                       "description": "This REST call fetch all SFC Port Pair Group data  using the handcrafted REST API (not through the RESTCONF yang based modles).",
+                       "descriptionFormat": "html",
+                       "time": 1466981329770,
+                       "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": "842a23f9-bde0-d639-1b06-663e711ef19a",
+                       "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+                       "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portpairgroups/444e5957-649f-477b-9e5b-f1f75b21c03c",
+                       "pathVariables": {},
+                       "preRequestScript": "",
+                       "method": "DELETE",
+                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+                       "data": [],
+                       "dataMode": "raw",
+                       "name": "Delete Specific Port Pair Group Data (non-MDSAL)",
+                       "description": "This REST call delete specific SFC Port Pair Group data  using the handcrafted REST API (not through the RESTCONF yang based modles).",
+                       "descriptionFormat": "html",
+                       "time": 1466982457834,
+                       "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": "8676edc8-697a-aef2-b203-2f840fa648b6",
                        "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
                        "currentHelper": "normal",
                        "helperAttributes": {}
                },
+               {
+                       "id": "9a716ae1-b9b8-a1e7-8278-c655b5333909",
+                       "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
+                       "url": "http://localhost:8181/restconf/config/neutron:neutron/port-pair-groups/port-pair-group/444e5957-649f-477b-9e5b-f1f75b21c03c",
+                       "pathVariables": {},
+                       "preRequestScript": "",
+                       "method": "GET",
+                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+                       "data": [],
+                       "dataMode": "params",
+                       "name": "Specific Port Pair Group Data from MDSAL",
+                       "description": "Fetch specific SFC Port Pair Group data from the MD-SAL Data Store using the MD-SAL RESTCONF URL. This restconf call can be used to verify that the SFC Port Pair Group created through handcrafted REST request is indeed present in the MD-SAL Data store.",
+                       "descriptionFormat": "html",
+                       "time": 1466981299760,
+                       "version": 2,
+                       "responses": [],
+                       "tests": "",
+                       "currentHelper": "normal",
+                       "helperAttributes": {}
+               },
                {
                        "id": "b3012570-d38b-432a-2eb6-4a7731450814",
                        "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
                                "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": "be3dce07-d900-7e45-6cf7-04f077d28989",
+                       "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+                       "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portpairgroups/",
+                       "preRequestScript": "",
+                       "pathVariables": {},
+                       "method": "POST",
+                       "data": [],
+                       "dataMode": "raw",
+                       "version": 2,
+                       "tests": "",
+                       "currentHelper": "basicAuth",
+                       "helperAttributes": {
+                               "id": "basic",
+                               "username": "admin",
+                               "password": "admin",
+                               "saveToRequest": true
+                       },
+                       "time": 1466981979425,
+                       "name": "Create Port Pair Group (non-MDSAL)",
+                       "description": "This REST call create SFC Port Pair Group using the handcrafted REST API (not through the RESTCONF yang based modles).",
+                       "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+                       "responses": [],
+                       "rawModeData": "{\n    \"portpairgroup\":{\n    \"id\": \"444e5957-649f-477b-9e5b-f1f75b21c03c\",\n    \"name\": \"portpairgroup\", \n    \"service_function_parameters\": [\n        \"d11e9190-73d4-11e5-b392-2c27d72acb4c\"\n     ],\n     \"tenant_id\":\"4969c491a3c74ee4af974e6d800c62de\"\n    }\n\n}"
                }
        ]
 }
\ No newline at end of file
diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSFCPortPairGroupInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronSFCPortPairGroupInterface.java
new file mode 100644 (file)
index 0000000..e0b13b6
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * 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 org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.neutron.spi.INeutronSFCPortPairGroupCRUD;
+import org.opendaylight.neutron.spi.NeutronSFCPortPairGroup;
+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.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortPairGroups;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.pair.groups.PortPairGroupBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Created by Anil Vishnoi (avishnoi@Brocade.com)
+ */
+public class NeutronSFCPortPairGroupInterface
+        extends AbstractNeutronInterface<PortPairGroup, PortPairGroups, NeutronSFCPortPairGroup>
+        implements INeutronSFCPortPairGroupCRUD {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSFCPortPairGroupInterface.class);
+
+    NeutronSFCPortPairGroupInterface(DataBroker db) {
+        super(db);
+    }
+
+    @Override
+    protected InstanceIdentifier<PortPairGroup> createInstanceIdentifier(PortPairGroup portPairGroup) {
+        return InstanceIdentifier.create(Neutron.class).child(PortPairGroups.class)
+                .child(PortPairGroup.class, portPairGroup.getKey());
+    }
+
+    @Override
+    protected InstanceIdentifier<PortPairGroups> createInstanceIdentifier() {
+        return InstanceIdentifier.create(Neutron.class).child(PortPairGroups.class);
+    }
+
+    @Override
+    protected PortPairGroup toMd(NeutronSFCPortPairGroup neutronPortPairGroup) {
+
+        LOGGER.trace("toMd: REST SFC Port Pair Group data : {}", neutronPortPairGroup);
+
+        PortPairGroupBuilder result = new PortPairGroupBuilder();
+        result.setUuid(new Uuid(neutronPortPairGroup.getID()));
+        result.setName(neutronPortPairGroup.getName());
+        result.setTenantId(toUuid(neutronPortPairGroup.getTenantID()));
+        if (neutronPortPairGroup.getPortPairs() != null ) {
+            List<Uuid> portPairs = new ArrayList<>();
+            for(String ppUuid : neutronPortPairGroup.getPortPairs()) {
+                portPairs.add(new Uuid(ppUuid));
+            }
+            result.setPortPairs(portPairs);
+        }
+        LOGGER.trace("toMd: Yang SFC Port Pair Group data : {}", result);
+        return result.build();
+    }
+
+    @Override
+    protected PortPairGroup toMd(String uuid) {
+        final PortPairGroupBuilder portPairGroupBuilder = new PortPairGroupBuilder();
+        portPairGroupBuilder.setUuid(toUuid(uuid));
+        return portPairGroupBuilder.build();
+    }
+
+    @Override
+    protected NeutronSFCPortPairGroup fromMd(PortPairGroup mdPortPairGroup) {
+        LOGGER.trace("fromMd: Yang SFC Port Pair Group data : {}", mdPortPairGroup);
+        NeutronSFCPortPairGroup result = new NeutronSFCPortPairGroup();
+        result.setID(mdPortPairGroup.getUuid().getValue());
+        result.setName(mdPortPairGroup.getName());
+        result.setTenantID(mdPortPairGroup.getTenantId());
+        if (mdPortPairGroup.getPortPairs() != null) {
+            List<String> portPairsUUID = new ArrayList<>();
+            for(Uuid uuid : mdPortPairGroup.getPortPairs()) {
+                portPairsUUID.add(uuid.getValue());
+            }
+            result.setPortPairs(portPairsUUID);
+        }
+        LOGGER.trace("fromMd: REST SFC Port Pair Group data : {}", result);
+        return result;
+    }
+
+    @Override
+    protected List<PortPairGroup> getDataObjectList(PortPairGroups dataObjects) {
+        return dataObjects.getPortPairGroup();
+    }
+}
index f185500b810cc0548273cae0bebf53e2bcb26b62..03585f1fd79ea12cd4bd096e8d9e28e872bb0dd3 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.neutron.spi.INeutronPortCRUD;
 import org.opendaylight.neutron.spi.INeutronRouterCRUD;
 import org.opendaylight.neutron.spi.INeutronSFCFlowClassifierCRUD;
 import org.opendaylight.neutron.spi.INeutronSFCPortPairCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCPortPairGroupCRUD;
 import org.opendaylight.neutron.spi.INeutronSecurityGroupCRUD;
 import org.opendaylight.neutron.spi.INeutronSecurityRuleCRUD;
 import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
@@ -79,6 +80,7 @@ public class NeutronTranscriberProvider
     private NeutronVPNServiceInterface vPNServiceInterface;
     private NeutronSFCFlowClassifierInterface sfcFlowClassifierInterface;
     private NeutronSFCPortPairInterface sfcPortPairInterface;
+    private NeutronSFCPortPairGroupInterface sfcPortPairGroupInterface;
 
     public NeutronTranscriberProvider(BundleContext context, DataBroker db) {
         LOGGER.debug("DataBroker set to: {}", db);
@@ -170,6 +172,8 @@ public class NeutronTranscriberProvider
         sfcPortPairInterface = new NeutronSFCPortPairInterface(db);
         registerCRUDInterface(INeutronSFCPortPairCRUD.class, sfcPortPairInterface);
 
+        sfcPortPairGroupInterface = new NeutronSFCPortPairGroupInterface(db);
+        registerCRUDInterface(INeutronSFCPortPairGroupCRUD.class, sfcPortPairGroupInterface);
         // We don't need context any more
         this.context = null;
     }