Committed by
Gerrit Code Review
ONOS-2843 Fix bug post NBI subnet get an error.
Change-Id: I93b52a0c69a57b458b610afbb78cfdec0b50e3a5
Showing
10 changed files
with
36 additions
and
29 deletions
... | @@ -18,6 +18,7 @@ package org.onosproject.vtnrsc; | ... | @@ -18,6 +18,7 @@ package org.onosproject.vtnrsc; |
18 | import static com.google.common.base.MoreObjects.toStringHelper; | 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
19 | 19 | ||
20 | import java.util.Objects; | 20 | import java.util.Objects; |
21 | +import java.util.Set; | ||
21 | 22 | ||
22 | import org.onlab.packet.IpAddress; | 23 | import org.onlab.packet.IpAddress; |
23 | import org.onlab.packet.IpAddress.Version; | 24 | import org.onlab.packet.IpAddress.Version; |
... | @@ -38,8 +39,8 @@ public final class DefaultSubnet implements Subnet { | ... | @@ -38,8 +39,8 @@ public final class DefaultSubnet implements Subnet { |
38 | private final boolean shared; | 39 | private final boolean shared; |
39 | private final Mode ipV6AddressMode; | 40 | private final Mode ipV6AddressMode; |
40 | private final Mode ipV6RaMode; | 41 | private final Mode ipV6RaMode; |
41 | - private final Iterable<HostRoute> hostRoutes; | 42 | + private final Set<HostRoute> hostRoutes; |
42 | - private final Iterable<AllocationPool> allocationPools; | 43 | + private final Set<AllocationPool> allocationPools; |
43 | 44 | ||
44 | /** | 45 | /** |
45 | * Creates a subnet object. | 46 | * Creates a subnet object. |
... | @@ -64,9 +65,9 @@ public final class DefaultSubnet implements Subnet { | ... | @@ -64,9 +65,9 @@ public final class DefaultSubnet implements Subnet { |
64 | TenantNetworkId networkId, TenantId tenantId, | 65 | TenantNetworkId networkId, TenantId tenantId, |
65 | Version ipVersion, IpPrefix cidr, IpAddress gatewayIp, | 66 | Version ipVersion, IpPrefix cidr, IpAddress gatewayIp, |
66 | boolean dhcpEnabled, boolean shared, | 67 | boolean dhcpEnabled, boolean shared, |
67 | - Iterable<HostRoute> hostRoutes, Mode ipV6AddressMode, | 68 | + Set<HostRoute> hostRoutes, Mode ipV6AddressMode, |
68 | Mode ipV6RaMode, | 69 | Mode ipV6RaMode, |
69 | - Iterable<AllocationPool> allocationPoolsIt) { | 70 | + Set<AllocationPool> allocationPoolsIt) { |
70 | this.id = id; | 71 | this.id = id; |
71 | this.subnetName = subnetName; | 72 | this.subnetName = subnetName; |
72 | this.networkId = networkId; | 73 | this.networkId = networkId; | ... | ... |
... | @@ -43,8 +43,8 @@ public final class DefaultVirtualPort implements VirtualPort { | ... | @@ -43,8 +43,8 @@ public final class DefaultVirtualPort implements VirtualPort { |
43 | private final String bindingVnicType; | 43 | private final String bindingVnicType; |
44 | private final String bindingVifType; | 44 | private final String bindingVifType; |
45 | private final String bindingVifDetails; | 45 | private final String bindingVifDetails; |
46 | - private final Collection<AllowedAddressPair> allowedAddressPairs; | 46 | + private final Set<AllowedAddressPair> allowedAddressPairs; |
47 | - private final Collection<SecurityGroup> securityGroups; | 47 | + private final Set<SecurityGroup> securityGroups; |
48 | 48 | ||
49 | /** | 49 | /** |
50 | * Creates a VirtualPort object. | 50 | * Creates a VirtualPort object. |
... | @@ -72,8 +72,8 @@ public final class DefaultVirtualPort implements VirtualPort { | ... | @@ -72,8 +72,8 @@ public final class DefaultVirtualPort implements VirtualPort { |
72 | DeviceId deviceId, | 72 | DeviceId deviceId, |
73 | Set<FixedIp> fixedIps, | 73 | Set<FixedIp> fixedIps, |
74 | BindingHostId bindingHostId, | 74 | BindingHostId bindingHostId, |
75 | - Collection<AllowedAddressPair> allowedAddressPairs, | 75 | + Set<AllowedAddressPair> allowedAddressPairs, |
76 | - Collection<SecurityGroup> securityGroups) { | 76 | + Set<SecurityGroup> securityGroups) { |
77 | this.id = id; | 77 | this.id = id; |
78 | this.networkId = networkId; | 78 | this.networkId = networkId; |
79 | this.adminStateUp = adminStateUp; | 79 | this.adminStateUp = adminStateUp; | ... | ... |
... | @@ -88,11 +88,11 @@ public class SubnetCreateCommand extends AbstractShellCommand { | ... | @@ -88,11 +88,11 @@ public class SubnetCreateCommand extends AbstractShellCommand { |
88 | 88 | ||
89 | @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes", | 89 | @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes", |
90 | required = false, multiValued = false) | 90 | required = false, multiValued = false) |
91 | - Iterable<HostRoute> hostRoutes = null; | 91 | + Set<HostRoute> hostRoutes = Sets.newHashSet(); |
92 | 92 | ||
93 | @Option(name = "-a", aliases = "--allocationPools", | 93 | @Option(name = "-a", aliases = "--allocationPools", |
94 | description = "Subnet jsonnode allocationPools", required = false, multiValued = false) | 94 | description = "Subnet jsonnode allocationPools", required = false, multiValued = false) |
95 | - Iterable<AllocationPool> allocationPools = Sets.newHashSet(); | 95 | + Set<AllocationPool> allocationPools = Sets.newHashSet(); |
96 | 96 | ||
97 | @Override | 97 | @Override |
98 | protected void execute() { | 98 | protected void execute() { | ... | ... |
... | @@ -88,11 +88,11 @@ public class SubnetUpdateCommand extends AbstractShellCommand { | ... | @@ -88,11 +88,11 @@ public class SubnetUpdateCommand extends AbstractShellCommand { |
88 | 88 | ||
89 | @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes", | 89 | @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes", |
90 | required = false, multiValued = false) | 90 | required = false, multiValued = false) |
91 | - Iterable<HostRoute> hostRoutes = null; | 91 | + Set<HostRoute> hostRoutes = Sets.newHashSet(); |
92 | 92 | ||
93 | @Option(name = "-a", aliases = "--allocationPools", | 93 | @Option(name = "-a", aliases = "--allocationPools", |
94 | description = "Subnet jsonnode allocationPools", required = false, multiValued = false) | 94 | description = "Subnet jsonnode allocationPools", required = false, multiValued = false) |
95 | - Iterable<AllocationPool> allocationPools = Sets.newHashSet();; | 95 | + Set<AllocationPool> allocationPools = Sets.newHashSet();; |
96 | 96 | ||
97 | @Override | 97 | @Override |
98 | protected void execute() { | 98 | protected void execute() { | ... | ... |
... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnrsc.cli.virtualport; | 16 | package org.onosproject.vtnrsc.cli.virtualport; |
17 | 17 | ||
18 | -import java.util.Collection; | ||
19 | import java.util.Map; | 18 | import java.util.Map; |
20 | import java.util.Set; | 19 | import java.util.Set; |
21 | 20 | ||
... | @@ -106,11 +105,11 @@ public class VirtualPortCreateCommand extends AbstractShellCommand { | ... | @@ -106,11 +105,11 @@ public class VirtualPortCreateCommand extends AbstractShellCommand { |
106 | 105 | ||
107 | @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.", | 106 | @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.", |
108 | required = false, multiValued = false) | 107 | required = false, multiValued = false) |
109 | - Collection<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet(); | 108 | + Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet(); |
110 | 109 | ||
111 | @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.", | 110 | @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.", |
112 | required = false, multiValued = false) | 111 | required = false, multiValued = false) |
113 | - Collection<SecurityGroup> securityGroups = Sets.newHashSet(); | 112 | + Set<SecurityGroup> securityGroups = Sets.newHashSet(); |
114 | 113 | ||
115 | @Override | 114 | @Override |
116 | protected void execute() { | 115 | protected void execute() { | ... | ... |
... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.vtnrsc.cli.virtualport; | 16 | package org.onosproject.vtnrsc.cli.virtualport; |
17 | 17 | ||
18 | -import java.util.Collection; | ||
19 | import java.util.Map; | 18 | import java.util.Map; |
20 | import java.util.Set; | 19 | import java.util.Set; |
21 | 20 | ||
... | @@ -107,11 +106,11 @@ public class VirtualPortUpdateCommand extends AbstractShellCommand { | ... | @@ -107,11 +106,11 @@ public class VirtualPortUpdateCommand extends AbstractShellCommand { |
107 | 106 | ||
108 | @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.", | 107 | @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.", |
109 | required = false, multiValued = false) | 108 | required = false, multiValued = false) |
110 | - Collection<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet(); | 109 | + Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet(); |
111 | 110 | ||
112 | @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.", | 111 | @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.", |
113 | required = false, multiValued = false) | 112 | required = false, multiValued = false) |
114 | - Collection<SecurityGroup> securityGroups = Sets.newHashSet(); | 113 | + Set<SecurityGroup> securityGroups = Sets.newHashSet(); |
115 | 114 | ||
116 | @Override | 115 | @Override |
117 | protected void execute() { | 116 | protected void execute() { | ... | ... |
... | @@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Deactivate; | ... | @@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Deactivate; |
21 | import org.apache.felix.scr.annotations.Reference; | 21 | import org.apache.felix.scr.annotations.Reference; |
22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
23 | import org.apache.felix.scr.annotations.Service; | 23 | import org.apache.felix.scr.annotations.Service; |
24 | +import org.onlab.packet.IpAddress; | ||
24 | import org.onosproject.core.ApplicationId; | 25 | import org.onosproject.core.ApplicationId; |
25 | import org.onosproject.core.CoreService; | 26 | import org.onosproject.core.CoreService; |
26 | import org.onosproject.store.serializers.KryoNamespaces; | 27 | import org.onosproject.store.serializers.KryoNamespaces; |
27 | import org.onosproject.store.service.Serializer; | 28 | import org.onosproject.store.service.Serializer; |
28 | import org.onosproject.store.service.StorageService; | 29 | import org.onosproject.store.service.StorageService; |
29 | import org.onosproject.vtnrsc.AllocationPool; | 30 | import org.onosproject.vtnrsc.AllocationPool; |
31 | +import org.onosproject.vtnrsc.DefaultSubnet; | ||
30 | import org.onosproject.vtnrsc.HostRoute; | 32 | import org.onosproject.vtnrsc.HostRoute; |
31 | import org.onosproject.vtnrsc.Subnet; | 33 | import org.onosproject.vtnrsc.Subnet; |
32 | import org.onosproject.vtnrsc.SubnetId; | 34 | import org.onosproject.vtnrsc.SubnetId; |
... | @@ -86,7 +88,9 @@ public class SubnetManager implements SubnetService { | ... | @@ -86,7 +88,9 @@ public class SubnetManager implements SubnetService { |
86 | TenantId.class, | 88 | TenantId.class, |
87 | HostRoute.class, | 89 | HostRoute.class, |
88 | Subnet.Mode.class, | 90 | Subnet.Mode.class, |
89 | - AllocationPool.class)) | 91 | + AllocationPool.class, |
92 | + DefaultSubnet.class, | ||
93 | + IpAddress.Version.class)) | ||
90 | .build().asJavaMap(); | 94 | .build().asJavaMap(); |
91 | 95 | ||
92 | log.info("Started"); | 96 | log.info("Started"); | ... | ... |
... | @@ -30,6 +30,7 @@ import org.onosproject.store.service.Serializer; | ... | @@ -30,6 +30,7 @@ import org.onosproject.store.service.Serializer; |
30 | import org.onosproject.store.service.StorageService; | 30 | import org.onosproject.store.service.StorageService; |
31 | import org.onosproject.vtnrsc.AllowedAddressPair; | 31 | import org.onosproject.vtnrsc.AllowedAddressPair; |
32 | import org.onosproject.vtnrsc.BindingHostId; | 32 | import org.onosproject.vtnrsc.BindingHostId; |
33 | +import org.onosproject.vtnrsc.DefaultVirtualPort; | ||
33 | import org.onosproject.vtnrsc.FixedIp; | 34 | import org.onosproject.vtnrsc.FixedIp; |
34 | import org.onosproject.vtnrsc.SecurityGroup; | 35 | import org.onosproject.vtnrsc.SecurityGroup; |
35 | import org.onosproject.vtnrsc.SubnetId; | 36 | import org.onosproject.vtnrsc.SubnetId; |
... | @@ -98,7 +99,8 @@ public class VirtualPortManager implements VirtualPortService { | ... | @@ -98,7 +99,8 @@ public class VirtualPortManager implements VirtualPortService { |
98 | BindingHostId.class, | 99 | BindingHostId.class, |
99 | SecurityGroup.class, | 100 | SecurityGroup.class, |
100 | SubnetId.class, | 101 | SubnetId.class, |
101 | - IpAddress.class)) | 102 | + IpAddress.class, |
103 | + DefaultVirtualPort.class)) | ||
102 | .build().asJavaMap(); | 104 | .build().asJavaMap(); |
103 | log.info("Started"); | 105 | log.info("Started"); |
104 | } | 106 | } | ... | ... |
... | @@ -63,6 +63,7 @@ import com.fasterxml.jackson.databind.JsonNode; | ... | @@ -63,6 +63,7 @@ import com.fasterxml.jackson.databind.JsonNode; |
63 | import com.fasterxml.jackson.databind.ObjectMapper; | 63 | import com.fasterxml.jackson.databind.ObjectMapper; |
64 | import com.fasterxml.jackson.databind.node.ObjectNode; | 64 | import com.fasterxml.jackson.databind.node.ObjectNode; |
65 | import com.google.common.collect.Maps; | 65 | import com.google.common.collect.Maps; |
66 | +import com.google.common.collect.Sets; | ||
66 | 67 | ||
67 | @Path("subnets") | 68 | @Path("subnets") |
68 | public class SubnetWebResource extends AbstractWebResource { | 69 | public class SubnetWebResource extends AbstractWebResource { |
... | @@ -211,8 +212,8 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -211,8 +212,8 @@ public class SubnetWebResource extends AbstractWebResource { |
211 | Subnet subnet = new DefaultSubnet(id, subnetName, networkId, | 212 | Subnet subnet = new DefaultSubnet(id, subnetName, networkId, |
212 | tenantId, ipVersion, cidr, | 213 | tenantId, ipVersion, cidr, |
213 | gatewayIp, dhcpEnabled, shared, | 214 | gatewayIp, dhcpEnabled, shared, |
214 | - hostRoutesIt, ipV6AddressMode, | 215 | + Sets.newHashSet(hostRoutesIt), ipV6AddressMode, |
215 | - ipV6RaMode, allocationPoolsIt); | 216 | + ipV6RaMode, Sets.newHashSet(allocationPoolsIt)); |
216 | subMap.put(id, subnet); | 217 | subMap.put(id, subnet); |
217 | } | 218 | } |
218 | return Collections.unmodifiableCollection(subMap.values()); | 219 | return Collections.unmodifiableCollection(subMap.values()); |
... | @@ -267,9 +268,9 @@ public class SubnetWebResource extends AbstractWebResource { | ... | @@ -267,9 +268,9 @@ public class SubnetWebResource extends AbstractWebResource { |
267 | 268 | ||
268 | Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId, | 269 | Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId, |
269 | ipVersion, cidr, gatewayIp, | 270 | ipVersion, cidr, gatewayIp, |
270 | - dhcpEnabled, shared, hostRoutesIt, | 271 | + dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt), |
271 | ipV6AddressMode, ipV6RaMode, | 272 | ipV6AddressMode, ipV6RaMode, |
272 | - allocationPoolsIt); | 273 | + Sets.newHashSet(allocationPoolsIt)); |
273 | subMap.put(id, subnet); | 274 | subMap.put(id, subnet); |
274 | return Collections.unmodifiableCollection(subMap.values()); | 275 | return Collections.unmodifiableCollection(subMap.values()); |
275 | } | 276 | } | ... | ... |
... | @@ -54,8 +54,8 @@ import org.onosproject.vtnrsc.SubnetId; | ... | @@ -54,8 +54,8 @@ import org.onosproject.vtnrsc.SubnetId; |
54 | import org.onosproject.vtnrsc.TenantId; | 54 | import org.onosproject.vtnrsc.TenantId; |
55 | import org.onosproject.vtnrsc.TenantNetworkId; | 55 | import org.onosproject.vtnrsc.TenantNetworkId; |
56 | import org.onosproject.vtnrsc.VirtualPort; | 56 | import org.onosproject.vtnrsc.VirtualPort; |
57 | -import org.onosproject.vtnrsc.VirtualPortId; | ||
58 | import org.onosproject.vtnrsc.VirtualPort.State; | 57 | import org.onosproject.vtnrsc.VirtualPort.State; |
58 | +import org.onosproject.vtnrsc.VirtualPortId; | ||
59 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; | 59 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
60 | import org.onosproject.vtnrsc.web.VirtualPortCodec; | 60 | import org.onosproject.vtnrsc.web.VirtualPortCodec; |
61 | import org.slf4j.Logger; | 61 | import org.slf4j.Logger; |
... | @@ -65,6 +65,7 @@ import com.fasterxml.jackson.databind.JsonNode; | ... | @@ -65,6 +65,7 @@ import com.fasterxml.jackson.databind.JsonNode; |
65 | import com.fasterxml.jackson.databind.ObjectMapper; | 65 | import com.fasterxml.jackson.databind.ObjectMapper; |
66 | import com.fasterxml.jackson.databind.node.ObjectNode; | 66 | import com.fasterxml.jackson.databind.node.ObjectNode; |
67 | import com.google.common.collect.Maps; | 67 | import com.google.common.collect.Maps; |
68 | +import com.google.common.collect.Sets; | ||
68 | 69 | ||
69 | /** | 70 | /** |
70 | * REST resource for interacting with the inventory of infrastructure | 71 | * REST resource for interacting with the inventory of infrastructure |
... | @@ -249,8 +250,8 @@ public class VirtualPortWebResource extends AbstractWebResource { | ... | @@ -249,8 +250,8 @@ public class VirtualPortWebResource extends AbstractWebResource { |
249 | macAddress, tenantId, | 250 | macAddress, tenantId, |
250 | deviceId, fixedIps, | 251 | deviceId, fixedIps, |
251 | bindingHostId, | 252 | bindingHostId, |
252 | - allowedAddressPairs, | 253 | + Sets.newHashSet(allowedAddressPairs), |
253 | - securityGroups); | 254 | + Sets.newHashSet(securityGroups)); |
254 | portMap.put(id, vPort); | 255 | portMap.put(id, vPort); |
255 | } | 256 | } |
256 | return Collections.unmodifiableCollection(portMap.values()); | 257 | return Collections.unmodifiableCollection(portMap.values()); |
... | @@ -308,8 +309,8 @@ public class VirtualPortWebResource extends AbstractWebResource { | ... | @@ -308,8 +309,8 @@ public class VirtualPortWebResource extends AbstractWebResource { |
308 | macAddress, tenantId, | 309 | macAddress, tenantId, |
309 | deviceId, fixedIps, | 310 | deviceId, fixedIps, |
310 | bindingHostId, | 311 | bindingHostId, |
311 | - allowedAddressPairs, | 312 | + Sets.newHashSet(allowedAddressPairs), |
312 | - securityGroups); | 313 | + Sets.newHashSet(securityGroups)); |
313 | vportMap.put(id, vPort); | 314 | vportMap.put(id, vPort); |
314 | 315 | ||
315 | return Collections.unmodifiableCollection(vportMap.values()); | 316 | return Collections.unmodifiableCollection(vportMap.values()); | ... | ... |
-
Please register or login to post a comment