X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnorthbound%2Fcontainermanager%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fcontainermanager%2Fnorthbound%2FContainerManagerNorthbound.java;h=754167814d763555ede965c5de8c6ee867f5c9f5;hb=refs%2Fchanges%2F10%2F7610%2F5;hp=77c3004c76b6928fb57631ffd1a4c99e4740a067;hpb=c56d1b9358a17dbe9cabdbbeb446c2a70ef412fc;p=controller.git diff --git a/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java b/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java index 77c3004c76..754167814d 100644 --- a/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java +++ b/opendaylight/northbound/containermanager/src/main/java/org/opendaylight/controller/containermanager/northbound/ContainerManagerNorthbound.java @@ -9,7 +9,6 @@ package org.opendaylight.controller.containermanager.northbound; -import java.security.Principal; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -22,11 +21,13 @@ 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.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.UriInfo; +import javax.ws.rs.ext.ContextResolver; import org.codehaus.enunciate.jaxrs.ResponseCode; import org.codehaus.enunciate.jaxrs.StatusCodes; @@ -42,6 +43,7 @@ import org.opendaylight.controller.northbound.commons.exception.ResourceConflict import org.opendaylight.controller.northbound.commons.exception.ResourceForbiddenException; import org.opendaylight.controller.northbound.commons.exception.ResourceNotFoundException; import org.opendaylight.controller.northbound.commons.exception.UnauthorizedException; +import org.opendaylight.controller.northbound.commons.query.QueryContext; import org.opendaylight.controller.northbound.commons.utils.NorthboundUtils; import org.opendaylight.controller.sal.authorization.Privilege; import org.opendaylight.controller.sal.authorization.UserLevel; @@ -69,6 +71,14 @@ import org.opendaylight.controller.usermanager.IUserManager; @Path("/") public class ContainerManagerNorthbound { private String username; + private QueryContext queryContext; + + @Context + public void setQueryContext(ContextResolver queryCtxResolver) { + if (queryCtxResolver != null) { + queryContext = queryCtxResolver.getContext(QueryContext.class); + } + } @Context public void setSecurityContext(SecurityContext context) { @@ -115,8 +125,8 @@ public class ContainerManagerNorthbound { * http://localhost:8080/controller/nb/v2/containermanager/containers * * Response body in XML: - * <container-config-list> - * <container-config> + * <containerConfig-list> + * <containerConfig> * <container>black</container> * <staticVlan>10</staticVlan> * <nodeConnectors>OF|1@OF|00:00:00:00:00:00:00:01</nodeConnectors> @@ -125,8 +135,8 @@ public class ContainerManagerNorthbound { * <name>tcp</name> * <protocol>TCP</protocol> * </flowSpecs> - * </container-config> - * <container-config> + * </containerConfig> + * <containerConfig> * <container>red</container> * <staticVlan>20</staticVlan> * <nodeConnectors>OF|1@OF|00:00:00:00:00:00:00:01</nodeConnectors> @@ -135,11 +145,11 @@ public class ContainerManagerNorthbound { * <name>udp</name> * <protocol>UDP</protocol> * </flowSpecs> - * </container-config> - * </container-config-list> + * </containerConfig> + * </containerConfig-list> * * Response body in JSON: - * { "container-config" : [ + * { "containerConfig" : [ * { "container" : "black", * "nodeConnectors" : [ * "OF|1@OF|00:00:00:00:00:00:00:01", "OF|23@OF|00:00:00:00:00:00:20:21" @@ -173,13 +183,18 @@ public class ContainerManagerNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 401, condition = "User is not authorized to perform this operation"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public ContainerConfigs viewAllContainers() { + public ContainerConfigs viewAllContainers(@QueryParam("_q") String queryString) { handleNetworkAuthorization(getUserName()); IContainerManager containerManager = getContainerManager(); - - return new ContainerConfigs(containerManager.getContainerConfigList()); + ContainerConfigs result = new ContainerConfigs( + containerManager.getContainerConfigList()); + if (queryString != null) { + queryContext.createQuery(queryString, ContainerConfigs.class) + .filter(result, ContainerConfig.class); + } + return result; } /** @@ -197,16 +212,16 @@ public class ContainerManagerNorthbound { * http://localhost:8080/controller/nb/v2/containermanager/container/blue * * Response body in XML: - * <container-config> + * <containerConfig> * <container>blue</container> * <staticVlan>10</staticVlan> * <nodeConnectors>OF|1@OF|00:00:00:00:00:00:00:01</nodeConnectors> * <nodeConnectors>OF|23@OF|00:00:00:00:00:00:20:21</nodeConnectors> - * </container-config> + * </containerConfig> * * Response body in JSON: * { - * "container-config": [ + * "containerConfig": [ * { * "container": "yellow", * "staticVlan": "10", @@ -260,11 +275,11 @@ public class ContainerManagerNorthbound { * http://localhost:8080/controller/nb/v2/containermanager/container/yellow * * Request body in XML: - * <container-config> + * <containerConfig> * <container>yellow</container> * <staticVlan>10</staticVlan> * <nodeConnectors></nodeConnectors> - * </container-config> + * </containerConfig> * * Request body in JSON: * { @@ -364,6 +379,7 @@ public class ContainerManagerNorthbound { * Response body in XML: * <flow-spec-config> * <name>ssh</name> + * <dlVlan>52</dlVlan> * <nwSrc>10.0.0.101</nwSrc> * <nwDst>10.0.0.102</nwDst> * <protocol>IPv4</protocol> @@ -374,6 +390,7 @@ public class ContainerManagerNorthbound { * Response body in JSON: * { * "protocol" : "IPv4", + * "dlVlan" : "52", * "nwDst" : "10.0.0.102", * "name" : "ssh", * "nwSrc" : "10.0.0.101", @@ -429,6 +446,7 @@ public class ContainerManagerNorthbound { * <flow-spec-configs> * <flow-spec-config> * <name>ssh</name> + * <dlVlan>52</dlVlan> * <nwSrc>10.0.0.101</nwSrc> * <nwDst>10.0.0.102</nwDst> * <protocol>IPv4</protocol> @@ -437,6 +455,7 @@ public class ContainerManagerNorthbound { * </flow-spec-config> * <flow-spec-config> * <name>http2</name> + * <dlVlan>123</dlVlan> * <nwSrc>10.0.0.201</nwSrc> * <nwDst>10.0.0.202</nwDst> * <protocol></protocol> @@ -450,6 +469,7 @@ public class ContainerManagerNorthbound { * "flow-spec-config": [ * { * "name": "http", + * "dlVlan" : "52", * "nwSrc": "10.0.0.201", * "nwDst": "10.0.0.202", * "protocol": "", @@ -458,6 +478,7 @@ public class ContainerManagerNorthbound { * }, * { * "name": "ssh", + * "dlVlan" : "123", * "nwSrc": "10.0.0.101", * "nwDst": "10.0.0.102", * "protocol": "IPv4", @@ -476,7 +497,8 @@ public class ContainerManagerNorthbound { @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"), @ResponseCode(code = 404, condition = "The container is not found"), @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") }) - public FlowSpecConfigs viewContainerFlowSpecs(@PathParam(value = "container") String container) { + public FlowSpecConfigs viewContainerFlowSpecs(@PathParam(value = "container") String container, + @QueryParam("_q") String queryString) { handleContainerAuthorization(container, getUserName()); handleForbiddenOnDefault(container); @@ -484,8 +506,13 @@ public class ContainerManagerNorthbound { handleContainerNotExists(container); IContainerManager containerManager = getContainerManager(); - - return new FlowSpecConfigs(containerManager.getContainerFlows(container)); + FlowSpecConfigs result = new FlowSpecConfigs( + containerManager.getContainerFlows(container)); + if (queryString != null) { + queryContext.createQuery(queryString, FlowSpecConfigs.class) + .filter(result, ContainerFlowConfig.class); + } + return result; } /** @@ -511,6 +538,7 @@ public class ContainerManagerNorthbound { * Request body in XML: * <flow-spec-config> * <name>http</name> + * <dlVlan>25</dlVlan> * <nwSrc>10.0.0.101</nwSrc> * <nwDst>10.0.0.102</nwDst> * <protocol></protocol> @@ -520,10 +548,11 @@ public class ContainerManagerNorthbound { * * Request body in JSON: * { - * "protocol" : "", - * "nwDst" : "10.0.0.102", * "name" : "http", + * "dlVlan" : "25", * "nwSrc" : "10.0.0.101", + * "nwDst" : "10.0.0.102", + * "protocol" : "", * "tpSrc" : "80", * "tpDst" : "100" * }