summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web')
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkCodec.java69
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkWebResource.java66
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortCodec.java107
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortWebResource.java88
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetCodec.java83
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetWebResource.java69
-rw-r--r--framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/package-info.java20
7 files changed, 0 insertions, 502 deletions
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkCodec.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkCodec.java
deleted file mode 100644
index 0a0b5dce..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkCodec.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openstackswitching.web;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.openstackswitching.OpenstackNetwork;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Implementation of the OpenstackNetwork Codec.
- *
- */
-public class OpenstackNetworkCodec extends JsonCodec<OpenstackNetwork> {
-
- protected static final Logger log = LoggerFactory
- .getLogger(OpenstackNetworkCodec.class);
-
- private static final String NETWORK = "network";
- private static final String NAME = "name";
- private static final String TENANT_ID = "tenant_id";
- private static final String SEGMENTATION_ID = "provider:segmentation_id";
- private static final String NETWORK_TYPE = "provider:network_type";
- private static final String ID = "id";
-
- @Override
- public OpenstackNetwork decode(ObjectNode json, CodecContext context) {
-
- JsonNode networkInfo = json.get(NETWORK);
- if (networkInfo == null) {
- networkInfo = json;
- }
-
- String name = networkInfo.path(NAME).asText();
- String tenantId = networkInfo.path(TENANT_ID).asText();
- String id = networkInfo.path(ID).asText();
-
- OpenstackNetwork.Builder onb = OpenstackNetwork.builder();
- onb.name(name)
- .tenantId(tenantId)
- .id(id);
-
- if (!networkInfo.path(NETWORK_TYPE).isMissingNode()) {
- onb.networkType(OpenstackNetwork.NetworkType.valueOf(networkInfo.path(NETWORK_TYPE).
- asText().toUpperCase()));
- onb.name(networkInfo.path(NETWORK_TYPE).asText());
- onb.segmentId(networkInfo.path(SEGMENTATION_ID).asText());
- }
-
- return onb.build();
- }
-
-}
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkWebResource.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkWebResource.java
deleted file mode 100644
index bf04cc4d..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackNetworkWebResource.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openstackswitching.web;
-
-import org.onosproject.rest.AbstractWebResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-
-/**
- * Handles REST API call of Neutron ML2 plugin.
- */
-@Path("networks")
-public class OpenstackNetworkWebResource extends AbstractWebResource {
-
- protected static final Logger log = LoggerFactory
- .getLogger(OpenstackNetworkWebResource.class);
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createNetwork(InputStream input) {
- log.debug("REST API networks is called {}", input.toString());
- return Response.status(Response.Status.OK).build();
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updateNetwork(InputStream input) {
- log.debug("REST API networks is called {}", input.toString());
- return Response.status(Response.Status.OK).build();
- }
-
- @DELETE
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deleteNetwork(InputStream input) {
- log.debug("REST API networks is called {}", input.toString());
- return Response.status(Response.Status.OK).build();
- }
-}
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortCodec.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortCodec.java
deleted file mode 100644
index 63e6d2ea..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortCodec.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openstackswitching.web;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.MacAddress;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.openstackswitching.OpenstackPort;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-
-/**
- * Encodes and decodes the OpenstackPort.
- */
-public class OpenstackPortCodec extends JsonCodec<OpenstackPort> {
-
- private static Logger log = LoggerFactory
- .getLogger(OpenstackPortCodec.class);
-
- // JSON field names
- private static final String PORT = "port";
- private static final String STATUS = "status";
- private static final String NAME = "name";
- private static final String ADDRESS_PAIR = "allowed_address_pairs";
- private static final String ADMIN_STATUS = "admin_status";
- private static final String NETWORK_ID = "network_id";
- private static final String TENANT_ID = "tenant_id";
- private static final String DEVICE_OWNER = "device_owner";
- private static final String MAC_ADDRESS = "mac_address";
- private static final String FIXED_IPS = "fixed_ips";
- private static final String SUBNET_ID = "subnet_id";
- private static final String IP_ADDRESS = "ip_address";
- private static final String ID = "id";
- private static final String SECURITY_GROUPS = "security_groups";
- private static final String DEVICE_ID = "device_id";
-
- @Override
- public OpenstackPort decode(ObjectNode json, CodecContext context) {
-
- HashMap<String, Ip4Address> fixedIpMap = new HashMap<>();
- JsonNode portInfo = json.get(PORT);
- if (portInfo == null) {
- portInfo = json;
- }
-
- String status = portInfo.path(STATUS).asText();
- String name = portInfo.path(NAME).asText();
- boolean adminStateUp = portInfo.path(ADMIN_STATUS).asBoolean();
- String networkId = portInfo.path(NETWORK_ID).asText();
- String tenantId = portInfo.path(TENANT_ID).asText();
- String deviceOwner = portInfo.path(DEVICE_OWNER).asText();
- String macStr = portInfo.path(MAC_ADDRESS).asText();
- ArrayNode fixedIpList = (ArrayNode) portInfo.path(FIXED_IPS);
- for (JsonNode fixedIpInfo: fixedIpList) {
- String subnetId = fixedIpInfo.path(SUBNET_ID).asText();
- String ipAddressStr = fixedIpInfo.path(IP_ADDRESS).asText();
- if (ipAddressStr != null) {
- Ip4Address ipAddress = Ip4Address.valueOf(ipAddressStr);
- fixedIpMap.put(subnetId, ipAddress);
- }
- }
- String id = portInfo.path(ID).asText();
- String securityGroups = portInfo.path(SECURITY_GROUPS).asText();
- String deviceId = portInfo.path(DEVICE_ID).asText();
-
- OpenstackPort.Builder openstackPortBuilder = OpenstackPort.builder();
- openstackPortBuilder.portStatus(OpenstackPort.PortStatus.valueOf(status))
- .name(name)
- .adminState(adminStateUp)
- .netwrokId(networkId)
- .tenantId(tenantId)
- .deviceOwner(deviceOwner)
- .macAddress(MacAddress.valueOf(macStr))
- .fixedIps(fixedIpMap)
- .id(id)
- .deviceId(deviceId);
-
- // FIX ME
- if (!securityGroups.isEmpty()) {
- openstackPortBuilder.securityGroup(securityGroups);
- }
-
- OpenstackPort openstackPort = openstackPortBuilder.build();
-
- return openstackPort;
- }
-
-}
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortWebResource.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortWebResource.java
deleted file mode 100644
index faffa732..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackPortWebResource.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openstackswitching.web;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onosproject.openstackswitching.OpenstackPort;
-import org.onosproject.openstackswitching.OpenstackSwitchingService;
-import org.onosproject.rest.AbstractWebResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-
-/**
- * Handles Rest API call from Neutron ML2 plugin.
- */
-@Path("ports")
-public class OpenstackPortWebResource extends AbstractWebResource {
-
- protected static final Logger log = LoggerFactory
- .getLogger(OpenstackPortWebResource.class);
-
- private static final OpenstackPortCodec PORT_CODEC = new OpenstackPortCodec();
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPorts(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode portNode = (ObjectNode) mapper.readTree(input);
-
- OpenstackPort openstackPort = PORT_CODEC.decode(portNode, this);
- OpenstackSwitchingService switchingService =
- getService(OpenstackSwitchingService.class);
- switchingService.createPorts(openstackPort);
-
- log.debug("REST API ports is called with {}", portNode.toString());
- return Response.status(Response.Status.OK).build();
-
- } catch (Exception e) {
- log.error("Creates Port failed because of exception {}",
- e.toString());
- return Response.status(Response.Status.INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @DELETE
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response deletesPorts(InputStream input) {
- log.debug("REST API ports is called with {}", input.toString());
- return Response.status(Response.Status.OK).build();
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updatePorts(InputStream input) {
- log.info("REST API ports is called with {}", input.toString());
- return Response.status(Response.Status.OK).build();
- }
-}
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetCodec.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetCodec.java
deleted file mode 100644
index 2a7af82a..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetCodec.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openstackswitching.web;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Lists;
-import org.onlab.packet.Ip4Address;
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.openstackswitching.OpenstackSubnet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-
-/**
- * Encodes and decodes the OpenstackSubnet.
- */
-public class OpenstackSubnetCodec extends JsonCodec<OpenstackSubnet> {
- private static Logger log = LoggerFactory
- .getLogger(OpenstackSubnetCodec.class);
-
- // JSON Field names
- private static final String SUBNET = "subnet";
- private static final String NAME = "name";
- private static final String ENABLE_DHCP = "enable_dhcp";
- private static final String NETWORK_ID = "network_id";
- private static final String TENANT_ID = "tenant_id";
- private static final String DNS_NAMESERVERS = "dns_nameservers";
- private static final String GATEWAY_IP = "gateway_ip";
- private static final String CIDR = "cidr";
- private static final String ID = "id";
-
- @Override
- public OpenstackSubnet decode(ObjectNode json, CodecContext context) {
- JsonNode subnetInfo = json.get(SUBNET);
- if (subnetInfo == null) {
- subnetInfo = json;
- }
-
- String name = subnetInfo.path(NAME).asText();
- boolean enableDhcp = subnetInfo.path(ENABLE_DHCP).asBoolean();
- String networkId = subnetInfo.path(NETWORK_ID).asText();
- String tenantId = subnetInfo.path(TENANT_ID).asText();
- ArrayNode dnsNameservsers = (ArrayNode) subnetInfo.path(DNS_NAMESERVERS);
- List<Ip4Address> dnsList = Lists.newArrayList();
- if (dnsNameservsers != null && !dnsNameservsers.isMissingNode()) {
- dnsNameservsers.forEach(dns -> dnsList.add(Ip4Address.valueOf(dns.asText())));
- }
- String gatewayIp = subnetInfo.path(GATEWAY_IP).asText();
- String cidr = subnetInfo.path(CIDR).asText();
- String id = subnetInfo.path(ID).asText();
-
- OpenstackSubnet openstackSubnet = OpenstackSubnet.builder()
- .setName(name)
- .setEnableDhcp(enableDhcp)
- .setNetworkId(networkId)
- .setTenantId(tenantId)
- .setDnsNameservers(dnsList)
- .setGatewayIp(gatewayIp)
- .setCidr(cidr)
- .setId(id)
- .build();
- return openstackSubnet;
- }
-}
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetWebResource.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetWebResource.java
deleted file mode 100644
index 43205eac..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/OpenstackSubnetWebResource.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.openstackswitching.web;
-
-/**
- * Handles Rest API call from Neutron ML2 plugin.
- */
-import org.onosproject.rest.AbstractWebResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-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.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.InputStream;
-
-@Path("subnets")
-public class OpenstackSubnetWebResource extends AbstractWebResource {
- protected static final Logger log = LoggerFactory
- .getLogger(OpenstackSubnetWebResource.class);
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createSubnet(InputStream input) {
- return Response.status(Response.Status.OK).build();
- }
-
-
- @PUT
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateSubnet(@PathParam("id") String id,
- final InputStream input) {
- return Response.status(Response.Status.OK).build();
-
- }
-
- @DELETE
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response deleteSubnet(@PathParam("id") String id,
- final InputStream input) {
- return Response.status(Response.Status.OK).build();
- }
-
-
-}
diff --git a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/package-info.java b/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/package-info.java
deleted file mode 100644
index 91e19c62..00000000
--- a/framework/src/onos/apps/openstackswitching/app/src/main/java/org/onosproject/openstackswitching/web/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * OpenStack switching REST API.
- */
-package org.onosproject.openstackswitching.web;