jiangrui
Committed by Gerrit Code Review

ONOS-2843 Fix bug post NBI subnet get an error.

Change-Id: I93b52a0c69a57b458b610afbb78cfdec0b50e3a5
......@@ -18,6 +18,7 @@ package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Objects;
import java.util.Set;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpAddress.Version;
......@@ -38,8 +39,8 @@ public final class DefaultSubnet implements Subnet {
private final boolean shared;
private final Mode ipV6AddressMode;
private final Mode ipV6RaMode;
private final Iterable<HostRoute> hostRoutes;
private final Iterable<AllocationPool> allocationPools;
private final Set<HostRoute> hostRoutes;
private final Set<AllocationPool> allocationPools;
/**
* Creates a subnet object.
......@@ -64,9 +65,9 @@ public final class DefaultSubnet implements Subnet {
TenantNetworkId networkId, TenantId tenantId,
Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
boolean dhcpEnabled, boolean shared,
Iterable<HostRoute> hostRoutes, Mode ipV6AddressMode,
Set<HostRoute> hostRoutes, Mode ipV6AddressMode,
Mode ipV6RaMode,
Iterable<AllocationPool> allocationPoolsIt) {
Set<AllocationPool> allocationPoolsIt) {
this.id = id;
this.subnetName = subnetName;
this.networkId = networkId;
......
......@@ -43,8 +43,8 @@ public final class DefaultVirtualPort implements VirtualPort {
private final String bindingVnicType;
private final String bindingVifType;
private final String bindingVifDetails;
private final Collection<AllowedAddressPair> allowedAddressPairs;
private final Collection<SecurityGroup> securityGroups;
private final Set<AllowedAddressPair> allowedAddressPairs;
private final Set<SecurityGroup> securityGroups;
/**
* Creates a VirtualPort object.
......@@ -72,8 +72,8 @@ public final class DefaultVirtualPort implements VirtualPort {
DeviceId deviceId,
Set<FixedIp> fixedIps,
BindingHostId bindingHostId,
Collection<AllowedAddressPair> allowedAddressPairs,
Collection<SecurityGroup> securityGroups) {
Set<AllowedAddressPair> allowedAddressPairs,
Set<SecurityGroup> securityGroups) {
this.id = id;
this.networkId = networkId;
this.adminStateUp = adminStateUp;
......
......@@ -88,11 +88,11 @@ public class SubnetCreateCommand extends AbstractShellCommand {
@Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
required = false, multiValued = false)
Iterable<HostRoute> hostRoutes = null;
Set<HostRoute> hostRoutes = Sets.newHashSet();
@Option(name = "-a", aliases = "--allocationPools",
description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
Iterable<AllocationPool> allocationPools = Sets.newHashSet();
Set<AllocationPool> allocationPools = Sets.newHashSet();
@Override
protected void execute() {
......
......@@ -88,11 +88,11 @@ public class SubnetUpdateCommand extends AbstractShellCommand {
@Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
required = false, multiValued = false)
Iterable<HostRoute> hostRoutes = null;
Set<HostRoute> hostRoutes = Sets.newHashSet();
@Option(name = "-a", aliases = "--allocationPools",
description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
Iterable<AllocationPool> allocationPools = Sets.newHashSet();;
Set<AllocationPool> allocationPools = Sets.newHashSet();;
@Override
protected void execute() {
......
......@@ -15,7 +15,6 @@
*/
package org.onosproject.vtnrsc.cli.virtualport;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
......@@ -106,11 +105,11 @@ public class VirtualPortCreateCommand extends AbstractShellCommand {
@Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
required = false, multiValued = false)
Collection<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
@Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
required = false, multiValued = false)
Collection<SecurityGroup> securityGroups = Sets.newHashSet();
Set<SecurityGroup> securityGroups = Sets.newHashSet();
@Override
protected void execute() {
......
......@@ -15,7 +15,6 @@
*/
package org.onosproject.vtnrsc.cli.virtualport;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
......@@ -107,11 +106,11 @@ public class VirtualPortUpdateCommand extends AbstractShellCommand {
@Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
required = false, multiValued = false)
Collection<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
@Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
required = false, multiValued = false)
Collection<SecurityGroup> securityGroups = Sets.newHashSet();
Set<SecurityGroup> securityGroups = Sets.newHashSet();
@Override
protected void execute() {
......
......@@ -21,12 +21,14 @@ import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.vtnrsc.AllocationPool;
import org.onosproject.vtnrsc.DefaultSubnet;
import org.onosproject.vtnrsc.HostRoute;
import org.onosproject.vtnrsc.Subnet;
import org.onosproject.vtnrsc.SubnetId;
......@@ -86,7 +88,9 @@ public class SubnetManager implements SubnetService {
TenantId.class,
HostRoute.class,
Subnet.Mode.class,
AllocationPool.class))
AllocationPool.class,
DefaultSubnet.class,
IpAddress.Version.class))
.build().asJavaMap();
log.info("Started");
......
......@@ -30,6 +30,7 @@ import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
import org.onosproject.vtnrsc.AllowedAddressPair;
import org.onosproject.vtnrsc.BindingHostId;
import org.onosproject.vtnrsc.DefaultVirtualPort;
import org.onosproject.vtnrsc.FixedIp;
import org.onosproject.vtnrsc.SecurityGroup;
import org.onosproject.vtnrsc.SubnetId;
......@@ -98,7 +99,8 @@ public class VirtualPortManager implements VirtualPortService {
BindingHostId.class,
SecurityGroup.class,
SubnetId.class,
IpAddress.class))
IpAddress.class,
DefaultVirtualPort.class))
.build().asJavaMap();
log.info("Started");
}
......
......@@ -63,6 +63,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
@Path("subnets")
public class SubnetWebResource extends AbstractWebResource {
......@@ -211,8 +212,8 @@ public class SubnetWebResource extends AbstractWebResource {
Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
tenantId, ipVersion, cidr,
gatewayIp, dhcpEnabled, shared,
hostRoutesIt, ipV6AddressMode,
ipV6RaMode, allocationPoolsIt);
Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
subMap.put(id, subnet);
}
return Collections.unmodifiableCollection(subMap.values());
......@@ -267,9 +268,9 @@ public class SubnetWebResource extends AbstractWebResource {
Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
ipVersion, cidr, gatewayIp,
dhcpEnabled, shared, hostRoutesIt,
dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
ipV6AddressMode, ipV6RaMode,
allocationPoolsIt);
Sets.newHashSet(allocationPoolsIt));
subMap.put(id, subnet);
return Collections.unmodifiableCollection(subMap.values());
}
......
......@@ -54,8 +54,8 @@ import org.onosproject.vtnrsc.SubnetId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.VirtualPort;
import org.onosproject.vtnrsc.VirtualPortId;
import org.onosproject.vtnrsc.VirtualPort.State;
import org.onosproject.vtnrsc.VirtualPortId;
import org.onosproject.vtnrsc.virtualport.VirtualPortService;
import org.onosproject.vtnrsc.web.VirtualPortCodec;
import org.slf4j.Logger;
......@@ -65,6 +65,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
/**
* REST resource for interacting with the inventory of infrastructure
......@@ -249,8 +250,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
macAddress, tenantId,
deviceId, fixedIps,
bindingHostId,
allowedAddressPairs,
securityGroups);
Sets.newHashSet(allowedAddressPairs),
Sets.newHashSet(securityGroups));
portMap.put(id, vPort);
}
return Collections.unmodifiableCollection(portMap.values());
......@@ -308,8 +309,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
macAddress, tenantId,
deviceId, fixedIps,
bindingHostId,
allowedAddressPairs,
securityGroups);
Sets.newHashSet(allowedAddressPairs),
Sets.newHashSet(securityGroups));
vportMap.put(id, vPort);
return Collections.unmodifiableCollection(vportMap.values());
......