Committed by
Gerrit Code Review
[ONOS-2871]update VTN's bug: docking the neutron's interface, when get
the value is empty, should return a 404 error Change-Id: I939191d44387cb3160b1cb325b7fb261dd916a9b
Showing
3 changed files
with
25 additions
and
7 deletions
... | @@ -18,6 +18,7 @@ package org.onosproject.vtnweb.resources; | ... | @@ -18,6 +18,7 @@ package org.onosproject.vtnweb.resources; |
18 | import static com.google.common.base.Preconditions.checkArgument; | 18 | import static com.google.common.base.Preconditions.checkArgument; |
19 | import static com.google.common.base.Preconditions.checkNotNull; | 19 | import static com.google.common.base.Preconditions.checkNotNull; |
20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; | 20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; |
21 | +import static javax.ws.rs.core.Response.Status.NOT_FOUND; | ||
21 | 22 | ||
22 | import java.io.IOException; | 23 | import java.io.IOException; |
23 | import java.io.InputStream; | 24 | import java.io.InputStream; |
... | @@ -87,7 +88,8 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -87,7 +88,8 @@ public class SubnetWebResource extends AbstractWebResource { |
87 | public Response getSubnet(@PathParam("subnetUUID") String id) { | 88 | public Response getSubnet(@PathParam("subnetUUID") String id) { |
88 | 89 | ||
89 | if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) { | 90 | if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) { |
90 | - return ok("The subnet does not exists").build(); | 91 | + return Response.status(NOT_FOUND) |
92 | + .entity(SUBNET_NOT_FOUND).build(); | ||
91 | } | 93 | } |
92 | Subnet sub = nullIsNotFound(get(SubnetService.class) | 94 | Subnet sub = nullIsNotFound(get(SubnetService.class) |
93 | .getSubnet(SubnetId.subnetId(id)), | 95 | .getSubnet(SubnetId.subnetId(id)), |
... | @@ -112,7 +114,8 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -112,7 +114,8 @@ public class SubnetWebResource extends AbstractWebResource { |
112 | SUBNET_NOT_CREATE); | 114 | SUBNET_NOT_CREATE); |
113 | 115 | ||
114 | if (!result) { | 116 | if (!result) { |
115 | - return Response.status(204).entity(SUBNET_NOT_CREATE).build(); | 117 | + return Response.status(INTERNAL_SERVER_ERROR) |
118 | + .entity(SUBNET_NOT_CREATE).build(); | ||
116 | } | 119 | } |
117 | return Response.status(202).entity(result.toString()).build(); | 120 | return Response.status(202).entity(result.toString()).build(); |
118 | } catch (Exception e) { | 121 | } catch (Exception e) { |
... | @@ -134,7 +137,8 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -134,7 +137,8 @@ public class SubnetWebResource extends AbstractWebResource { |
134 | Boolean result = nullIsNotFound(get(SubnetService.class) | 137 | Boolean result = nullIsNotFound(get(SubnetService.class) |
135 | .updateSubnets(subnets), SUBNET_NOT_FOUND); | 138 | .updateSubnets(subnets), SUBNET_NOT_FOUND); |
136 | if (!result) { | 139 | if (!result) { |
137 | - return Response.status(204).entity(SUBNET_NOT_FOUND).build(); | 140 | + return Response.status(INTERNAL_SERVER_ERROR) |
141 | + .entity(SUBNET_NOT_FOUND).build(); | ||
138 | } | 142 | } |
139 | return Response.status(203).entity(result.toString()).build(); | 143 | return Response.status(203).entity(result.toString()).build(); |
140 | } catch (Exception e) { | 144 | } catch (Exception e) { |
... | @@ -194,8 +198,18 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -194,8 +198,18 @@ public class SubnetWebResource extends AbstractWebResource { |
194 | .tenantId(subnetNode.get("tenant_id").asText()); | 198 | .tenantId(subnetNode.get("tenant_id").asText()); |
195 | TenantNetworkId networkId = TenantNetworkId | 199 | TenantNetworkId networkId = TenantNetworkId |
196 | .networkId(subnetNode.get("network_id").asText()); | 200 | .networkId(subnetNode.get("network_id").asText()); |
197 | - Version ipVersion = Version | 201 | + String version = subnetNode.get("ip_version").asText(); |
198 | - .valueOf(subnetNode.get("ip_version").asText()); | 202 | + Version ipVersion; |
203 | + switch (version) { | ||
204 | + case "4": | ||
205 | + ipVersion = Version.INET; | ||
206 | + break; | ||
207 | + case "6": | ||
208 | + ipVersion = Version.INET; | ||
209 | + break; | ||
210 | + default: | ||
211 | + throw new IllegalArgumentException("ipVersion should be 4 or 6."); | ||
212 | + } | ||
199 | IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText()); | 213 | IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText()); |
200 | IpAddress gatewayIp = IpAddress | 214 | IpAddress gatewayIp = IpAddress |
201 | .valueOf(subnetNode.get("gateway_ip").asText()); | 215 | .valueOf(subnetNode.get("gateway_ip").asText()); | ... | ... |
... | @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
19 | import static com.google.common.base.Preconditions.checkArgument; | 19 | import static com.google.common.base.Preconditions.checkArgument; |
20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; | 20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; |
21 | import static javax.ws.rs.core.Response.Status.OK; | 21 | import static javax.ws.rs.core.Response.Status.OK; |
22 | +import static javax.ws.rs.core.Response.Status.NOT_FOUND; | ||
22 | 23 | ||
23 | import java.io.InputStream; | 24 | import java.io.InputStream; |
24 | import java.util.Collections; | 25 | import java.util.Collections; |
... | @@ -150,7 +151,8 @@ public class TenantNetworkWebResource extends AbstractWebResource { | ... | @@ -150,7 +151,8 @@ public class TenantNetworkWebResource extends AbstractWebResource { |
150 | 151 | ||
151 | if (!get(TenantNetworkService.class).exists(TenantNetworkId | 152 | if (!get(TenantNetworkService.class).exists(TenantNetworkId |
152 | .networkId(id))) { | 153 | .networkId(id))) { |
153 | - return ok("The tenantNetwork does not exists").build(); | 154 | + return Response.status(NOT_FOUND) |
155 | + .entity(NETWORK_NOT_FOUND).build(); | ||
154 | } | 156 | } |
155 | TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class) | 157 | TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class) |
156 | .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND); | 158 | .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND); | ... | ... |
... | @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument; | ... | @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkArgument; |
19 | import static com.google.common.base.Preconditions.checkNotNull; | 19 | import static com.google.common.base.Preconditions.checkNotNull; |
20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; | 20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; |
21 | import static javax.ws.rs.core.Response.Status.OK; | 21 | import static javax.ws.rs.core.Response.Status.OK; |
22 | +import static javax.ws.rs.core.Response.Status.NOT_FOUND; | ||
22 | 23 | ||
23 | import java.io.InputStream; | 24 | import java.io.InputStream; |
24 | import java.util.Collection; | 25 | import java.util.Collection; |
... | @@ -96,7 +97,8 @@ public class VirtualPortWebResource extends AbstractWebResource { | ... | @@ -96,7 +97,8 @@ public class VirtualPortWebResource extends AbstractWebResource { |
96 | public Response getportsById(@PathParam("id") String id) { | 97 | public Response getportsById(@PathParam("id") String id) { |
97 | 98 | ||
98 | if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) { | 99 | if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) { |
99 | - return ok("The virtualPort does not exists").build(); | 100 | + return Response.status(NOT_FOUND) |
101 | + .entity(VPORT_NOT_FOUND).build(); | ||
100 | } | 102 | } |
101 | VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class) | 103 | VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class) |
102 | .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND); | 104 | .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND); | ... | ... |
-
Please register or login to post a comment