From: adetalhouet Date: Mon, 30 Nov 2015 23:25:25 +0000 (-0500) Subject: Add a REST APIs support for IOVIsor module X-Git-Tag: release/beryllium~56 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=d0ec571cc93b4f31968c6c19dc430492b892ece2;p=groupbasedpolicy.git Add a REST APIs support for IOVIsor module - provide aaa authentication - path is: /controller/sb/iovisor/{SERVICE} For now we have one service being: /policies Through this one we will POST a list of policies for the IOVisor module to GET. To play with thee REST interface, you can use this postman collection: https://www.getpostman.com/collections/3b1fe6ef1ec0ead72ee7 Another patch will implement the POST correctly Change-Id: I5186df6b5d0501dca8b244bfd04e22dd54649b40 Signed-off-by: adetalhouet --- diff --git a/features/pom.xml b/features/pom.xml index 721a2d5ce..4f789f3c9 100755 --- a/features/pom.xml +++ b/features/pom.xml @@ -24,6 +24,7 @@ + 0.3.0-SNAPSHOT 2.0.0-SNAPSHOT 0.8.0-SNAPSHOT 1.3.0-SNAPSHOT @@ -165,6 +166,29 @@ xml + + + org.opendaylight.aaa + features-aaa + ${aaa.version} + features + xml + + + + + com.sun.jersey + jersey-core + + + com.sun.jersey + jersey-server + + + org.opendaylight.controller.thirdparty + com.sun.jersey.jersey-servlet + + commons-net diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index e7422e218..1e7cef5bd 100755 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -27,6 +27,8 @@ mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features mvn:org.opendaylight.dlux/features-dlux/{{VERSION}}/xml/features + + mvn:org.opendaylight.aaa/features-aaa/${aaa.version}/xml/features @@ -92,9 +94,15 @@ This renderer maps GBP service model to agents of the IOVisor Linux Foundation project. --> - + + war + odl-aaa-authn odl-groupbasedpolicy-base mvn:org.opendaylight.groupbasedpolicy/iovisor-renderer/{{VERSION}} + mvn:com.sun.jersey/jersey-core/${jersey.version} + mvn:com.sun.jersey/jersey-server/${jersey.version} + mvn:com.sun.jersey/jersey-servlet/${jersey.version} mvn:org.opendaylight.groupbasedpolicy/iovisor-renderer/{{VERSION}}/xml/config diff --git a/renderers/iovisor/enunciate.xml b/renderers/iovisor/enunciate.xml new file mode 100644 index 000000000..80d540a60 --- /dev/null +++ b/renderers/iovisor/enunciate.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/renderers/iovisor/pom.xml b/renderers/iovisor/pom.xml index e3ecf4d41..f608602dd 100644 --- a/renderers/iovisor/pom.xml +++ b/renderers/iovisor/pom.xml @@ -26,6 +26,32 @@ org.opendaylight.mdsal.model yang-ext + + + + com.sun.jersey + jersey-core + + + com.sun.jersey + jersey-server + + + org.opendaylight.controller.thirdparty + com.sun.jersey.jersey-servlet + + + + + org.eclipse.persistence + org.eclipse.persistence.moxy + + + + org.codehaus.enunciate + enunciate-core-annotations + + junit @@ -56,4 +82,24 @@ test + + + + + org.apache.felix + maven-bundle-plugin + true + + + + org.eclipse.jetty.servlets, + com.sun.jersey.spi.container.servlet,* + + /controller/sb/iovisor + + ${project.basedir}/src/main/resources/META-INF + + + + diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sbrest/IovisorModuleService.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sbrest/IovisorModuleService.java new file mode 100644 index 000000000..1803b3fdf --- /dev/null +++ b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sbrest/IovisorModuleService.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2015 Inocybe Technologies 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.groupbasedpolicy.renderer.iovisor.sbrest; + +import java.util.List; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Path("/policies") +public class IovisorModuleService { + + private static final Logger LOG = LoggerFactory.getLogger(IovisorModuleService.class); + + private static final String RESOLVED_POLICY_URI = "/restconf/operational/resolved-policy:resolved-policies/resolved-policy:resolved-policy"; + + @POST + @Produces({ MediaType.APPLICATION_JSON }) + @Consumes({ MediaType.APPLICATION_JSON }) + public Response sendResolvedPolicies(List resolvedPoliciesID) { + // TODO create resolvedPolicies coder/decoder + LOG.info("Sent resolvedPolicies to IOVisorModule {}", "MODULE_INSTANCE"); + return Response.status(200).entity(resolvedPoliciesID).build(); + } + + @GET + @Produces({MediaType.TEXT_PLAIN}) + public Response test() { + String result = "Our SBREST Module is up and running\n\n"; + return Response.status(200).entity(result).build(); + } +} diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sbrest/IovisorRSApplication.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sbrest/IovisorRSApplication.java new file mode 100644 index 000000000..0aac16e0d --- /dev/null +++ b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sbrest/IovisorRSApplication.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2015 Inocybe Technologies 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.groupbasedpolicy.renderer.iovisor.sbrest; + +import java.util.HashSet; +import java.util.Set; + +import javax.ws.rs.core.Application; + +/** + * This class is an instance of javax.ws.rs.core.Application and is used to + * return the classes that will be instantiated for JAXRS processing. This is + * necessary because package scanning in jersey doesn't yet work in OSGi + * environment. + * + */ +public class IovisorRSApplication extends Application { + + @Override + public Set> getClasses() { + Set> classes = new HashSet>(); + classes.add(IovisorModuleService.class); + return classes; + } +} diff --git a/renderers/iovisor/src/main/resources/WEB-INF/web.xml b/renderers/iovisor/src/main/resources/WEB-INF/web.xml new file mode 100644 index 000000000..67da998b6 --- /dev/null +++ b/renderers/iovisor/src/main/resources/WEB-INF/web.xml @@ -0,0 +1,57 @@ + + + + JAXRSIOVisor + com.sun.jersey.spi.container.servlet.ServletContainer + + javax.ws.rs.Application + org.opendaylight.groupbasedpolicy.renderer.iovisor.sbrest.IovisorRSApplication + + + + com.sun.jersey.spi.container.ContainerRequestFilters + org.opendaylight.aaa.sts.TokenAuthFilter + + 1 + + + + JAXRSIOVisor + /* + + + + cross-origin-restconf + org.eclipse.jetty.servlets.CrossOriginFilter + + allowedOrigins + * + + + allowedMethods + GET,POST,OPTIONS,DELETE,PUT,HEAD + + + allowedHeaders + origin, content-type, accept, authorization + + + + cross-origin-restconf + /* + + + + IOVisor api + /* + POST + GET + PUT + PATCH + DELETE + HEAD + + +