--- /dev/null
+/*
+ * 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 Chain objects
+ *
+ */
+public interface INeutronSFCPortChainCRUD extends INeutronCRUD<NeutronSFCPortChain>{
+ // Nothing Here.
+ // This class is defined to use reflection.
+}
private INeutronSFCFlowClassifierCRUD sfcFlowClassifierInterface;
private INeutronSFCPortPairCRUD sfcPortPairInterface;
private INeutronSFCPortPairGroupCRUD sfcPortPairGroupInterface;
+ private INeutronSFCPortChainCRUD sfcPortChainInterface;
public NeutronCRUDInterfaces() {
}
return sfcPortPairGroupInterface;
}
+ public INeutronSFCPortChainCRUD getSFCPortChainInterface() {
+ return sfcPortChainInterface;
+ }
+
public NeutronCRUDInterfaces fetchINeutronNetworkCRUD(Object obj) {
networkInterface = (INeutronNetworkCRUD) getInstances(INeutronNetworkCRUD.class, obj);
return this;
return this;
}
+ public NeutronCRUDInterfaces fetchINeutronSFCPortChainCRUD (Object obj) {
+ sfcPortChainInterface =
+ (INeutronSFCPortChainCRUD) getInstances(INeutronSFCPortChainCRUD.class, obj);
+ return this;
+ }
+
public Object getInstances(Class<?> clazz, Object bundle) {
try {
BundleContext bCtx = FrameworkUtil.getBundle(bundle.getClass()).getBundleContext();
--- /dev/null
+/*
+ * 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 com.fasterxml.jackson.annotation.JsonIgnore;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+
+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.Iterator;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+
+public class NeutronSFCPortChain extends NeutronObject implements Serializable, INeutronObject {
+
+ private static final long serialVersionUID = 1L;
+
+ // See OpenStack Networking SFC (networking-sfc) Port Chain API v1.0 Reference
+ // for description of annotated attributes
+ @XmlElement(name = "name")
+ String name;
+
+ @XmlElement(name = "port_pair_groups")
+ List<String> portPairGroupsUUID;
+
+ @XmlElement(name = "flow_classifiers")
+ List<String> flowClassifiersUUID;
+
+ @XmlElement(name = "chain_parameters")
+ @XmlJavaTypeAdapter(NeutronResourceMapPropertyAdapter.class)
+ Map<String, String> chainParameters;
+
+ public NeutronSFCPortChain() {
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public List<String> getPortPairGroupsUUID() {
+ return portPairGroupsUUID;
+ }
+
+ public void setPortPairGroupsUUID(List<String> portPairGroupsUUID) {
+ this.portPairGroupsUUID = portPairGroupsUUID;
+ }
+
+ public List<String> getFlowClassifiersUUID() {
+ return flowClassifiersUUID;
+ }
+
+ public void setFlowClassifiersUUID(List<String> flowClassifiersUUID) {
+ this.flowClassifiersUUID = flowClassifiersUUID;
+ }
+
+ public Map<String, String> getChainParameters() {
+ return chainParameters;
+ }
+
+ public void setChainParameters(Map<String, String> chainParameters) {
+ this.chainParameters = chainParameters;
+ }
+
+ /**
+ * 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 Chain object with only the selected fields
+ * populated
+ */
+
+ public NeutronSFCPortChain extractFields(List<String> fields) {
+ NeutronSFCPortChain ans = new NeutronSFCPortChain();
+ 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_pair_groups")) {
+ ans.setPortPairGroupsUUID(this.getPortPairGroupsUUID());
+ }
+ if (s.equals("flow_classifiers")) {
+ ans.setFlowClassifiersUUID(this.getFlowClassifiersUUID());
+ }
+ if (s.equals("chain_parameters")) {
+ ans.setChainParameters(this.getChainParameters());
+ }
+ }
+ return ans;
+ }
+
+ @Override
+ public String toString() {
+ return "NeutronSFCPortChain[" +
+ "tenantID='" + tenantID + '\'' +
+ ", name='" + name + '\'' +
+ ", portPairGroupsUUID=" + portPairGroupsUUID +
+ ", flowClassifiersUUID='" + flowClassifiersUUID + '\'' +
+ ", chainParameters=" + chainParameters +
+ ']';
+ }
+}
--- /dev/null
+/*
+ * 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)
+ */
+public class NeutronSFCPortChainJAXBTest {
+
+ private static final String NeutronSFCPortChain_sourceJson = "{ "
+ + "\"name\": \"portchain1\", "
+ + "\"port_pair_groups\": [ "
+ + "\"4512d643-24fc-4fae-af4b-321c5e2eb3d1\", "
+ + "\"4a634d49-76dc-4fae-af4b-321c5e23d651\" "
+ + "], "
+ + "\"flow_classifiers\": [ "
+ + "\"4a334cd4-fe9c-4fae-af4b-321c5e2eb051\", "
+ + "\"105a4b0a-73d6-11e5-b392-2c27d72acb4c\" "
+ + "], "
+ + "\"chain_parameters\": [ "
+ + "{ "
+ + "\"correlation\": \"value\" "
+ + "} "
+ + "], "
+ + "\"tenant_id\": \"4969c491a3c74ee4af974e6d800c62de\", "
+ + "\"id\": \"4e8e5957-649f-477b-9e5b-f1f75b21c03c\" }";
+
+ @Test
+ public void test_NeutronSFCPortChain_JAXB() throws JAXBException {
+
+ NeutronSFCPortChain testObject = new NeutronSFCPortChain();
+ NeutronSFCPortChain neutronObject
+ = (NeutronSFCPortChain) JaxbTestHelper.jaxbUnmarshall(testObject
+ , NeutronSFCPortChain_sourceJson);
+
+ Assert.assertEquals("NeutronSFCPortChain JAXB Test 1: Testing id failed"
+ , "4e8e5957-649f-477b-9e5b-f1f75b21c03c",neutronObject.getID());
+
+ Assert.assertEquals("NeutronSFCPortChain JAXB Test 2: Testing tenant_id failed",
+ "4969c491a3c74ee4af974e6d800c62de", neutronObject.getTenantID());
+
+ Assert.assertEquals("NeutronSFCPortChain JAXB Test 3: Testing flow_classifiers failed",
+ 2, neutronObject.getFlowClassifiersUUID().size());
+
+ Assert.assertEquals("NeutronSFCPortChain JAXB Test 4: Testing port_pair_groups failed",
+ 2, neutronObject.getPortPairGroupsUUID().size());
+
+ Map<String, String> param = neutronObject.getChainParameters();
+ Assert.assertEquals("NeutronSFCPortChain JAXB Test 5: Testing chain_parameters list length " +
+ "failed", 1, param.size());
+
+ }
+}
classes.add(NeutronSFCFlowClassifiersNorthbound.class);
classes.add(NeutronSFCPortPairsNorthbound.class);
classes.add(NeutronSFCPortPairGroupsNorthbound.class);
+ classes.add(NeutronSFCPortChainsNorthbound.class);
- classes.add(MOXyJsonProvider.class);
+ classes.add(MOXyJsonProvider.class);
return classes;
}
--- /dev/null
+/*
+ * 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.NeutronSFCPortChain;
+import org.opendaylight.neutron.spi.NeutronSFCPortPair;
+
+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 NeutronSFCPortChainRequest implements INeutronRequest<NeutronSFCPortChain> {
+ // See OpenStack Networking SFC (networking-sfc) Port Chain API v1.0 Reference
+ // for description of annotated attributes
+
+ @XmlElement(name="portchain")
+ NeutronSFCPortChain singletonPortChain;
+
+ @XmlElement(name="portchains")
+ List<NeutronSFCPortChain> bulkRequest;
+
+ NeutronSFCPortChainRequest() {
+ }
+
+ NeutronSFCPortChainRequest(List<NeutronSFCPortChain> bulkRequest) {
+ this.bulkRequest = bulkRequest;
+ this.singletonPortChain = null;
+ }
+
+ NeutronSFCPortChainRequest(NeutronSFCPortChain sfcPortPair) {
+ this.singletonPortChain = sfcPortPair;
+ }
+
+ @Override
+ public NeutronSFCPortChain getSingleton() {
+ return this.singletonPortChain;
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return singletonPortChain != null;
+ }
+
+ @Override
+ public List<NeutronSFCPortChain> getBulk() {
+ return this.bulkRequest;
+ }
+}
--- /dev/null
+/*
+ * 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.INeutronSFCPortChainCRUD;
+import org.opendaylight.neutron.spi.NeutronCRUDInterfaces;
+import org.opendaylight.neutron.spi.NeutronSFCPortChain;
+
+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 Chain.<br>
+ * This class provides REST APIs for managing OpenStack SFC Port Chain
+ *
+ * <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/portchains")
+public class NeutronSFCPortChainsNorthbound
+ extends AbstractNeutronNorthbound<NeutronSFCPortChain,
+ NeutronSFCPortChainRequest, INeutronSFCPortChainCRUD> {
+
+ private static final String RESOURCE_NAME = "Sfc Port Chain";
+
+ @Override
+ protected String getResourceName() {
+ return RESOURCE_NAME;
+ }
+
+ @Override
+ protected NeutronSFCPortChain extractFields(NeutronSFCPortChain o, List<String> fields) {
+ return o.extractFields(fields);
+ }
+
+ @Override
+ protected NeutronSFCPortChainRequest newNeutronRequest(NeutronSFCPortChain o) {
+ return new NeutronSFCPortChainRequest(o);
+ }
+
+ @Override
+ protected INeutronSFCPortChainCRUD getNeutronCRUD() {
+ NeutronCRUDInterfaces answer = new NeutronCRUDInterfaces().fetchINeutronSFCPortChainCRUD(this);
+ if (answer.getSFCPortChainInterface() == null) {
+ throw new ServiceUnavailableException(serviceUnavailable());
+ }
+ return answer.getSFCPortChainInterface();
+ }
+
+ /**
+ * Returns a list of all SFC Port Chains*/
+
+ @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 listSFCPortChains(
+ // return fields
+ @QueryParam("fields") List<String> fields,
+ @QueryParam("id") String queryID,
+ @QueryParam("name") String queryName,
+ @QueryParam("tenant_id") String queryTenantID) {
+ INeutronSFCPortChainCRUD sfcPortChainInterface = getNeutronCRUD();
+ List<NeutronSFCPortChain> allSFCPortChain = sfcPortChainInterface.getAll();
+ List<NeutronSFCPortChain> ans = new ArrayList<>();
+ Iterator<NeutronSFCPortChain> i = allSFCPortChain.iterator();
+ while (i.hasNext()) {
+ NeutronSFCPortChain oSFCPC = i.next();
+ if ((queryID == null || queryID.equals(oSFCPC.getID())) &&
+ (queryName == null || queryName.equals(oSFCPC.getName())) &&
+ (queryTenantID == null || queryTenantID.equals(oSFCPC.getTenantID()))) {
+ if (fields.size() > 0) {
+ ans.add(extractFields(oSFCPC,fields));
+ } else {
+ ans.add(oSFCPC);
+ }
+ }
+ }
+
+ return Response.status(HttpURLConnection.HTTP_OK).entity(new NeutronSFCPortChainRequest(ans)).build();
+
+ }
+
+ /**
+ * Returns a specific SFC Port Chain */
+
+ @Path("{portChainUUID}")
+ @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 showSFCPortChain(
+ @PathParam("portChainUUID") String sfcPortChainUUID,
+ // return fields
+ @QueryParam("fields") List<String> fields) {
+ return show(sfcPortChainUUID, fields);
+ }
+
+ /**
+ * Creates new SFC Port Chain*/
+ @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 createSFCPortChain(final NeutronSFCPortChainRequest input) {
+ return create(input);
+ }
+
+ @Override
+ protected void updateDelta(String uuid, NeutronSFCPortChain delta, NeutronSFCPortChain 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 Chain */
+ @Path("{portChainUUID}")
+ @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 updateSFCPortChain(
+ @PathParam("portChainUUID") String sfcPortChainUUID, final NeutronSFCPortChainRequest input) {
+ return update(sfcPortChainUUID, input);
+ }
+
+ /**
+ * Deletes the SFC Port Chain */
+ @Path("{portChainUUID}")
+ @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 deleteSFCPortChain(
+ @PathParam("portChainUUID") String sfcPortChainUUID) {
+ return delete(sfcPortChainUUID);
+ }
+}
"535c75b8-b722-79ea-a7fb-ad79a6510b02",
"9a716ae1-b9b8-a1e7-8278-c655b5333909",
"7039b324-34c2-e024-1339-1314bbaa6b6d",
- "842a23f9-bde0-d639-1b06-663e711ef19a"
+ "842a23f9-bde0-d639-1b06-663e711ef19a",
+ "67843460-9c88-2274-8c6d-b834a27ce90f",
+ "95ab58d5-525c-d2df-124d-abb747839445",
+ "01e744e0-4126-4c3e-8439-fc33cf0c1e18",
+ "f6faf4ec-86a9-e398-52a3-52050153c916",
+ "0cd5de7d-e72e-69af-2d29-735614f95b26"
],
"folders": [],
"timestamp": 1466797738971,
"public": false,
"published": false,
"requests": [
+ {
+ "id": "01e744e0-4126-4c3e-8439-fc33cf0c1e18",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
+ "url": "http://localhost:8181/restconf/config/neutron:neutron/port-chains/port-chain/444e5957-649f-477b-9e5b-f1f75b21c03c",
+ "pathVariables": {},
+ "preRequestScript": "",
+ "method": "GET",
+ "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+ "data": [],
+ "dataMode": "params",
+ "name": "Specific Port Chain Data from MDSAL",
+ "description": "Fetch specific SFC Port Chain 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 Chain created through handcrafted REST request is indeed present in the MD-SAL Data store.",
+ "descriptionFormat": "html",
+ "time": 1466989350411,
+ "version": 2,
+ "responses": [],
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {}
+ },
+ {
+ "id": "0cd5de7d-e72e-69af-2d29-735614f95b26",
+ "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+ "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portchains/444e5957-649f-477b-9e5b-f1f75b21c03c",
+ "pathVariables": {},
+ "preRequestScript": "",
+ "method": "DELETE",
+ "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+ "data": [],
+ "dataMode": "raw",
+ "name": "Delete Specific Port Chain Data (non-MDSAL)",
+ "description": "This REST call delete specific SFC Port Chain data using the handcrafted REST API (not through the RESTCONF yang based modles).",
+ "descriptionFormat": "html",
+ "time": 1466989429349,
+ "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": "1d511ed2-e420-e501-59b3-6107f2878387",
"headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
"collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
"responses": []
},
+ {
+ "id": "67843460-9c88-2274-8c6d-b834a27ce90f",
+ "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+ "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portchains/",
+ "preRequestScript": "",
+ "pathVariables": {},
+ "method": "POST",
+ "data": [],
+ "dataMode": "raw",
+ "version": 2,
+ "tests": "",
+ "currentHelper": "basicAuth",
+ "helperAttributes": "{\"id\":\"basic\",\"username\":\"admin\",\"password\":\"admin\",\"saveToRequest\":true}",
+ "time": 1466989694590,
+ "name": "Create Port Chain (non-MDSAL)",
+ "description": "This REST call create SFC Port Chain using the handcrafted REST API (not through the RESTCONF yang based modles).",
+ "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+ "responses": [],
+ "descriptionFormat": "html",
+ "folder": null,
+ "rawModeData": "{\n \"portchain\":{\n \"id\": \"444e5957-649f-477b-9e5b-f1f75b21c03c\",\n \"name\": \"portchain\", \n \"flow_classifiers\": [\n \"4a334cd4-fe9c-4fae-af4b-321c5e2eb051\",\n \"105a4b0a-73d6-11e5-b392-2c27d72acb4c\"\n ],\n \"port_pair_groups\": [\n \"4512d643-24fc-4fae-af4b-321c5e2eb3d1\",\n \"4a634d49-76dc-4fae-af4b-321c5e23d651\"\n ],\n \"chain_parameters\": [\n {\n \"correlation\":\"value\"\n }\n ],\n \"tenant_id\":\"4969c491a3c74ee4af974e6d800c62de\"\n }\n\n}"
+ },
{
"id": "7039b324-34c2-e024-1339-1314bbaa6b6d",
"headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
"collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
"responses": []
},
+ {
+ "id": "95ab58d5-525c-d2df-124d-abb747839445",
+ "headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
+ "url": "http://localhost:8181/restconf/config/neutron:neutron/port-chains/",
+ "pathVariables": {},
+ "preRequestScript": "",
+ "method": "GET",
+ "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+ "data": [],
+ "dataMode": "params",
+ "name": "All PortChains Data from MDSAL",
+ "description": "Fetch SFC Port Chains 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 Chains created through handcrafted REST request is indeed present in the MD-SAL Data store. ",
+ "descriptionFormat": "html",
+ "time": 1466989304254,
+ "version": 2,
+ "responses": [],
+ "tests": "",
+ "currentHelper": "normal",
+ "helperAttributes": {}
+ },
{
"id": "96110c74-ae51-7bb3-e94c-d4c0044ccccc",
"headers": "Authorization: Basic YWRtaW46YWRtaW4=\nContent-Type: application/json\nAccept: application/json\n",
"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}"
+ },
+ {
+ "id": "f6faf4ec-86a9-e398-52a3-52050153c916",
+ "headers": "Content-Type: application/json\nAccept: application/json\nAuthorization: Basic YWRtaW46YWRtaW4=\n",
+ "url": " http://localhost:8181/controller/nb/v2/neutron/sfc/portchains/",
+ "pathVariables": {},
+ "preRequestScript": "",
+ "method": "GET",
+ "collectionId": "810e37ef-c291-5276-575c-d16b3f7ef595",
+ "data": [],
+ "dataMode": "raw",
+ "name": "All Port Chain Data (non-MDSAL)",
+ "description": "This REST call fetch all SFC Port Chain data using the handcrafted REST API (not through the RESTCONF yang based modles).",
+ "descriptionFormat": "html",
+ "time": 1466989387969,
+ "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}"
}
]
}
\ No newline at end of file
--- /dev/null
+/*
+ * 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.INeutronSFCPortChainCRUD;
+import org.opendaylight.neutron.spi.NeutronSFCPortChain;
+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.port.chain.attributes.ChainParameters;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParametersBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.port.chain.attributes.ChainParametersKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.PortChains;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChain;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.sfc.rev160511.sfc.attributes.port.chains.PortChainBuilder;
+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)
+ */
+public class NeutronSFCPortChainInterface
+ extends AbstractNeutronInterface<PortChain, PortChains, NeutronSFCPortChain>
+ implements INeutronSFCPortChainCRUD {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(NeutronSFCPortChainInterface.class);
+
+ NeutronSFCPortChainInterface(DataBroker db) {
+ super(db);
+ }
+
+ @Override
+ protected List<PortChain> getDataObjectList(PortChains dataObjects) {
+ return dataObjects.getPortChain();
+ }
+
+ @Override
+ protected InstanceIdentifier<PortChain> createInstanceIdentifier(PortChain portChain) {
+ return InstanceIdentifier.create(Neutron.class).child(PortChains.class)
+ .child(PortChain.class, portChain.getKey());
+ }
+
+ @Override
+ protected InstanceIdentifier<PortChains> createInstanceIdentifier() {
+ return InstanceIdentifier.create(Neutron.class).child(PortChains.class);
+ }
+
+ @Override
+ protected PortChain toMd(NeutronSFCPortChain neutronPortChain) {
+
+ LOGGER.trace("toMd: REST SFC Port Chain data : {}", neutronPortChain);
+
+ PortChainBuilder result = new PortChainBuilder();
+ result.setUuid(new Uuid(neutronPortChain.getID()));
+ result.setName(neutronPortChain.getName());
+ result.setTenantId(toUuid(neutronPortChain.getTenantID()));
+ if (neutronPortChain.getPortPairGroupsUUID() != null) {
+ List<Uuid> portPairGroups = new ArrayList<>();
+ for(String uuid : neutronPortChain.getPortPairGroupsUUID()) {
+ portPairGroups.add(new Uuid(uuid));
+ }
+ result.setPortPairGroups(portPairGroups);
+ }
+ if (neutronPortChain.getFlowClassifiersUUID() != null) {
+ List<Uuid> flowClassifiers= new ArrayList<>();
+ for(String uuid : neutronPortChain.getFlowClassifiersUUID()) {
+ flowClassifiers.add(new Uuid(uuid));
+ }
+ result.setFlowClassifiers(flowClassifiers);
+ }
+ if (neutronPortChain.getChainParameters()!= null) {
+ List<ChainParameters> chainParams = new ArrayList<>();
+ for(String paramKey : neutronPortChain.getChainParameters().keySet()) {
+ ChainParametersBuilder param = new ChainParametersBuilder();
+ param.setKey(new ChainParametersKey(paramKey));
+ param.setChainParameter(paramKey);
+ param.setChainParameterValue(neutronPortChain.getChainParameters().get(paramKey));
+ chainParams.add(param.build());
+ }
+ result.setChainParameters(chainParams);
+ }
+ LOGGER.trace("toMd: Yang SFC Port Chain data : {}", result);
+ return result.build();
+ }
+
+ @Override
+ protected PortChain toMd(String uuid) {
+ final PortChainBuilder portChainBuilder = new PortChainBuilder();
+ portChainBuilder.setUuid(toUuid(uuid));
+ return portChainBuilder.build();
+ }
+
+ @Override
+ protected NeutronSFCPortChain fromMd(PortChain mdPortChain) {
+ LOGGER.trace("fromMd: Yang SFC Port Chain data : {}", mdPortChain);
+ NeutronSFCPortChain result = new NeutronSFCPortChain();
+ result.setID(mdPortChain.getUuid().getValue());
+ result.setName(mdPortChain.getName());
+ result.setTenantID(mdPortChain.getTenantId());
+ if (mdPortChain.getPortPairGroups() !=null) {
+ List<String> portPairGroups = new ArrayList<>();
+ for(Uuid uuid : mdPortChain.getPortPairGroups()) {
+ portPairGroups.add(uuid.getValue());
+ }
+ result.setPortPairGroupsUUID(portPairGroups);
+ }
+ if (mdPortChain.getFlowClassifiers() !=null) {
+ List<String> flowClassifiers = new ArrayList<>();
+ for(Uuid uuid : mdPortChain.getFlowClassifiers()) {
+ flowClassifiers.add(uuid.getValue());
+ }
+ result.setFlowClassifiersUUID(flowClassifiers);
+ }
+ if (mdPortChain.getChainParameters()!= null) {
+ HashMap<String, String> chainParams = new HashMap<>();
+ for(ChainParameters param : mdPortChain.getChainParameters()) {
+ chainParams.put(param.getChainParameter(),param.getChainParameterValue());
+ }
+ result.setChainParameters(chainParams);
+ }
+ LOGGER.trace("fromMd: REST SFC Port Chain data : {}", result);
+ return result;
+ }
+}
import org.opendaylight.neutron.spi.INeutronPortCRUD;
import org.opendaylight.neutron.spi.INeutronRouterCRUD;
import org.opendaylight.neutron.spi.INeutronSFCFlowClassifierCRUD;
+import org.opendaylight.neutron.spi.INeutronSFCPortChainCRUD;
import org.opendaylight.neutron.spi.INeutronSFCPortPairCRUD;
import org.opendaylight.neutron.spi.INeutronSFCPortPairGroupCRUD;
import org.opendaylight.neutron.spi.INeutronSecurityGroupCRUD;
import java.util.ArrayList;
import java.util.List;
-
public class NeutronTranscriberProvider
implements AutoCloseable, NeutronTranscriber {
private static final Logger LOGGER = LoggerFactory.getLogger(NeutronTranscriberProvider.class);
private NeutronSFCFlowClassifierInterface sfcFlowClassifierInterface;
private NeutronSFCPortPairInterface sfcPortPairInterface;
private NeutronSFCPortPairGroupInterface sfcPortPairGroupInterface;
+ private NeutronSFCPortChainInterface sfcPortChainInterface;
public NeutronTranscriberProvider(BundleContext context, DataBroker db) {
LOGGER.debug("DataBroker set to: {}", db);
sfcPortPairGroupInterface = new NeutronSFCPortPairGroupInterface(db);
registerCRUDInterface(INeutronSFCPortPairGroupCRUD.class, sfcPortPairGroupInterface);
+
+ sfcPortChainInterface = new NeutronSFCPortChainInterface(db);
+ registerCRUDInterface(INeutronSFCPortChainCRUD.class, sfcPortChainInterface);
+
// We don't need context any more
this.context = null;
}