Committed by
Gerrit Code Review
[ONOS-2736] Fix bug of getting json from subnet.
Change-Id: I386f622fba74f0303a5ed9e6820ebc68a817021d
Showing
4 changed files
with
14 additions
and
8 deletions
... | @@ -32,15 +32,19 @@ public final class SubnetCodec extends JsonCodec<Subnet> { | ... | @@ -32,15 +32,19 @@ public final class SubnetCodec extends JsonCodec<Subnet> { |
32 | checkNotNull(subnet, "Subnet cannot be null"); | 32 | checkNotNull(subnet, "Subnet cannot be null"); |
33 | ObjectNode result = context.mapper().createObjectNode() | 33 | ObjectNode result = context.mapper().createObjectNode() |
34 | .put("id", subnet.id().toString()) | 34 | .put("id", subnet.id().toString()) |
35 | - .put("gate_ip", subnet.gatewayIp().toString()) | 35 | + .put("gateway_ip", subnet.gatewayIp().toString()) |
36 | .put("network_id", subnet.networkId().toString()) | 36 | .put("network_id", subnet.networkId().toString()) |
37 | .put("name", subnet.subnetName().toString()) | 37 | .put("name", subnet.subnetName().toString()) |
38 | .put("ip_version", subnet.ipVersion().toString()) | 38 | .put("ip_version", subnet.ipVersion().toString()) |
39 | .put("cidr", subnet.cidr().toString()) | 39 | .put("cidr", subnet.cidr().toString()) |
40 | .put("shared", subnet.shared()) | 40 | .put("shared", subnet.shared()) |
41 | .put("enabled_dchp", subnet.dhcpEnabled()) | 41 | .put("enabled_dchp", subnet.dhcpEnabled()) |
42 | - .put("tenant_id", subnet.tenantId().toString()); | 42 | + .put("tenant_id", subnet.tenantId().toString()) |
43 | - result.set("alloction_pools", new AllocationPoolsCodec().encode(subnet | 43 | + .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null |
44 | + : subnet.ipV6AddressMode().toString()) | ||
45 | + .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null | ||
46 | + : subnet.ipV6RaMode().toString()); | ||
47 | + result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet | ||
44 | .allocationPools(), context)); | 48 | .allocationPools(), context)); |
45 | result.set("host_routes", | 49 | result.set("host_routes", |
46 | new HostRoutesCodec().encode(subnet.hostRoutes(), context)); | 50 | new HostRoutesCodec().encode(subnet.hostRoutes(), context)); | ... | ... |
... | @@ -226,8 +226,8 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -226,8 +226,8 @@ public class SubnetWebResource extends AbstractWebResource { |
226 | */ | 226 | */ |
227 | public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) { | 227 | public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) { |
228 | checkNotNull(subnetNodes, JSON_NOT_NULL); | 228 | checkNotNull(subnetNodes, JSON_NOT_NULL); |
229 | - checkArgument(!subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean"); | 229 | + checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean"); |
230 | - checkArgument(!subnetNodes.get("shared").isBoolean(), "shared should be boolean"); | 230 | + checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean"); |
231 | Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>(); | 231 | Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>(); |
232 | if (!subnetNodes.hasNonNull("id")) { | 232 | if (!subnetNodes.hasNonNull("id")) { |
233 | return null; | 233 | return null; | ... | ... |
... | @@ -269,9 +269,9 @@ public class TenantNetworkWebResource extends AbstractWebResource { | ... | @@ -269,9 +269,9 @@ public class TenantNetworkWebResource extends AbstractWebResource { |
269 | ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps | 269 | ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps |
270 | .newConcurrentMap(); | 270 | .newConcurrentMap(); |
271 | if (node != null) { | 271 | if (node != null) { |
272 | - checkArgument(!node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean"); | 272 | + checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean"); |
273 | - checkArgument(!node.get("shared").isBoolean(), "shared should be boolean"); | 273 | + checkArgument(node.get("shared").isBoolean(), "shared should be boolean"); |
274 | - checkArgument(!node.get("router:external").isBoolean(), "router:external should be boolean"); | 274 | + checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean"); |
275 | String name = node.get("name").asText(); | 275 | String name = node.get("name").asText(); |
276 | boolean adminStateUp = node.get("admin_state_up").asBoolean(); | 276 | boolean adminStateUp = node.get("admin_state_up").asBoolean(); |
277 | String state = node.get("status").asText(); | 277 | String state = node.get("status").asText(); | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnweb.resources; | 16 | package org.onosproject.vtnweb.resources; |
17 | 17 | ||
18 | +import static com.google.common.base.Preconditions.checkArgument; | ||
18 | import static com.google.common.base.Preconditions.checkNotNull; | 19 | import static com.google.common.base.Preconditions.checkNotNull; |
19 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; | 20 | import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR; |
20 | import static javax.ws.rs.core.Response.Status.OK; | 21 | import static javax.ws.rs.core.Response.Status.OK; |
... | @@ -209,6 +210,7 @@ public class VirtualPortWebResource extends AbstractWebResource { | ... | @@ -209,6 +210,7 @@ public class VirtualPortWebResource extends AbstractWebResource { |
209 | .asText()); | 210 | .asText()); |
210 | TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode | 211 | TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode |
211 | .get("network_id").asText()); | 212 | .get("network_id").asText()); |
213 | + checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean"); | ||
212 | Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean(); | 214 | Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean(); |
213 | String state = vPortnode.get("status").asText(); | 215 | String state = vPortnode.get("status").asText(); |
214 | MacAddress macAddress = MacAddress.valueOf(vPortnode | 216 | MacAddress macAddress = MacAddress.valueOf(vPortnode | ... | ... |
-
Please register or login to post a comment