CNlucius
Committed by Gerrit Code Review

ONOS-2622

Fix error of north app and update onos-app-vtnrsc package

Change-Id: I375002ff26d2ab3ada879a92a1d47bcdb8980054
Showing 41 changed files with 409 additions and 310 deletions
......@@ -33,12 +33,6 @@ import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.util.KryoNamespace;
import org.onosproject.app.vtnrsc.SegmentationId;
import org.onosproject.app.vtnrsc.TenantNetwork;
import org.onosproject.app.vtnrsc.VirtualPort;
import org.onosproject.app.vtnrsc.VirtualPortId;
import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.app.vtnrsc.virtualport.VirtualPortService;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.Device;
......@@ -79,6 +73,12 @@ import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.WallClockTimestamp;
import org.onosproject.vtn.VTNService;
import org.onosproject.vtnrsc.SegmentationId;
import org.onosproject.vtnrsc.TenantNetwork;
import org.onosproject.vtnrsc.VirtualPort;
import org.onosproject.vtnrsc.VirtualPortId;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.vtnrsc.virtualport.VirtualPortService;
import org.slf4j.Logger;
import com.google.common.collect.Sets;
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
<repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
<feature name="onos-app-vtnrsc" version="@FEATURE-VERSION"
description="ONOS app vtnrsc components">
<feature>onos-api</feature>
<bundle>mvn:org.onosproject/onos-app-vtnrsc/@ONOS-VERSION
</bundle>
</feature>
</features>
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import org.onlab.packet.IpAddress;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
......
package org.onosproject.vtnrsc;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Objects;
public final class BindingHostId {
private final String bindingHostId;
// Public construction is prohibited
private BindingHostId(String bindingHostId) {
checkNotNull(bindingHostId, "BindingHosttId cannot be null");
this.bindingHostId = bindingHostId;
}
/**
* Creates a BindingHostId identifier.
*
* @param bindingHostId the bindingHostId identifier
* @return the bindingHostId identifier
*/
public static BindingHostId bindingHostId(String bindingHostId) {
return new BindingHostId(bindingHostId);
}
/**
* Returns the bindingHostId identifier.
*
* @return the bindingHostId identifier
*/
public String bindingHostId() {
return bindingHostId;
}
@Override
public int hashCode() {
return Objects.hash(bindingHostId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof BindingHostId) {
final BindingHostId that = (BindingHostId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.bindingHostId, that.bindingHostId);
}
return false;
}
@Override
public String toString() {
return bindingHostId;
}
}
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
......@@ -48,6 +48,7 @@ public final class DefaultSubnet implements Subnet {
* @param subnetName the name of subnet
* @param networkId network identifier
* @param tenantId tenant identifier
* @param ipVersion Version of ipv4 or ipv6
* @param cidr the cidr
* @param gatewayIp gateway ip
* @param dhcpEnabled dhcp enabled or not
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
......
......@@ -13,17 +13,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.onlab.packet.MacAddress;
import org.onosproject.net.DeviceId;
import org.onosproject.net.HostId;
/**
* Default implementation of VirtualPort interface .
......@@ -38,8 +38,8 @@ public final class DefaultVirtualPort implements VirtualPort {
private final TenantId tenantId;
private final String deviceOwner;
private final DeviceId deviceId;
private final FixedIp fixedIp;
private final HostId bindingHostId;
private final Set<FixedIp> fixedIps;
private final BindingHostId bindingHostId;
private final String bindingVnicType;
private final String bindingVifType;
private final String bindingVifDetails;
......@@ -57,7 +57,7 @@ public final class DefaultVirtualPort implements VirtualPort {
* @param macAddress the MAC address
* @param tenantId the tenant identifier
* @param deviceId the device identifier
* @param fixedIp the fixed IP
* @param fixedIps set of fixed IP
* @param bindingHostId the binding host identifier
* @param allowedAddressPairs the collection of allowdeAddressPairs
* @param securityGroups the collection of securityGroups
......@@ -70,8 +70,8 @@ public final class DefaultVirtualPort implements VirtualPort {
MacAddress macAddress,
TenantId tenantId,
DeviceId deviceId,
FixedIp fixedIp,
HostId bindingHostId,
Set<FixedIp> fixedIps,
BindingHostId bindingHostId,
Collection<AllowedAddressPair> allowedAddressPairs,
Collection<SecurityGroup> securityGroups) {
this.id = id;
......@@ -83,7 +83,7 @@ public final class DefaultVirtualPort implements VirtualPort {
this.tenantId = tenantId;
this.deviceOwner = strMap.get("deviceOwner");
this.deviceId = deviceId;
this.fixedIp = fixedIp;
this.fixedIps = fixedIps;
this.bindingHostId = bindingHostId;
this.bindingVnicType = strMap.get("bindingVnicType");
this.bindingVifType = strMap.get("bindingVifType");
......@@ -143,12 +143,12 @@ public final class DefaultVirtualPort implements VirtualPort {
}
@Override
public FixedIp fixedIps() {
return fixedIp;
public Set<FixedIp> fixedIps() {
return fixedIps;
}
@Override
public HostId bindingHostId() {
public BindingHostId bindingHostId() {
return bindingHostId;
}
......@@ -176,7 +176,7 @@ public final class DefaultVirtualPort implements VirtualPort {
public int hashCode() {
return Objects.hash(id, networkId, adminStateUp, name, state,
macAddress, tenantId, deviceId, deviceOwner,
allowedAddressPairs, fixedIp, bindingHostId,
allowedAddressPairs, fixedIps, bindingHostId,
bindingVnicType, bindingVifType, bindingVifDetails,
securityGroups);
}
......@@ -199,7 +199,7 @@ public final class DefaultVirtualPort implements VirtualPort {
&& Objects.equals(this.deviceOwner, that.deviceOwner)
&& Objects.equals(this.allowedAddressPairs,
that.allowedAddressPairs)
&& Objects.equals(this.fixedIp, that.fixedIp)
&& Objects.equals(this.fixedIps, that.fixedIps)
&& Objects.equals(this.bindingHostId, that.bindingHostId)
&& Objects.equals(this.bindingVifDetails,
that.bindingVifDetails)
......@@ -219,7 +219,7 @@ public final class DefaultVirtualPort implements VirtualPort {
.add("macAddress", macAddress).add("tenantId", tenantId)
.add("deviced", deviceId).add("deviceOwner", deviceOwner)
.add("allowedAddressPairs", allowedAddressPairs)
.add("fixedIp", fixedIp).add("bindingHostId", bindingHostId)
.add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
.add("bindingVnicType", bindingVnicType)
.add("bindingVifDetails", bindingVifDetails)
.add("bindingVifType", bindingVifType)
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.MoreObjects.toStringHelper;
import static com.google.common.base.Preconditions.checkNotNull;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
......
......@@ -13,46 +13,47 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a physicalnetwork identity.
* Immutable representation of a physical network identity.
*/
public final class PhysicalNetwork {
private final String physicalnetwork;
private final String physicalNetwork;
// Public construction is prohibited
private PhysicalNetwork(String physicalnetwork) {
checkNotNull(physicalnetwork, "Physicalnetwork cannot be null");
this.physicalnetwork = physicalnetwork;
private PhysicalNetwork(String physicalNetwork) {
checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
this.physicalNetwork = physicalNetwork;
}
/**
* Creates a network id using the physicalnetwork.
* Creates a PhysicalNetwork object.
*
* @param physicalnetwork network String
* @return physicalnetwork
* @param physicalNetwork physical network
* @return physical network
*/
public static PhysicalNetwork physicalNetwork(String physicalnetwork) {
return new PhysicalNetwork(physicalnetwork);
public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
return new PhysicalNetwork(physicalNetwork);
}
/**
* Returns a physicalNetwork.
*
* @return physicalnetwork
* @return physical network
*/
public String physicalnetwork() {
return physicalnetwork;
public String physicalNetwork() {
return physicalNetwork;
}
@Override
public int hashCode() {
return Objects.hash(physicalnetwork);
return Objects.hash(physicalNetwork);
}
@Override
......@@ -63,15 +64,15 @@ public final class PhysicalNetwork {
if (obj instanceof PhysicalNetwork) {
final PhysicalNetwork that = (PhysicalNetwork) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.physicalnetwork,
that.physicalnetwork);
&& Objects.equals(this.physicalNetwork,
that.physicalNetwork);
}
return false;
}
@Override
public String toString() {
return physicalnetwork;
return physicalNetwork;
}
}
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import java.util.Objects;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import java.util.Objects;
......
/*
*Copyright 2014 Open Networking Laboratory
*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.
......@@ -13,7 +13,7 @@
*See the License for the specific language governing permissions and
*limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpAddress.Version;
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.Preconditions.checkNotNull;
......
......@@ -13,22 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Immutable representation of a network identity.
* Immutable representation of a tenant identifier.
*/
public final class TenantId {
private final String tenantid;
private final String tenantId;
// Public construction is prohibited
private TenantId(String tenantid) {
this.tenantid = tenantid;
private TenantId(String tenantId) {
this.tenantId = tenantId;
}
/**
......@@ -43,16 +43,17 @@ public final class TenantId {
}
/**
* Returns the tenant identifier.
*
* @return tenantid
* @return the tenant identifier
*/
public String tenantid() {
return tenantid;
public String tenantId() {
return tenantId;
}
@Override
public int hashCode() {
return Objects.hash(tenantid);
return Objects.hash(tenantId);
}
@Override
......@@ -63,14 +64,14 @@ public final class TenantId {
if (obj instanceof TenantId) {
final TenantId that = (TenantId) obj;
return this.getClass() == that.getClass()
&& Objects.equals(this.tenantid, that.tenantid);
&& Objects.equals(this.tenantId, that.tenantId);
}
return false;
}
@Override
public String toString() {
return tenantid;
return tenantId;
}
}
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
/**
* Representation of the tenantNetwork.
......@@ -95,7 +95,7 @@ public interface TenantNetwork {
* tenant can be different from the tenant that makes the create
* tenantNetwork request.
*
* @return tenantNetwork tenant identifier
* @return the tenant identifier
*/
TenantId tenantId();
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import java.util.Collection;
import java.util.Set;
import org.onlab.packet.MacAddress;
import org.onosproject.net.DeviceId;
import org.onosproject.net.HostId;
/**
* Representation of the VirtualPort.
......@@ -112,19 +112,19 @@ public interface VirtualPort {
Collection<AllowedAddressPair> allowedAddressPairs();
/**
* Returns the IP address for the port, Include the IP address and subnet
* Returns set of IP addresses for the port, include the IP addresses and subnet
* identity.
*
* @return port fixedIps
* @return FixedIps Set of fixedIp
*/
FixedIp fixedIps();
Set<FixedIp> fixedIps();
/**
* Returns the virtualPort bindinghostId.
*
* @return virtualPort bindinghostId
*/
HostId bindingHostId();
BindingHostId bindingHostId();
/**
* Returns the virtualPort bindingVnicType.
......
......@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc;
package org.onosproject.vtnrsc;
import static com.google.common.base.Preconditions.checkNotNull;
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.subnet;
package org.onosproject.vtnrsc.subnet;
import org.onosproject.app.vtnrsc.Subnet;
import org.onosproject.app.vtnrsc.SubnetId;
import org.onosproject.vtnrsc.Subnet;
import org.onosproject.vtnrsc.SubnetId;
/**
......
......@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.subnet.impl;
package org.onosproject.vtnrsc.subnet.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
......@@ -26,15 +27,11 @@ 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.util.KryoNamespace;
import org.onosproject.app.vtnrsc.Subnet;
import org.onosproject.app.vtnrsc.SubnetId;
import org.onosproject.app.vtnrsc.subnet.SubnetService;
import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.store.service.MultiValuedTimestamp;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.WallClockTimestamp;
import org.onosproject.vtnrsc.Subnet;
import org.onosproject.vtnrsc.SubnetId;
import org.onosproject.vtnrsc.subnet.SubnetService;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.slf4j.Logger;
/**
......@@ -49,8 +46,8 @@ public class SubnetManager implements SubnetService {
private final Logger log = getLogger(getClass());
private EventuallyConsistentMap<SubnetId, Subnet> subnetStore;
protected ConcurrentHashMap<SubnetId, Subnet> subnetStore =
new ConcurrentHashMap<>();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
......@@ -59,20 +56,12 @@ public class SubnetManager implements SubnetService {
@Activate
public void activate() {
KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
.register(MultiValuedTimestamp.class);
subnetStore = storageService
.<SubnetId, Subnet>eventuallyConsistentMapBuilder()
.withName("all_subnet").withSerializer(serializer)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.build();
log.info("SubnetManager started");
}
@Deactivate
public void deactivate() {
subnetStore.destroy();
subnetStore.clear();
log.info("SubnetManager stopped");
}
......
......@@ -13,10 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.tenantnetwork;
package org.onosproject.vtnrsc.tenantnetwork;
import org.onosproject.app.vtnrsc.TenantNetwork;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.TenantNetwork;
import org.onosproject.vtnrsc.TenantNetworkId;
/**
* Service for interacting with the inventory of tenantNetwork.
......@@ -73,8 +73,8 @@ public interface TenantNetworkService {
/**
* Deletes tenantNetwork by tenantNetworkIds.
*
* @param networksId the collection of tenantNetworkIds
* @return true if the specified tenantNetwork deleted successfully.
* @param networksIds the collection of tenantNetworkIds
* @return true if the specified tenantNetworks deleted successfully.
*/
boolean removeNetworks(Iterable<TenantNetworkId> networksId);
boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
}
......
......@@ -13,27 +13,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.tenantnetwork.impl;
package org.onosproject.vtnrsc.tenantnetwork.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
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.util.KryoNamespace;
import org.onosproject.app.vtnrsc.TenantNetwork;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.store.service.MultiValuedTimestamp;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.WallClockTimestamp;
import org.onosproject.vtnrsc.TenantNetwork;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.slf4j.Logger;
/**
......@@ -46,26 +40,19 @@ public class TenantNetworkManager implements TenantNetworkService {
private static final String NETWORK_ID_NULL = "Network ID cannot be null";
private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
private EventuallyConsistentMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
protected ConcurrentHashMap<TenantNetworkId, TenantNetwork> networkIdAsKeyStore =
new ConcurrentHashMap<>();
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
.register(MultiValuedTimestamp.class);
networkIdAsKeyStore = storageService
.<TenantNetworkId, TenantNetwork>eventuallyConsistentMapBuilder()
.withName("all_network").withSerializer(serializer)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.build();
log.info("Started");
}
@Deactivate
public void deactivate() {
networkIdAsKeyStore.destroy();
networkIdAsKeyStore.clear();
log.info("Stopped");
}
......@@ -97,7 +84,7 @@ public class TenantNetworkManager implements TenantNetworkService {
for (TenantNetwork network : networks) {
networkIdAsKeyStore.put(network.id(), network);
if (!networkIdAsKeyStore.containsKey(network.id())) {
log.debug("the network created failed which identifier was {}", network.id()
log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
.toString());
return false;
}
......@@ -110,15 +97,15 @@ public class TenantNetworkManager implements TenantNetworkService {
checkNotNull(networks, NETWORK_NOT_NULL);
for (TenantNetwork network : networks) {
if (!networkIdAsKeyStore.containsKey(network.id())) {
log.debug("the tenantNetwork did not exist whose identifier was {} ",
log.debug("The tenantNetwork is not exist whose identifier was {} ",
network.id().toString());
return false;
}
networkIdAsKeyStore.put(network.id(), network);
if (network.equals(networkIdAsKeyStore.get(network.id()))) {
log.debug("the network updated failed whose identifier was {} ",
if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
log.debug("The tenantNetwork is updated failed whose identifier was {} ",
network.id().toString());
return false;
}
......@@ -133,7 +120,7 @@ public class TenantNetworkManager implements TenantNetworkService {
for (TenantNetworkId networkId : networkIds) {
networkIdAsKeyStore.remove(networkId);
if (networkIdAsKeyStore.containsKey(networkId)) {
log.debug("the network removed failed whose identifier was {}",
log.debug("The tenantNetwork is removed failed whose identifier was {}",
networkId.toString());
return false;
}
......
/*
* 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.vtnrsc.tunnel;
import org.onosproject.vtnrsc.Subnet;
import org.onosproject.vtnrsc.SubnetId;
/**
* Service for interacting with the inventory of subnets.
*/
public interface TunnelConfigService {
/**
* Returns the subnet with the specified identifier.
*
* @param subnetId subnet identifier
* @return true or false
*/
boolean exists(SubnetId subnetId);
/**
* Returns a collection of the currently known subnets.
*
* @return iterable collection of subnets
*/
Iterable<Subnet> getSubnets();
/**
* Returns the subnet with the specified identifier.
*
* @param subnetId subnet identifier
* @return subnet or null if one with the given identifier is not known
*/
Subnet getSubnet(SubnetId subnetId);
/**
* Creates new subnets.
*
* @param subnets the iterable collection of subnets
* @return true if the identifier subnet has been created right
*/
boolean createSubnets(Iterable<Subnet> subnets);
/**
* Updates existing subnets.
*
* @param subnets the iterable collection of subnets
* @return true if all subnets were updated successfully
*/
boolean updateSubnets(Iterable<Subnet> subnets);
/**
* Administratively removes the specified subnets from the store.
*
* @param subnetIds the iterable collection of subnets identifier
* @return true if remove identifier subnets successfully
*/
boolean removeSubnets(Iterable<SubnetId> subnetIds);
}
......@@ -13,15 +13,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.virtualport;
package org.onosproject.vtnrsc.virtualport;
import java.util.Collection;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.TenantId;
import org.onosproject.app.vtnrsc.VirtualPort;
import org.onosproject.app.vtnrsc.VirtualPortId;
import org.onosproject.net.DeviceId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.VirtualPort;
import org.onosproject.vtnrsc.VirtualPortId;
/**
* Service for interacting with the inventory of virtualPort.
......@@ -45,6 +45,7 @@ public interface VirtualPortService {
/**
* Returns the collection of the currently known virtualPort.
* @return collection of VirtualPort.
*/
Collection<VirtualPort> getPorts();
......
......@@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.virtualport.impl;
package org.onosproject.vtnrsc.virtualport.impl;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.Collection;
import java.util.Collections;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
......@@ -26,18 +27,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.util.KryoNamespace;
import org.onosproject.net.DeviceId;
import org.onosproject.store.service.EventuallyConsistentMap;
import org.onosproject.store.service.MultiValuedTimestamp;
import org.onosproject.store.service.StorageService;
import org.onosproject.store.service.WallClockTimestamp;
import org.onosproject.app.vtnrsc.TenantId;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.VirtualPort;
import org.onosproject.app.vtnrsc.VirtualPortId;
import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.app.vtnrsc.virtualport.VirtualPortService;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.VirtualPort;
import org.onosproject.vtnrsc.VirtualPortId;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.vtnrsc.virtualport.VirtualPortService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -56,8 +53,8 @@ public class VirtualPortManager implements VirtualPortService {
private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
private EventuallyConsistentMap<VirtualPortId, VirtualPort> vPortStore;
protected ConcurrentHashMap<VirtualPortId, VirtualPort> vPortStore =
new ConcurrentHashMap<>();
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
......@@ -65,19 +62,12 @@ public class VirtualPortManager implements VirtualPortService {
@Activate
public void activate() {
KryoNamespace.Builder seriallizer = KryoNamespace.newBuilder()
.register(MultiValuedTimestamp.class);
vPortStore = storageService
.<VirtualPortId, VirtualPort>eventuallyConsistentMapBuilder()
.withName("vPortId_vPort").withSerializer(seriallizer)
.withTimestampProvider((k, v) -> new WallClockTimestamp())
.build();
log.info("Started");
}
@Deactivate
public void deactivate() {
vPortStore.destroy();
vPortStore.clear();
log.info("Stoppped");
}
......@@ -141,7 +131,7 @@ public class VirtualPortManager implements VirtualPortService {
log.debug("vPortId is {} ", vPort.portId().toString());
vPortStore.put(vPort.portId(), vPort);
if (!vPortStore.containsKey(vPort.portId())) {
log.debug("the virtualPort created failed whose identifier was {} ",
log.debug("The virtualPort is created failed whose identifier is {} ",
vPort.portId().toString());
return false;
}
......@@ -156,7 +146,7 @@ public class VirtualPortManager implements VirtualPortService {
for (VirtualPort vPort : vPorts) {
vPortStore.put(vPort.portId(), vPort);
if (!vPortStore.containsKey(vPort.portId())) {
log.debug("the virtualPort did not exist whose identifier was {}",
log.debug("The virtualPort is not exist whose identifier is {}",
vPort.portId().toString());
return false;
}
......@@ -164,7 +154,7 @@ public class VirtualPortManager implements VirtualPortService {
vPortStore.put(vPort.portId(), vPort);
if (!vPort.equals(vPortStore.get(vPort.portId()))) {
log.debug("the virtualPort updated failed whose identifier was {}",
log.debug("The virtualPort is updated failed whose identifier is {}",
vPort.portId().toString());
return false;
}
......@@ -180,7 +170,7 @@ public class VirtualPortManager implements VirtualPortService {
for (VirtualPortId vPortId : vPortIds) {
vPortStore.remove(vPortId);
if (vPortStore.containsKey(vPortId)) {
log.debug("the virtualPort removed failed whose identifier was {}",
log.debug("The virtualPort is removed failed whose identifier is {}",
vPortId.toString());
return false;
}
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.app.vtnrsc.AllocationPool;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.vtnrsc.AllocationPool;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.app.vtnrsc.AllowedAddressPair;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.vtnrsc.AllowedAddressPair;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.app.vtnrsc.FixedIp;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.vtnrsc.FixedIp;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.app.vtnrsc.HostRoute;
import org.onosproject.vtnrsc.HostRoute;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.app.vtnrsc.SecurityGroup;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.vtnrsc.SecurityGroup;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.app.vtnrsc.Subnet;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.vtnrsc.Subnet;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.app.vtnrsc.TenantNetwork;
import org.onosproject.vtnrsc.TenantNetwork;
import com.fasterxml.jackson.databind.node.ObjectNode;
......
......@@ -13,13 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.app.vtnrsc.web;
package org.onosproject.vtnrsc.web;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.app.vtnrsc.VirtualPort;
import org.onosproject.vtnrsc.VirtualPort;
import com.fasterxml.jackson.databind.node.ObjectNode;
......@@ -44,7 +44,7 @@ public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
.put("device_owner", vPort.deviceOwner().toString())
.put("binding:vnic_type", vPort.bindingVnicType().toString())
.put("binding:Vif_type", vPort.bindingVifType().toString())
.put("binding:host_id", vPort.bindingHostId().mac().toString())
.put("binding:host_id", vPort.bindingHostId().toString())
.put("binding:vif_details", vPort.bindingVifDetails().toString());
result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
vPort.allowedAddressPairs(), context));
......
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!--
~ 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.
-->
<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
<repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
<feature name="onos-app-vtnweb" version="@FEATURE-VERSION"
description="ONOS app vtnweb components">
<feature>onos-app-vtnrsc</feature>
<bundle>mvn:org.onosproject/vtnweb/@ONOS-VERSION
</bundle>
</feature>
</features>
......@@ -42,19 +42,19 @@ import org.onlab.packet.IpAddress;
import org.onlab.packet.IpAddress.Version;
import org.onlab.packet.IpPrefix;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.app.vtnrsc.AllocationPool;
import org.onosproject.app.vtnrsc.DefaultAllocationPool;
import org.onosproject.app.vtnrsc.DefaultHostRoute;
import org.onosproject.app.vtnrsc.DefaultSubnet;
import org.onosproject.app.vtnrsc.HostRoute;
import org.onosproject.app.vtnrsc.Subnet;
import org.onosproject.app.vtnrsc.Subnet.Mode;
import org.onosproject.app.vtnrsc.SubnetId;
import org.onosproject.app.vtnrsc.TenantId;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.subnet.SubnetService;
import org.onosproject.app.vtnrsc.web.SubnetCodec;
import org.onosproject.rest.AbstractWebResource;
import org.onosproject.vtnrsc.AllocationPool;
import org.onosproject.vtnrsc.DefaultAllocationPool;
import org.onosproject.vtnrsc.DefaultHostRoute;
import org.onosproject.vtnrsc.DefaultSubnet;
import org.onosproject.vtnrsc.HostRoute;
import org.onosproject.vtnrsc.Subnet;
import org.onosproject.vtnrsc.SubnetId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.Subnet.Mode;
import org.onosproject.vtnrsc.subnet.SubnetService;
import org.onosproject.vtnrsc.web.SubnetCodec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -85,7 +85,7 @@ public class SubnetWebResource extends AbstractWebResource {
public Response getSubnet(@PathParam("subnetUUID") String id) {
if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
return ok("the subnet does not exists").build();
return ok("The subnet does not exists").build();
}
Subnet sub = nullIsNotFound(get(SubnetService.class)
.getSubnet(SubnetId.subnetId(id)),
......@@ -183,30 +183,30 @@ public class SubnetWebResource extends AbstractWebResource {
checkNotNull(subnetNodes, JSON_NOT_NULL);
Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
for (JsonNode subnetNode : subnetNodes) {
if (subnetNode.hasNonNull("id")) {
if (!subnetNode.hasNonNull("id")) {
return null;
}
SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
String subnetName = subnetNode.get("name").asText();
TenantId tenantId = TenantId.tenantId(subnetNode.get("tenant_id")
.asText());
TenantNetworkId networkId = TenantNetworkId.networkId(subnetNode
.get("network_id").asText());
Version ipVersion = Version.valueOf(subnetNode.get("ip_version")
.asText());
TenantId tenantId = TenantId
.tenantId(subnetNode.get("tenant_id").asText());
TenantNetworkId networkId = TenantNetworkId
.networkId(subnetNode.get("network_id").asText());
Version ipVersion = Version
.valueOf(subnetNode.get("ip_version").asText());
IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
IpAddress gatewayIp = IpAddress.valueOf(subnetNode
.get("gateway_ip").asText());
IpAddress gatewayIp = IpAddress
.valueOf(subnetNode.get("gateway_ip").asText());
Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
Boolean shared = subnetNode.get("shared").asBoolean();
JsonNode hostRoutes = subnetNode.get("host_routes");
Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
JsonNode allocationPools = subnetNode.get("allocation_pools");
Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
Mode ipV6AddressMode = Mode.valueOf(subnetNode
.get("ipv6_address_mode").asText());
Mode ipV6RaMode = Mode.valueOf(subnetNode.get("ipv6_ra_mode")
.asText());
Mode ipV6AddressMode = Mode
.valueOf(subnetNode.get("ipv6_address_mode").asText());
Mode ipV6RaMode = Mode
.valueOf(subnetNode.get("ipv6_ra_mode").asText());
Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
tenantId, ipVersion, cidr,
gatewayIp, dhcpEnabled, shared,
......@@ -226,27 +226,42 @@ public class SubnetWebResource extends AbstractWebResource {
public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
checkNotNull(subnetNodes, JSON_NOT_NULL);
Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
if (!subnetNodes.hasNonNull("id")) {
return null;
}
SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
String subnetName = subnetNodes.get("name").asText();
TenantId tenantId = TenantId.tenantId(subnetNodes.get("tenant_id")
.asText());
TenantNetworkId networkId = TenantNetworkId.networkId(subnetNodes
.get("network_id").asText());
Version ipVersion = Version.valueOf(subnetNodes.get("ip_version")
.asText());
TenantId tenantId = TenantId
.tenantId(subnetNodes.get("tenant_id").asText());
TenantNetworkId networkId = TenantNetworkId
.networkId(subnetNodes.get("network_id").asText());
String version = subnetNodes.get("ip_version").asText();
Version ipVersion;
switch (version) {
case "4":
ipVersion = Version.INET;
break;
case "6":
ipVersion = Version.INET;
break;
default:
ipVersion = null;
}
IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
IpAddress gatewayIp = IpAddress.valueOf(subnetNodes.get("gateway_ip")
.asText());
IpAddress gatewayIp = IpAddress
.valueOf(subnetNodes.get("gateway_ip").asText());
Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
Boolean shared = subnetNodes.get("shared").asBoolean();
JsonNode hostRoutes = subnetNodes.get("host_routes");
Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
JsonNode allocationPools = subnetNodes.get("allocation_pools");
Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
Mode ipV6AddressMode = Mode.valueOf(subnetNodes
.get("ipv6_address_mode").asText());
Mode ipV6RaMode = Mode
.valueOf(subnetNodes.get("ipv6_ra_mode").asText());
Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
.asText());
Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
ipVersion, cidr, gatewayIp,
dhcpEnabled, shared, hostRoutesIt,
......@@ -257,6 +272,33 @@ public class SubnetWebResource extends AbstractWebResource {
}
/**
* Gets ipv6_address_mode or ipv6_ra_mode type.
*
* @param mode the String value in JsonNode
* @return ipV6Mode Mode of the ipV6Mode
*/
private Mode getMode(String mode) {
Mode ipV6Mode;
if (mode == null) {
return null;
}
switch (mode) {
case "dhcpv6-stateful":
ipV6Mode = Mode.DHCPV6_STATEFUL;
break;
case "dhcpv6-stateless":
ipV6Mode = Mode.DHCPV6_STATELESS;
break;
case "slaac":
ipV6Mode = Mode.SLAAC;
break;
default:
ipV6Mode = null;
}
return ipV6Mode;
}
/**
* Changes JsonNode alocPools to a collection of the alocPools.
*
* @param allocationPools the allocationPools JsonNode
......
......@@ -39,17 +39,17 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.app.vtnrsc.DefaultTenantNetwork;
import org.onosproject.app.vtnrsc.PhysicalNetwork;
import org.onosproject.app.vtnrsc.SegmentationId;
import org.onosproject.app.vtnrsc.TenantId;
import org.onosproject.app.vtnrsc.TenantNetwork;
import org.onosproject.app.vtnrsc.TenantNetwork.State;
import org.onosproject.app.vtnrsc.TenantNetwork.Type;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.app.vtnrsc.web.TenantNetworkCodec;
import org.onosproject.rest.AbstractWebResource;
import org.onosproject.vtnrsc.DefaultTenantNetwork;
import org.onosproject.vtnrsc.PhysicalNetwork;
import org.onosproject.vtnrsc.SegmentationId;
import org.onosproject.vtnrsc.TenantId;
import org.onosproject.vtnrsc.TenantNetwork;
import org.onosproject.vtnrsc.TenantNetworkId;
import org.onosproject.vtnrsc.TenantNetwork.State;
import org.onosproject.vtnrsc.TenantNetwork.Type;
import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
import org.onosproject.vtnrsc.web.TenantNetworkCodec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......
......@@ -43,20 +43,20 @@ import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.HostId;
import org.onosproject.rest.AbstractWebResource;
import org.onosproject.app.vtnrsc.AllowedAddressPair;
import org.onosproject.app.vtnrsc.DefaultVirtualPort;
import org.onosproject.app.vtnrsc.FixedIp;
import org.onosproject.app.vtnrsc.SecurityGroup;
import org.onosproject.app.vtnrsc.SubnetId;
import org.onosproject.app.vtnrsc.TenantId;
import org.onosproject.app.vtnrsc.TenantNetworkId;
import org.onosproject.app.vtnrsc.VirtualPort;
import org.onosproject.app.vtnrsc.VirtualPortId;
import org.onosproject.app.vtnrsc.VirtualPort.State;
import org.onosproject.app.vtnrsc.virtualport.VirtualPortService;
import org.onosproject.app.vtnrsc.web.VirtualPortCodec;
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;
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.virtualport.VirtualPortService;
import org.onosproject.vtnrsc.web.VirtualPortCodec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -216,10 +216,15 @@ public class VirtualPortWebResource extends AbstractWebResource {
DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
.asText());
String deviceOwner = vPortnode.get("device_owner").asText();
JsonNode fixedIpNode = vPortnode.get("fixed_ips");
JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
Set<FixedIp> fixedIps = new HashSet<FixedIp>();
for (JsonNode fixedIpNode : fixedIpNodes) {
FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
HostId bindingHostId = HostId.hostId(MacAddress.valueOf(vPortnode
.get("binding:host_id").asText()));
fixedIps.add(fixedIp);
}
BindingHostId bindingHostId = BindingHostId
.bindingHostId(vPortnode.get("binding:host_id").asText());
String bindingVnicType = vPortnode.get("binding:vnic_type")
.asText();
String bindingVifType = vPortnode.get("binding:vif_type").asText();
......@@ -230,18 +235,17 @@ public class VirtualPortWebResource extends AbstractWebResource {
Collection<AllowedAddressPair> allowedAddressPairs =
jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
JsonNode securityGroupNode = vPortnode.get("security_groups");
Collection<SecurityGroup> securityGroups =
jsonNodeToSecurityGroup(securityGroupNode);
strMap.putIfAbsent("name", name);
strMap.putIfAbsent("deviceOwner", deviceOwner);
strMap.putIfAbsent("bindingVnicType", bindingVnicType);
strMap.putIfAbsent("bindingVifType", bindingVifType);
strMap.putIfAbsent("bindingVifDetails", bindingVifDetails);
Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
strMap.put("name", name);
strMap.put("deviceOwner", deviceOwner);
strMap.put("bindingVnicType", bindingVnicType);
strMap.put("bindingVifType", bindingVifType);
strMap.put("bindingVifDetails", bindingVifDetails);
VirtualPort vPort = new DefaultVirtualPort(id, networkId,
adminStateUp, strMap,
isState(state),
macAddress, tenantId,
deviceId, fixedIp,
deviceId, fixedIps,
bindingHostId,
allowedAddressPairs,
securityGroups);
......@@ -273,10 +277,15 @@ public class VirtualPortWebResource extends AbstractWebResource {
DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
.asText());
String deviceOwner = vPortNodes.get("device_owner").asText();
JsonNode fixedIpNode = vPortNodes.get("fixed_ips");
JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
Set<FixedIp> fixedIps = new HashSet<FixedIp>();
for (JsonNode fixedIpNode : fixedIpNodes) {
FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
HostId bindingHostId = HostId.hostId(MacAddress.valueOf(vPortNodes
.get("binding:host_id").asText()));
fixedIps.add(fixedIp);
}
BindingHostId bindingHostId = BindingHostId
.bindingHostId(vPortNodes.get("binding:host_id").asText());
String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
String bindingVifType = vPortNodes.get("binding:vif_type").asText();
String bindingVifDetails = vPortNodes.get("binding:vif_details")
......@@ -286,17 +295,16 @@ public class VirtualPortWebResource extends AbstractWebResource {
Collection<AllowedAddressPair> allowedAddressPairs =
jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
JsonNode securityGroupNode = vPortNodes.get("security_groups");
Collection<SecurityGroup> securityGroups =
jsonNodeToSecurityGroup(securityGroupNode);
strMap.putIfAbsent("name", name);
strMap.putIfAbsent("deviceOwner", deviceOwner);
strMap.putIfAbsent("bindingVnicType", bindingVnicType);
strMap.putIfAbsent("bindingVifType", bindingVifType);
strMap.putIfAbsent("bindingVifDetails", bindingVifDetails);
Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
strMap.put("name", name);
strMap.put("deviceOwner", deviceOwner);
strMap.put("bindingVnicType", bindingVnicType);
strMap.put("bindingVifType", bindingVifType);
strMap.put("bindingVifDetails", bindingVifDetails);
VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
strMap, isState(state),
macAddress, tenantId,
deviceId, fixedIp,
deviceId, fixedIps,
bindingHostId,
allowedAddressPairs,
securityGroups);
......@@ -342,8 +350,8 @@ public class VirtualPortWebResource extends AbstractWebResource {
.newConcurrentMap();
int i = 0;
for (JsonNode node : securityGroups) {
SecurityGroup securityGroup = SecurityGroup.securityGroup(node
.get("security_group").asText());
SecurityGroup securityGroup = SecurityGroup
.securityGroup(node.asText());
securMaps.put(i, securityGroup);
i++;
}
......