aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/vtn
diff options
context:
space:
mode:
authorAshlee Young <ashlee@wildernessvoice.com>2015-11-22 10:02:05 -0800
committerAshlee Young <ashlee@wildernessvoice.com>2015-11-22 10:02:05 -0800
commit77ce3be7567bd01c66d8ee88a93b485666723501 (patch)
tree283e7f39a501750bbd705fbb91645b20198900f1 /framework/src/onos/apps/vtn
parent00e6500d0813dcbccaaa741ef38cc1eae6d11e07 (diff)
Removed patch path since changes have been merged upstream to a different path. Updated README with directions.
Change-Id: Ie419abd2d3d3ef7315de9f607dcd757a78190995 Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/apps/vtn')
-rw-r--r--framework/src/onos/apps/vtn/pom.xml27
-rw-r--r--framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/SfcService.java52
-rw-r--r--framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/SfcManager.java69
-rw-r--r--framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/VTNService.java68
-rw-r--r--framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/VTNManager.java672
-rw-r--r--framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java16
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java148
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java68
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java140
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java65
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java102
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java64
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java117
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java66
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java82
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java63
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java68
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java68
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java64
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java83
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java65
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java64
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java64
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java64
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java76
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java142
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java72
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java66
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java66
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java123
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java41
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java78
36 files changed, 138 insertions, 2965 deletions
diff --git a/framework/src/onos/apps/vtn/pom.xml b/framework/src/onos/apps/vtn/pom.xml
index e8387cb7..a42f91a0 100644
--- a/framework/src/onos/apps/vtn/pom.xml
+++ b/framework/src/onos/apps/vtn/pom.xml
@@ -32,13 +32,14 @@
<description>ONOS framework applications</description>
<modules>
+ <module>sfcmgr</module>
<module>vtnrsc</module>
<module>vtnmgr</module>
<module>vtnweb</module>
<module>app</module>
- </modules>
- <dependencies>
- <dependency>
+ </modules>
+ <dependencies>
+ <dependency>
<groupId>org.onosproject</groupId>
<artifactId>onlab-junit</artifactId>
<scope>test</scope>
@@ -53,5 +54,25 @@
<artifactId>easymock</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-osgi</artifactId>
+ <classifier>tests</classifier>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey</groupId>
+ <artifactId>jersey-servlet</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-core</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.sun.jersey.jersey-test-framework</groupId>
+ <artifactId>jersey-test-framework-grizzly2</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/SfcService.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/SfcService.java
deleted file mode 100644
index a2748f5e..00000000
--- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/SfcService.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * 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.sfc;
-
-import org.onosproject.vtnrsc.PortChain;
-
-/**
- * SFC application that applies flows to the device.
- */
-public interface SfcService {
- /**
- * Applies flow classification to OVS.
- *
- * @param portChain Port-Chain.
- */
- void InstallFlowClassification(PortChain portChain);
-
-
- /**
- * Remove flow classification from OVS.
- *
- * @param portChain Port-Chain.
- */
- void UnInstallFlowClassification(PortChain portChain);
-
- /**
- * Applies Service Function chain to OVS.
- *
- * @param portChain Port-Chain.
- */
- void InstallServiceFunctionChain(PortChain portChain);
-
- /**
- * Remove Service Function chain from OVS.
- *
- * @param portChain Port-Chain.
- */
- void UnInstallServiceFunctionChain(PortChain portChain);
-}
diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/SfcManager.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/SfcManager.java
deleted file mode 100644
index 1872295f..00000000
--- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/SfcManager.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * 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.sfc.impl;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-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.Service;
-import org.onosproject.vtnrsc.sfc.PortChain;
-import org.slf4j.Logger;
-
-/**
- * Provides implementation of SFC Service.
- */
-@Component(immediate = true)
-@Service
-public class SfcManager implements SfcService {
-
- private final Logger log = getLogger(SfcManager.class);
-
- @Activate
- public void activate() {
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public void InstallFlowClassification(PortChain portChain) {
- log.debug("InstallFlowClassification");
- //TODO: Installation of flow classification into OVS.
- }
-
- @Override
- public void UnInstallFlowClassification(PortChain portChain) {
- log.debug("UnInstallFlowClassification");
- //TODO: Un-installation flow classification from OVS
- }
-
- @Override
- public void InstallServiceFunctionChain(PortChain portChain) {
- log.debug("InstallServiceFunctionChain");
- //TODO: Installation of Service Function chain into OVS.
- }
-
- @Override
- public void UnInstallServiceFunctionChain(PortChain portChain) {
- log.debug("UnInstallServiceFunctionChain");
- //TODO: Un-installation of Service Function chain from OVS.
- }
-}
diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/package-info.java
deleted file mode 100644
index 0dba868c..00000000
--- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * SFC Service manager for interacting with SFC.
- */
-package org.onosproject.sfc.impl;
diff --git a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/package-info.java b/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/package-info.java
deleted file mode 100644
index 1dcb9929..00000000
--- a/framework/src/onos/apps/vtn/sfcmgr/src/main/java/org/onosproject/sfc/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Service for interacting with SFC.
- */
-package org.onosproject.sfc;
diff --git a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/VTNService.java b/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/VTNService.java
deleted file mode 100644
index a20f852b..00000000
--- a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/VTNService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.vtn;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.Host;
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-public interface VTNService {
-
- /**
- * Creates a vxlan tunnel and creates the ovs when a ovs controller node is detected.
- *
- * @param device controller-type device
- */
- void onServerDetected(Device device);
-
- /**
- * Drops a vxlan tunnel and drops the ovs when a ovs controller node is vanished.
- *
- * @param device controller-type device
- */
- void onServerVanished(Device device);
-
- /**
- * Applies default forwarding flows when a ovs is detected.
- *
- * @param device switch-type device
- */
- void onOvsDetected(Device device);
-
- /**
- * Remove default forwarding flows when a ovs is vanished.
- *
- * @param device switch-type device
- */
- void onOvsVanished(Device device);
-
- /**
- * Applies multicast flows and tunnel flows when a VM is detected.
- *
- * @param host a VM
- */
- void onHostDetected(Host host);
-
- /**
- * Remove multicast flows and tunnel flows when a VM is vanished.
- *
- * @param host a VM
- */
- void onHostVanished(Host host);
-
-}
diff --git a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/VTNManager.java b/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/VTNManager.java
deleted file mode 100644
index 090ef0f1..00000000
--- a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/VTNManager.java
+++ /dev/null
@@ -1,672 +0,0 @@
-/*
- * 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.vtn.impl;
-
-import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
-import static org.onlab.util.Tools.groupedThreads;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.stream.Collectors;
-
-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.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.BridgeConfig;
-import org.onosproject.net.behaviour.BridgeDescription;
-import org.onosproject.net.behaviour.BridgeName;
-import org.onosproject.net.behaviour.DefaultTunnelDescription;
-import org.onosproject.net.behaviour.IpTunnelEndPoint;
-import org.onosproject.net.behaviour.Pipeliner;
-import org.onosproject.net.behaviour.PipelinerContext;
-import org.onosproject.net.behaviour.TunnelConfig;
-import org.onosproject.net.behaviour.TunnelDescription;
-import org.onosproject.net.behaviour.TunnelEndPoint;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DefaultDriverData;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.FlowObjectiveStore;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostService;
-import org.onosproject.store.serializers.KryoNamespaces;
-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;
-
-/**
- * Provides implementation of VTNService.
- */
-@Component(immediate = true)
-@Service
-public class VTNManager implements VTNService {
- private final Logger log = getLogger(getClass());
-
- private static final String APP_ID = "org.onosproject.app.vtn";
- private ScheduledExecutorService backgroundService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService tenantNetworkService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected VirtualPortService virtualPortService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DriverService driverService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveService flowObjectiveService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveStore flowObjectiveStore;
- protected ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- private EventuallyConsistentMap<HostId, SegmentationId> binding;
- private ApplicationId appId;
- private HostListener hostListener = new InnerHostListener();
- private DeviceListener deviceListener = new InnerDeviceListener();
- private static final String IFACEID = "ifaceid";
- private static final String PORT_HEAD = "vxlan";
- private static final String DEFAULT_BRIDGE_NAME = "br-int";
- private static final String CONTROLLER_IP_KEY = "ipaddress";
- private static final int DEFAULT_MAC_PRIORITY = 0x0000;
- private static final int MAC_PRIORITY = 0xffff;
- private static final int DEFAULT_PORT_PRIORITY = 0x0000;
- private static final int PORT_PRIORITY = 0xffff;
- private static final String SWITCH_CHANNEL_ID = "channelId";
- private static final String DRIVER_NAME = "onosfw";
-
- @Activate
- public void activate() {
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API);
- appId = coreService.registerApplication(APP_ID);
- deviceService.addListener(deviceListener);
- hostService.addListener(hostListener);
- backgroundService = newSingleThreadScheduledExecutor(groupedThreads("onos-apps/vtn",
- "manager-background"));
- binding = storageService
- .<HostId, SegmentationId>eventuallyConsistentMapBuilder()
- .withName("all_tunnel").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- backgroundService.shutdown();
- binding.destroy();
- log.info("Stopped");
- }
-
- @Override
- public void onServerDetected(Device device) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- DriverHandler handler = driverService.createHandler(device.id());
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME));
- String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
- IpAddress ip = IpAddress.valueOf(ipAddress);
- Sets.newHashSet(devices).stream()
- .filter(d -> Device.Type.CONTROLLER == d.type())
- .filter(d -> !device.id().equals(d.id())).forEach(d -> {
- String ipAddress1 = d.annotations()
- .value(CONTROLLER_IP_KEY);
- IpAddress ip1 = IpAddress.valueOf(ipAddress1);
- applyTunnelConfig(ip, ip1, handler);
- DriverHandler handler1 = driverService
- .createHandler(d.id());
- applyTunnelConfig(ip1, ip, handler1);
-
- });
- }
-
- @Override
- public void onServerVanished(Device device) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
- IpAddress dst = IpAddress.valueOf(ipAddress);
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER)
- .filter(d -> !device.id().equals(d.id())).forEach(d -> {
- String ipAddress1 = d.annotations()
- .value(CONTROLLER_IP_KEY);
- DriverHandler handler = driverService.createHandler(d.id());
- IpAddress src = IpAddress.valueOf(ipAddress1);
- removeTunnelConfig(src, dst, handler);
- });
- }
-
- private void applyTunnelConfig(IpAddress src, IpAddress dst,
- DriverHandler handler) {
- TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
- TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelAsSrc,
- tunnelAsDst,
- TunnelDescription.Type.VXLAN,
- null);
- TunnelConfig config = handler.behaviour(TunnelConfig.class);
- config.createTunnel(tunnel);
- }
-
- private void removeTunnelConfig(IpAddress src, IpAddress dst,
- DriverHandler handler) {
- TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
- TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelAsSrc,
- tunnelAsDst,
- TunnelDescription.Type.VXLAN,
- null);
- TunnelConfig config = handler.behaviour(TunnelConfig.class);
- config.removeTunnel(tunnel);
- }
-
- @Override
- public void onOvsDetected(Device device) {
- programMacDefaultRules(device.id(), appId, Objective.Operation.ADD);
- programPortDefaultRules(device.id(), appId, Objective.Operation.ADD);
- }
-
- @Override
- public void onOvsVanished(Device device) {
- programMacDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
- programPortDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
- }
-
- @Override
- public void onHostDetected(Host host) {
- String ifaceId = host.annotations().value(IFACEID);
- DeviceId deviceId = host.location().deviceId();
- String currentControllerIp = getControllerIpOfSwitch(deviceId);
- Iterable<Device> devices = deviceService.getAvailableDevices();
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- TenantNetwork network = tenantNetworkService
- .getNetwork(port.networkId());
- String tunnelName = "vxlan-" + currentControllerIp;
- binding.put(host.id(), network.segmentationId());
- List<Port> allPorts = deviceService.getPorts(deviceId);
- PortNumber inPort = host.location().port();
- List<PortNumber> localVmPorts = getLocalPorts(deviceId, ifaceId);
- List<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(allPorts.iterator()).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL)).forEach(p -> {
- if (p.annotations().value("portName").startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
-
- localVmPorts.forEach(lp -> programLocalBcastRules(deviceId, network.segmentationId(), lp, localVmPorts,
- localTunnelPorts, appId, Objective.Operation.ADD));
- programLocalOut(deviceId, network.segmentationId(), inPort, host.mac(),
- appId, Objective.Operation.ADD);
- localTunnelPorts
- .forEach(tp -> programTunnelFloodOut(deviceId,
- network.segmentationId(),
- tp, localVmPorts,
- appId,
- Objective.Operation.ADD));
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER).forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler
- .behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig
- .getBridges();
-
- Iterator<BridgeDescription> it = bridgeDescriptions
- .iterator();
- if (it.hasNext()) {
- BridgeDescription sw = it.next();
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- ports.stream()
- .filter(p -> p.name()
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> programTunnelOut(sw.deviceId(),
- network.segmentationId(), p,
- host.mac(), appId,
- Objective.Operation.ADD));
- }
- });
- programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(),
- appId, Objective.Operation.ADD);
- localTunnelPorts
- .forEach(tp -> programTunnelIn(deviceId,
- network.segmentationId(),
- tp, inPort, host.mac(),
- appId, Objective.Operation.ADD));
-
- }
-
- @Override
- public void onHostVanished(Host host) {
- String ifaceId = host.annotations().value(IFACEID);
- SegmentationId segId = binding.remove(host.id());
- DeviceId deviceId = host.location().deviceId();
- String currentControllerIp = getControllerIpOfSwitch(deviceId);
- Iterable<Device> devices = deviceService.getAvailableDevices();
-
- String tunnelName = "vxlan-" + currentControllerIp;
- List<Port> allPorts = deviceService.getPorts(deviceId);
- PortNumber inPort = host.location().port();
-
- List<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(allPorts.iterator()).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL)).forEach(p -> {
- if (p.annotations().value("portName").startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
-
- List<PortNumber> localVmPorts = getLocalPorts(deviceId, ifaceId);
- localVmPorts.add(inPort);
- localVmPorts.forEach(lp -> programLocalBcastRules(deviceId, segId, lp, localVmPorts,
- localTunnelPorts, appId, Objective.Operation.REMOVE));
- programLocalOut(deviceId, segId, inPort, host.mac(),
- appId, Objective.Operation.REMOVE);
- localTunnelPorts
- .forEach(tp -> programTunnelFloodOut(deviceId,
- segId,
- tp, localVmPorts,
- appId,
- Objective.Operation.REMOVE));
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER).forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler
- .behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig
- .getBridges();
-
- Iterator<BridgeDescription> it = bridgeDescriptions
- .iterator();
- if (it.hasNext()) {
- BridgeDescription sw = it.next();
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- ports.stream()
- .filter(p -> p.name()
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> programTunnelOut(sw.deviceId(),
- segId, p,
- host.mac(), appId,
- Objective.Operation.REMOVE));
- }
- });
- programLocalIn(deviceId, segId, inPort, host.mac(),
- appId, Objective.Operation.REMOVE);
- localTunnelPorts
- .forEach(tp -> programTunnelIn(deviceId,
- segId,
- tp, inPort, host.mac(),
- appId, Objective.Operation.REMOVE));
- }
-
- private class InnerDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (Device.Type.CONTROLLER == device.type()
- && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> onServerDetected(device));
- } else if (Device.Type.CONTROLLER == device.type()
- && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
- .type()) {
- backgroundService.execute(() -> onServerVanished(device));
- } else if (Device.Type.SWITCH == device.type()
- && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> onOvsDetected(device));
- } else if (Device.Type.SWITCH == device.type()
- && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
- .type()) {
- backgroundService.execute(() -> onOvsVanished(device));
- } else {
- log.info("Do nothing for this device type");
- }
- }
-
- }
-
- private class InnerHostListener implements HostListener {
-
- @Override
- public void event(HostEvent event) {
- Host host = event.subject();
- if (HostEvent.Type.HOST_ADDED == event.type()) {
- backgroundService.execute(() -> onHostDetected(host));
- } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
- backgroundService.execute(() -> onHostVanished(host));
- } else if (HostEvent.Type.HOST_UPDATED == event.type()) {
- backgroundService.execute(() -> {
- onHostVanished(host);
- onHostDetected(host);
- });
- }
- }
-
- }
-
- // Used to forward the flows to the local VM.
- private void programLocalOut(DeviceId dpid, SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchTunnelId(Long.parseLong(segmentationId.toString()))
- .matchEthDst(sourceMac).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(outPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
-
- }
-
- // Used to forward the flows into the VXLAN tunnel.
- private void programTunnelOut(DeviceId dpid, SegmentationId segmentationId,
- PortNumber tunnelOutPort, MacAddress dstMac,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthDst(dstMac).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
-
- .setOutput(tunnelOutPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
-
- }
-
- // Used to forward multicast flows to remote VMs of the same tenant via
- // VXLAN tunnel.
- private void programTunnelFloodOut(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber ofPortOut,
- List<PortNumber> localVmPorts,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(ofPortOut)
-
- .add(Criteria.matchTunnelId(Long.parseLong(segmentationId
- .toString()))).matchEthDst(MacAddress.BROADCAST)
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
-
- for (PortNumber outPort : localVmPorts) {
- treatment.setOutput(outPort);
- }
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(deviceId, objective.add());
- } else {
- flowServiceForward(deviceId, objective.remove());
- }
- }
-
- // Applies default flows to mac table.
- private void programMacDefaultRules(DeviceId dpid, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder().build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().drop()
- .build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(DEFAULT_MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to forward the flows to the local VMs with the same tenant.
- private void programLocalBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber inPort,
- List<PortNumber> localVmPorts,
- List<PortNumber> localTunnelPorts,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthDst(MacAddress.BROADCAST)
- .add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- for (PortNumber outPort : localVmPorts) {
- if (inPort != outPort) {
- treatment.setOutput(outPort);
- }
- }
- for (PortNumber outport : localTunnelPorts) {
- treatment.setOutput(outport);
- }
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(deviceId, objective.add());
- } else {
- flowServiceForward(deviceId, objective.remove());
- }
- }
-
- // Used to apply local entry flow.
- private void programLocalIn(DeviceId dpid, SegmentationId segmentationId,
- PortNumber inPort, MacAddress srcMac,
- ApplicationId appid, Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthSrc(srcMac).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.add(Instructions.modTunnelId(Long.parseLong(segmentationId
- .toString())));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to forward the flows from the egress tunnel to the VM.
- private void programTunnelIn(DeviceId dpid, SegmentationId segmentationId,
- PortNumber tunnelInPort, PortNumber outPort,
- MacAddress sourceMac, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(tunnelInPort).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Applies the default flows to port table.
- private void programPortDefaultRules(DeviceId dpid, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder().build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(DEFAULT_PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to get channelId from the device annotations.
- private String getControllerIpOfSwitch(DeviceId deviceId) {
- Device device = deviceService.getDevice(deviceId);
- String url = device.annotations().value(SWITCH_CHANNEL_ID);
- return url.substring(0, url.lastIndexOf(":"));
- }
-
- private Iterable<String> getIfaceIds(String ifaceId) {
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- if (port == null) {
- return Collections.emptyList();
- }
-
- TenantNetwork network = tenantNetworkService
- .getNetwork(port.networkId());
- if (network == null) {
- return Collections.emptyList();
- }
-
- Collection<VirtualPort> ports = virtualPortService
- .getPorts(network.id());
- return ports.stream().map(p -> p.portId().portId())
- .collect(Collectors.toSet());
- }
-
- private List<PortNumber> getLocalPorts(DeviceId deviceId, String ifaceId) {
- DriverHandler handler = driverService
- .createHandler(getController(deviceId));
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- Iterable<String> ifaceIds = getIfaceIds(ifaceId);
- return bridgeConfig.getLocalPorts(ifaceIds);
- }
-
- private DeviceId getController(DeviceId deviceId) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- for (Device device : devices) {
- if (device.type() == Device.Type.CONTROLLER && device.id()
- .toString().contains(getControllerIpOfSwitch(deviceId))) {
- return device.id();
- }
- }
- log.info("Can not find controller for device : {}", deviceId);
- return null;
- }
-
- //Used to apply flowRule
- private void flowServiceForward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
- Driver driver = driverService.getDriver(DRIVER_NAME);
- Pipeliner pipeLiner = driver.createBehaviour(new DefaultDriverData(driver, deviceId), Pipeliner.class);
- if (pipeLiner != null) {
- final PipelinerContext context = new InnerPipelineContext();
- pipeLiner.init(deviceId, context);
- pipeLiner.forward(forwardingObjective);
- }
- }
-
- // Processing context for initializing pipeline driver behaviours.
- private class InnerPipelineContext implements PipelinerContext {
- @Override
- public ServiceDirectory directory() {
- return serviceDirectory;
- }
-
- @Override
- public FlowObjectiveStore store() {
- return flowObjectiveStore;
- }
- }
-
-}
diff --git a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/package-info.java b/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/package-info.java
deleted file mode 100644
index f18dbf8a..00000000
--- a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.impl;
diff --git a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/package-info.java b/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/package-info.java
deleted file mode 100644
index 371466c3..00000000
--- a/framework/src/onos/apps/vtn/vtnmgr/src/main/java/org/onosproject/vtn/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn;
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
index 39df2cff..7915ce08 100644
--- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
@@ -43,6 +43,8 @@ public final class DefaultFlowClassifier implements FlowClassifier {
private static final int NULL_PORT = 0;
private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "FlowClassifier id can not be null.";
private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null.";
+ private static final String NAME_NOT_NULL = "Name can not be null.";
+ private static final String ETHER_TYPE_NOT_NULL = "Ether Type can not be null.";
/**
* Constructor to create default flow classifier.
@@ -160,11 +162,9 @@ public final class DefaultFlowClassifier implements FlowClassifier {
private FlowClassifierId flowClassifierId;
private TenantId tenantId;
private String name;
- private boolean isFlowClassifierNameSet = false;
private String description;
private boolean isFlowClassifierDescriptionSet = false;
private String etherType;
- private boolean isEtherTypeSet = false;
private String protocol;
private boolean isProtocolSet = false;
private int minSrcPortRange;
@@ -189,9 +189,9 @@ public final class DefaultFlowClassifier implements FlowClassifier {
checkNotNull(flowClassifierId, FLOW_CLASSIFIER_ID_NOT_NULL);
checkNotNull(tenantId, TENANT_ID_NOT_NULL);
- String name = null;
+ checkNotNull(name, NAME_NOT_NULL);
+ checkNotNull(etherType, ETHER_TYPE_NOT_NULL);
String description = null;
- String etherType = null;
String protocol = null;
int minSrcPortRange = NULL_PORT;
int maxSrcPortRange = NULL_PORT;
@@ -202,15 +202,9 @@ public final class DefaultFlowClassifier implements FlowClassifier {
VirtualPortId srcPort = null;
VirtualPortId dstPort = null;
- if (isFlowClassifierNameSet) {
- name = this.name;
- }
if (isFlowClassifierDescriptionSet) {
description = this.description;
}
- if (isEtherTypeSet) {
- etherType = this.etherType;
- }
if (isProtocolSet) {
protocol = this.protocol;
}
@@ -259,7 +253,6 @@ public final class DefaultFlowClassifier implements FlowClassifier {
@Override
public Builder setName(String name) {
this.name = name;
- this.isFlowClassifierNameSet = true;
return this;
}
@@ -273,7 +266,6 @@ public final class DefaultFlowClassifier implements FlowClassifier {
@Override
public Builder setEtherType(String etherType) {
this.etherType = etherType;
- this.isEtherTypeSet = true;
return this;
}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java
deleted file mode 100644
index 6b0d9a64..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/DefaultFlowClassifierTest.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * 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.flowclassifier;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.DefaultFlowClassifier;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.FlowClassifier;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultFlowClassifier class.
- */
-public class DefaultFlowClassifierTest {
- /**
- * Checks that the DefaultFlowClassifier class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultFlowClassifier.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // Create same two flow classifier objects.
- final String name = "FlowClassifier1";
- final String description = "FlowClassifier1";
- final String ethType = "IPv4";
- final String protocol = "tcp";
- final int minSrcPortRange = 5;
- final int maxSrcPortRange = 10;
- final int minDstPortRange = 5;
- final int maxDstPortRange = 10;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("1");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("2");
-
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
-
- flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier sameAsFlowClassifier1 = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
-
- // Create different classifier object.
- final String name2 = "FlowClassifier2";
- final String description2 = "FlowClassifier2";
- final String ethType2 = "IPv6";
- final String protocol2 = "udp";
- final int minSrcPortRange2 = 5;
- final int maxSrcPortRange2 = 10;
- final int minDstPortRange2 = 5;
- final int maxDstPortRange2 = 10;
- final FlowClassifierId flowClassifierId2 = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final IpPrefix srcIpPrefix2 = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix2 = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort2 = VirtualPortId.portId("3");
- final VirtualPortId virtualDstPort2 = VirtualPortId.portId("4");
-
- DefaultFlowClassifier.Builder flowClassifierBuilder3 = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier2 = flowClassifierBuilder3.setFlowClassifierId(flowClassifierId2)
- .setTenantId(tenantId2).setName(name2).setDescription(description2).setEtherType(ethType2)
- .setProtocol(protocol2).setMinSrcPortRange(minSrcPortRange2).setMaxSrcPortRange(maxSrcPortRange2)
- .setMinDstPortRange(minDstPortRange2).setMaxDstPortRange(maxDstPortRange2).setSrcIpPrefix(srcIpPrefix2)
- .setDstIpPrefix(dstIpPrefix2).setSrcPort(virtualSrcPort2).setDstPort(virtualDstPort2).build();
-
- new EqualsTester().addEqualityGroup(flowClassifier1, sameAsFlowClassifier1).addEqualityGroup(flowClassifier2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultFlowClassifier object.
- */
- @Test
- public void testConstruction() {
- final String name = "FlowClassifier";
- final String description = "FlowClassifier";
- final String ethType = "IPv4";
- final String protocol = "tcp";
- final int minSrcPortRange = 5;
- final int maxSrcPortRange = 10;
- final int minDstPortRange = 5;
- final int maxDstPortRange = 10;
- final FlowClassifierId flowClassifierId = FlowClassifierId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0");
- final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0");
- final VirtualPortId virtualSrcPort = VirtualPortId.portId("1");
- final VirtualPortId virtualDstPort = VirtualPortId.portId("2");
-
- DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder();
- final FlowClassifier flowClassifier = flowClassifierBuilder.setFlowClassifierId(flowClassifierId)
- .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType)
- .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange)
- .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix)
- .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build();
-
- assertThat(flowClassifierId, is(flowClassifier.flowClassifierId()));
- assertThat(tenantId, is(flowClassifier.tenantId()));
- assertThat(name, is(flowClassifier.name()));
- assertThat(description, is(flowClassifier.description()));
- assertThat(ethType, is(flowClassifier.etherType()));
- assertThat(protocol, is(flowClassifier.protocol()));
- assertThat(minSrcPortRange, is(flowClassifier.minSrcPortRange()));
- assertThat(maxSrcPortRange, is(flowClassifier.maxSrcPortRange()));
- assertThat(minDstPortRange, is(flowClassifier.minDstPortRange()));
- assertThat(maxDstPortRange, is(flowClassifier.maxDstPortRange()));
- assertThat(srcIpPrefix, is(flowClassifier.srcIpPrefix()));
- assertThat(dstIpPrefix, is(flowClassifier.dstIpPrefix()));
- assertThat(virtualSrcPort, is(flowClassifier.srcPort()));
- assertThat(virtualDstPort, is(flowClassifier.dstPort()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java
deleted file mode 100644
index 4f521836..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/flowclassifier/FlowClassifierIdTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.flowclassifier;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.FlowClassifierId;
-
-import com.google.common.testing.EqualsTester;
-import java.util.UUID;
-
-/**
- * Unit tests for FlowClassifierId class.
- */
-public class FlowClassifierIdTest {
-
- final FlowClassifierId flowClassifierId1 = FlowClassifierId
- .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final FlowClassifierId sameAsFlowClassifierId1 = FlowClassifierId
- .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final FlowClassifierId flowClassifierId2 = FlowClassifierId
- .of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the FlowClassifierId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(FlowClassifierId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(flowClassifierId1, sameAsFlowClassifierId1)
- .addEqualityGroup(flowClassifierId2).testEquals();
- }
-
- /**
- * Checks the construction of a FlowClassifierId object.
- */
- @Test
- public void testConstruction() {
- final String flowClassifierIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final FlowClassifierId flowClassifierId = FlowClassifierId.of(flowClassifierIdValue);
- assertThat(flowClassifierId, is(notNullValue()));
- assertThat(flowClassifierId.value(), is(UUID.fromString(flowClassifierIdValue)));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java
deleted file mode 100644
index b9ce73d8..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/DefaultPortChainTest.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * 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.flowclassifier;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.onosproject.vtnrsc.PortChainId;
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.PortChain;
-import org.onosproject.vtnrsc.DefaultPortChain;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultPortChain class.
- */
-public class DefaultPortChainTest {
- /**
- * Checks that the DefaultPortChain class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultPortChain.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // Create same two port chain objects.
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain1";
- final String description = "PortChain1";
- // create list of Port Pair Groups.
- final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>();
- PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroups.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroups.add(portPairGroupId);
- // create list of Flow classifiers.
- final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>();
- FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifiers.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifiers.add(flowClassifierId);
-
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- final PortChain portChain1 = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers)
- .build();
-
- portChainBuilder = new DefaultPortChain.Builder();
- final PortChain samePortChain1 = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers)
- .build();
-
- // Create different port chain object.
- final PortChainId portChainId2 = PortChainId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortChain2";
- final String description2 = "PortChain2";
- // create list of Port Pair Groups.
- final List<PortPairGroupId> portPairGroups2 = new LinkedList<PortPairGroupId>();
- portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroups2.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroups2.add(portPairGroupId);
- // create list of Flow classifiers.
- final List<FlowClassifierId> flowClassifiers2 = new LinkedList<FlowClassifierId>();
- flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifiers2.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("76666666-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifiers2.add(flowClassifierId);
-
- portChainBuilder = new DefaultPortChain.Builder();
- final PortChain portChain2 = portChainBuilder.setId(portChainId2).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setPortPairGroups(portPairGroups2).setFlowClassifiers(flowClassifiers2)
- .build();
-
- new EqualsTester().addEqualityGroup(portChain1, samePortChain1).addEqualityGroup(portChain2).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPortChain object.
- */
- @Test
- public void testConstruction() {
- final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortChain";
- final String description = "PortChain";
- // create list of Port Pair Groups.
- final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>();
- PortPairGroupId portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairGroups.add(portPairGroupId);
- portPairGroupId = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3af");
- portPairGroups.add(portPairGroupId);
- // create list of Flow classifiers.
- final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>();
- FlowClassifierId flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- flowClassifiers.add(flowClassifierId);
- flowClassifierId = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af");
- flowClassifiers.add(flowClassifierId);
-
- DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder();
- final PortChain portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name)
- .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers)
- .build();
-
- assertThat(portChainId, is(portChain.portChainId()));
- assertThat(tenantId, is(portChain.tenantId()));
- assertThat(name, is(portChain.name()));
- assertThat(description, is(portChain.description()));
- assertThat(portPairGroups, is(portChain.portPairGroups()));
- assertThat(flowClassifiers, is(portChain.flowClassifiers()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java
deleted file mode 100644
index a87bdb99..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portchain/PortChainIdTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.portchain;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.PortChainId;
-
-import com.google.common.testing.EqualsTester;
-import java.util.UUID;
-
-/**
- * Unit tests for PortChainId class.
- */
-public class PortChainIdTest {
-
- final PortChainId portChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortChainId sameAsPortChainId1 = PortChainId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortChainId portChainId2 = PortChainId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the PortChainId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortChainId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(portChainId1, sameAsPortChainId1).addEqualityGroup(portChainId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a PortChainId object.
- */
- @Test
- public void testConstruction() {
- final String portChainIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final PortChainId portChainId = PortChainId.of(portChainIdValue);
- assertThat(portChainId, is(notNullValue()));
- assertThat(portChainId.value(), is(UUID.fromString(portChainIdValue)));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java
deleted file mode 100644
index 91e7ab37..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/DefaultPortPairTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * 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.flowclassifier;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.PortPair;
-import org.onosproject.vtnrsc.DefaultPortPair;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultPortPair class.
- */
-public class DefaultPortPairTest {
- /**
- * Checks that the DefaultPortPair class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultPortPair.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // Create same two port pair objects.
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair1";
- final String description = "PortPair1";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
-
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- final PortPair portPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
-
- portPairBuilder = new DefaultPortPair.Builder();
- final PortPair samePortPair1 = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
-
- // Create different port pair object.
- final PortPairId portPairId2 = PortPairId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortPair2";
- final String description2 = "PortPair2";
- final String ingress2 = "d5555555-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress2 = "a6666666-4a56-2a6e-cd3a-9dee4e2ec345";
-
- portPairBuilder = new DefaultPortPair.Builder();
- final PortPair portPair2 = portPairBuilder.setId(portPairId2).setTenantId(tenantId2).setName(name2)
- .setDescription(description2).setIngress(ingress2).setEgress(egress2).build();
-
- new EqualsTester().addEqualityGroup(portPair1, samePortPair1).addEqualityGroup(portPair2).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPortPair object.
- */
- @Test
- public void testConstruction() {
- final PortPairId portPairId = PortPairId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPair";
- final String description = "PortPair";
- final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1";
- final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345";
-
- DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder();
- final PortPair portPair = portPairBuilder.setId(portPairId).setTenantId(tenantId).setName(name)
- .setDescription(description).setIngress(ingress).setEgress(egress).build();
-
- assertThat(portPairId, is(portPair.portPairId()));
- assertThat(tenantId, is(portPair.tenantId()));
- assertThat(name, is(portPair.name()));
- assertThat(description, is(portPair.description()));
- assertThat(ingress, is(portPair.ingress()));
- assertThat(egress, is(portPair.egress()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java
deleted file mode 100644
index f176089e..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpair/PortPairIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.portpair;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.PortPairId;
-
-import com.google.common.testing.EqualsTester;
-import java.util.UUID;
-
-/**
- * Unit tests for PortPairId class.
- */
-public class PortPairIdTest {
-
- final PortPairId portPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairId sameAsPortPairId1 = PortPairId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairId portPairId2 = PortPairId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the PortPairId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortPairId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(portPairId1, sameAsPortPairId1).addEqualityGroup(portPairId2).testEquals();
- }
-
- /**
- * Checks the construction of a PortPairId object.
- */
- @Test
- public void testConstruction() {
- final String portPairIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final PortPairId portPairId = PortPairId.of(portPairIdValue);
- assertThat(portPairId, is(notNullValue()));
- assertThat(portPairId.value(), is(UUID.fromString(portPairIdValue)));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java
deleted file mode 100644
index 2528fb29..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/DefaultPortPairGroupTest.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * 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.flowclassifier;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import java.util.List;
-import java.util.LinkedList;
-
-import org.onosproject.vtnrsc.PortPairGroupId;
-import org.onosproject.vtnrsc.PortPairId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.PortPairGroup;
-import org.onosproject.vtnrsc.DefaultPortPairGroup;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultPortPairGroup class.
- */
-public class DefaultPortPairGroupTest {
- /**
- * Checks that the DefaultPortPairGroup class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultPortPairGroup.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- // Create same two port-pair-group objects.
- final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPairGroup1";
- final String description = "PortPairGroup1";
- // create port-pair-id list
- final List<PortPairId> portPairList = new LinkedList<PortPairId>();
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList.add(portPairId);
- portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList.add(portPairId);
-
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- final PortPairGroup portPairGroup1 = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId)
- .setName(name).setDescription(description).setPortPairs(portPairList).build();
-
- portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- final PortPairGroup samePortPairGroup1 = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId)
- .setName(name).setDescription(description).setPortPairs(portPairList).build();
-
- // Create different port-pair-group object.
- final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("79999999-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId2 = TenantId.tenantId("2");
- final String name2 = "PortPairGroup2";
- final String description2 = "PortPairGroup2";
- // create port-pair-id list
- final List<PortPairId> portPairList2 = new LinkedList<PortPairId>();
- portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList2.add(portPairId);
- portPairId = PortPairId.of("75555555-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList2.add(portPairId);
-
- portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- final PortPairGroup portPairGroup2 = portPairGroupBuilder.setId(portPairGroupId2).setTenantId(tenantId2)
- .setName(name2).setDescription(description2).setPortPairs(portPairList2).build();
-
- new EqualsTester().addEqualityGroup(portPairGroup1, samePortPairGroup1).addEqualityGroup(portPairGroup2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a DefaultPortPairGroup object.
- */
- @Test
- public void testConstruction() {
- final PortPairGroupId portPairGroupId = PortPairGroupId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae");
- final TenantId tenantId = TenantId.tenantId("1");
- final String name = "PortPairGroup";
- final String description = "PortPairGroup";
- // create port-pair-id list
- final List<PortPairId> portPairList = new LinkedList<PortPairId>();
- PortPairId portPairId = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList.add(portPairId);
- portPairId = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae");
- portPairList.add(portPairId);
-
- DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder();
- final PortPairGroup portPairGroup = portPairGroupBuilder.setId(portPairGroupId).setTenantId(tenantId)
- .setName(name).setDescription(description).setPortPairs(portPairList).build();
-
- assertThat(portPairGroupId, is(portPairGroup.portPairGroupId()));
- assertThat(tenantId, is(portPairGroup.tenantId()));
- assertThat(name, is(portPairGroup.name()));
- assertThat(description, is(portPairGroup.description()));
- assertThat(portPairList, is(portPairGroup.portPairs()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java
deleted file mode 100644
index 25db9d2e..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupIdTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.portpairgroup;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.PortPairGroupId;
-
-import com.google.common.testing.EqualsTester;
-import java.util.UUID;
-
-/**
- * Unit tests for PortPairGroupId class.
- */
-public class PortPairGroupIdTest {
-
- final PortPairGroupId portPairGroupId1 = PortPairGroupId.of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairGroupId sameAsPortPairGroupId1 = PortPairGroupId
- .of("78dcd363-fc23-aeb6-f44b-56dc5e2fb3ae");
- final PortPairGroupId portPairGroupId2 = PortPairGroupId.of("dace4513-24fc-4fae-af4b-321c5e2eb3d1");
-
- /**
- * Checks that the PortPairGroupId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PortPairGroupId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(portPairGroupId1, sameAsPortPairGroupId1)
- .addEqualityGroup(portPairGroupId2).testEquals();
- }
-
- /**
- * Checks the construction of a PortPairGroupId object.
- */
- @Test
- public void testConstruction() {
- final String portPairGroupIdValue = "dace4513-24fc-4fae-af4b-321c5e2eb3d1";
- final PortPairGroupId portPairGroupId = PortPairGroupId.of(portPairGroupIdValue);
- assertThat(portPairGroupId, is(notNullValue()));
- assertThat(portPairGroupId.value(), is(UUID.fromString(portPairGroupIdValue)));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java
deleted file mode 100644
index ce6b6c00..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterGatewayTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * 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.router;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.RouterGateway;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.FixedIp;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for RouterGateway class.
- */
-public class RouterGatewayTest {
- final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
- final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
- final Set<FixedIp> fixedIpSet1 = new HashSet<>();
- final Set<FixedIp> fixedIpSet2 = new HashSet<>();
-
- /**
- * Checks that the RouterGateway class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(RouterGateway.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- RouterGateway routerGateway1 = RouterGateway.routerGateway(networkId1,
- true,
- fixedIpSet1);
- RouterGateway routerGateway2 = RouterGateway.routerGateway(networkId1,
- true,
- fixedIpSet1);
- RouterGateway routerGateway3 = RouterGateway.routerGateway(networkId2,
- true,
- fixedIpSet2);
- new EqualsTester().addEqualityGroup(routerGateway1, routerGateway2)
- .addEqualityGroup(routerGateway3).testEquals();
- }
-
- /**
- * Checks the construction of a RouterGateway object.
- */
- @Test
- public void testConstruction() {
- RouterGateway routerGateway = RouterGateway.routerGateway(networkId1,
- true,
- fixedIpSet1);
- assertThat(fixedIpSet1, is(notNullValue()));
- assertThat(fixedIpSet1, is(routerGateway.externalFixedIps()));
- assertThat(networkId1, is(notNullValue()));
- assertThat(networkId1, is(routerGateway.networkId()));
- assertThat(routerGateway.enableSnat(), is(true));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java
deleted file mode 100644
index 3751c11a..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/router/RouterIdTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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.router;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.RouterId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for RouterId class.
- */
-public class RouterIdTest {
- final RouterId routerId1 = RouterId.valueOf("1");
- final RouterId sameAsRouterId1 = RouterId.valueOf("1");
- final RouterId routerId2 = RouterId.valueOf("2");
-
- /**
- * Checks that the RouterId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(RouterId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(routerId1, sameAsRouterId1).addEqualityGroup(routerId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a RouterId object.
- */
- @Test
- public void testConstruction() {
- final String routerIdValue = "s";
- final RouterId routerId = RouterId.valueOf(routerIdValue);
- assertThat(routerId, is(notNullValue()));
- assertThat(routerId.routerId(), is(routerIdValue));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java
deleted file mode 100644
index 4ce4def2..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultAllocationPoolTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.subnet;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultAllocationPool;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultAllocationPool class.
- */
-public class DefaultAllocationPoolTest {
-
- final IpAddress startIP1 = IpAddress.valueOf("192.168.1.1");
- final IpAddress startIP2 = IpAddress.valueOf("192.168.1.2");
- final IpAddress endIP1 = IpAddress.valueOf("192.168.1.1");
- final IpAddress endIP2 = IpAddress.valueOf("192.168.1.2");
-
- /**
- * Checks that the DefaultAllocationPool class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultAllocationPool.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- AllocationPool pool1 = new DefaultAllocationPool(startIP1, endIP1);
- AllocationPool pool2 = new DefaultAllocationPool(startIP1, endIP1);
- AllocationPool pool3 = new DefaultAllocationPool(startIP2, endIP2);
- new EqualsTester().addEqualityGroup(pool1, pool2)
- .addEqualityGroup(pool3).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultAllocationPool object.
- */
- @Test
- public void testConstruction() {
- final AllocationPool apool = new DefaultAllocationPool(startIP1, endIP1);
- assertThat(startIP1, is(apool.startIp()));
- assertThat(endIP1, is(apool.endIp()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java
deleted file mode 100644
index 2f751742..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/DefaultHostRouteTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * 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.subnet;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.vtnrsc.DefaultHostRoute;
-import org.onosproject.vtnrsc.HostRoute;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultHostRoute class.
- */
-public class DefaultHostRouteTest {
- final IpAddress nexthop1 = IpAddress.valueOf("192.168.1.1");
- final IpAddress nexthop2 = IpAddress.valueOf("192.168.1.2");
- final IpPrefix destination1 = IpPrefix.valueOf("1.1.1.1/1");
- final IpPrefix destination2 = IpPrefix.valueOf("1.1.1.1/2");
-
- /**
- * Checks that the DefaultHostRoute class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultHostRoute.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- HostRoute route1 = new DefaultHostRoute(nexthop1, destination1);
- HostRoute route2 = new DefaultHostRoute(nexthop1, destination1);
- HostRoute route3 = new DefaultHostRoute(nexthop2, destination2);
- new EqualsTester().addEqualityGroup(route1, route2)
- .addEqualityGroup(route3).testEquals();
- }
-
- /**
- * Checks the construction of a DefaultHostRoute object.
- */
- @Test
- public void testConstruction() {
- final HostRoute host = new DefaultHostRoute(nexthop1, destination1);
- assertThat(nexthop1, is(host.nexthop()));
- assertThat(destination1, is(host.destination()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java
deleted file mode 100644
index d18dd41a..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/subnet/SubnetIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.subnet;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.SubnetId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for SubnetId class.
- */
-public class SubnetIdTest {
-
- final SubnetId subnetId1 = SubnetId.subnetId("1");
- final SubnetId sameAsSubnetId1 = SubnetId.subnetId("1");
- final SubnetId subnetId2 = SubnetId.subnetId("2");
-
- /**
- * Checks that the SubnetId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SubnetId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(subnetId1, sameAsSubnetId1).addEqualityGroup(subnetId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a SubnetId object.
- */
- @Test
- public void testConstruction() {
- final String subnetIdValue = "s";
- final SubnetId subnetId = SubnetId.subnetId(subnetIdValue);
- assertThat(subnetId, is(notNullValue()));
- assertThat(subnetId.subnetId(), is(subnetIdValue));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java
deleted file mode 100644
index 742d5933..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/DefaultNeutronNetworkTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * 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.tenantnetwork;
-
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-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 com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultNeutronNetwork class.
- */
-public class DefaultNeutronNetworkTest {
-
- private String networkIdStr1 = "123";
- private String networkIdStr2 = "234";
- private String physicalNetworkStr = "1234";
- private String tenantIdStr = "345";
- private String segmentationIdStr = "1";
- private String name = "456";
-
- /**
- * Checks that the DefaultNeutronNetwork class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(DefaultTenantNetwork.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquality() {
- TenantNetworkId networkid1 = TenantNetworkId.networkId(networkIdStr1);
- TenantNetworkId networkid2 = TenantNetworkId.networkId(networkIdStr2);
- PhysicalNetwork physicalNetwork = PhysicalNetwork
- .physicalNetwork(physicalNetworkStr);
- TenantId tenantId = TenantId.tenantId(tenantIdStr);
- SegmentationId segmentationID = SegmentationId
- .segmentationId(segmentationIdStr);
- TenantNetwork p1 = new DefaultTenantNetwork(networkid1, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- TenantNetwork p2 = new DefaultTenantNetwork(networkid1, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- TenantNetwork p3 = new DefaultTenantNetwork(networkid2, name, false,
- TenantNetwork.State.ACTIVE,
- false, tenantId, false,
- TenantNetwork.Type.LOCAL,
- physicalNetwork,
- segmentationID);
- new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java
deleted file mode 100644
index e101795e..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/PhysicalNetworkTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * 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.tenantnetwork;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for PhysicalNetwork class.
- */
-public class PhysicalNetworkTest {
-
- final PhysicalNetwork physicalNetwork1 = PhysicalNetwork.physicalNetwork("1");
- final PhysicalNetwork sameAsPhysicalNetwork1 = PhysicalNetwork.physicalNetwork("1");
- final PhysicalNetwork physicalNetwork2 = PhysicalNetwork.physicalNetwork("2");
-
- /**
- * Checks that the PhysicalNetwork class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(PhysicalNetwork.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(physicalNetwork1, sameAsPhysicalNetwork1)
- .addEqualityGroup(physicalNetwork2).testEquals();
- }
-
- /**
- * Checks the construction of a PhysicalNetwork object.
- */
- @Test
- public void testConstruction() {
- final String physicalNetworkValue = "s";
- final PhysicalNetwork physicalNetwork = PhysicalNetwork
- .physicalNetwork(physicalNetworkValue);
- assertThat(physicalNetwork, is(notNullValue()));
- assertThat(physicalNetwork.physicalNetwork(), is(physicalNetworkValue));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java
deleted file mode 100644
index dea7baf6..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/SegmentationIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.tenantnetwork;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.SegmentationId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for SegmentationId class.
- */
-public class SegmentationIdTest {
-
- final SegmentationId segmentationID1 = SegmentationId.segmentationId("1");
- final SegmentationId sameAsSegmentationID1 = SegmentationId.segmentationId("1");
- final SegmentationId segmentationID2 = SegmentationId.segmentationId("2");
-
- /**
- * Checks that the SegmentationId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SegmentationId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(segmentationID1, sameAsSegmentationID1)
- .addEqualityGroup(segmentationID2).testEquals();
- }
-
- /**
- * Checks the construction of a segmentationId object.
- */
- @Test
- public void testConstruction() {
- final String segmentationIdValue = "s";
- final SegmentationId segmentationId = SegmentationId.segmentationId(segmentationIdValue);
- assertThat(segmentationId, is(notNullValue()));
- assertThat(segmentationId.segmentationId(), is(segmentationIdValue));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java
deleted file mode 100644
index e9216383..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.tenantnetwork;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.TenantId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for TenantId class.
- */
-public class TenantIdTest {
-
- final TenantId tenantId1 = TenantId.tenantId("1");
- final TenantId sameAsTenantId1 = TenantId.tenantId("1");
- final TenantId tenantId2 = TenantId.tenantId("2");
-
- /**
- * Checks that the TenantId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(TenantId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(tenantId1, sameAsTenantId1).addEqualityGroup(tenantId2)
- .testEquals();
- }
-
- /**
- * Checks the construction of a TenantId object.
- */
- @Test
- public void testConstruction() {
- final String tenantIdValue = "s";
- final TenantId tenantId = TenantId.tenantId(tenantIdValue);
- assertThat(tenantId, is(notNullValue()));
- assertThat(tenantId.tenantId(), is(tenantIdValue));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java
deleted file mode 100644
index 8271b51c..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkIdTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * 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.tenantnetwork;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for TenantNetworkId class.
- */
-public class TenantNetworkIdTest {
-
- final TenantNetworkId networkId1 = TenantNetworkId.networkId("1");
- final TenantNetworkId sameAsnetworkId1 = TenantNetworkId.networkId("1");
- final TenantNetworkId networkId2 = TenantNetworkId.networkId("2");
-
- /**
- * Checks that the TenantNetworkId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(TenantNetworkId.class);
- }
-
- /**
- * Checks the operation of equals() methods.
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(networkId1, sameAsnetworkId1)
- .addEqualityGroup(networkId2).testEquals();
- }
-
- /**
- * Checks the construction of a TenantNetworkId object.
- */
- @Test
- public void testConstruction() {
- final String networkIdValue = "s";
- final TenantNetworkId networkId = TenantNetworkId.networkId(networkIdValue);
- assertThat(networkId, is(notNullValue()));
- assertThat(networkId.networkId(), is(networkIdValue));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java
deleted file mode 100644
index dabe5896..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/AllowedAddressPairTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.virtualport;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for AllowedAddressPair class.
- */
-public class AllowedAddressPairTest {
-
- final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
- final IpAddress ip2 = IpAddress.valueOf("192.168.0.2");
- final MacAddress mac1 = MacAddress.valueOf("fa:16:3e:76:83:88");
- final MacAddress mac2 = MacAddress.valueOf("aa:16:3e:76:83:88");
-
- /**
- * Checks that the AllowedAddressPair class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(AllowedAddressPair.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- AllowedAddressPair p1 = AllowedAddressPair
- .allowedAddressPair(ip1, mac1);
- AllowedAddressPair p2 = AllowedAddressPair
- .allowedAddressPair(ip1, mac1);
- AllowedAddressPair p3 = AllowedAddressPair
- .allowedAddressPair(ip2, mac2);
- new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3)
- .testEquals();
- }
-
- /**
- * Checks the construction of a AllowedAddressPair object.
- */
- @Test
- public void testConstruction() {
- AllowedAddressPair allowedAddressPair = AllowedAddressPair
- .allowedAddressPair(ip1, mac1);
- assertThat(ip1, is(notNullValue()));
- assertThat(ip1, is(allowedAddressPair.ip()));
- assertThat(mac1, is(notNullValue()));
- assertThat(mac1, is(allowedAddressPair.mac()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java
deleted file mode 100644
index 8a0c8004..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/DefaultVirtualPortTest.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * 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.virtualport;
-
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-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 com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for DefaultVirtualPort class.
- */
-public class DefaultVirtualPortTest {
-
- private Set<FixedIp> fixedIps;
- private Map<String, String> propertyMap;
- private Set<AllowedAddressPair> allowedAddressPairs;
- private Set<SecurityGroup> securityGroups;
- private VirtualPortId id1;
- private VirtualPortId id2;
- private String macAddressStr = "fa:12:3e:56:ee:a2";
- private String ipAddress = "10.1.1.1";
- private String deviceStr = "of:000000000000001";
- private String tenantIdStr = "123";
- private String portId1 = "1241";
- private String portId2 = "1242";
- private String tenantNetworkId = "1234567";
- private String subnet = "1212";
- private String hostIdStr = "fa:e2:3e:56:ee:a2";
-
- private void initVirtualPortId() {
- id1 = VirtualPortId.portId(portId1);
- id2 = VirtualPortId.portId(portId2);
- }
-
- private void initFixedIpSet() {
- FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(subnet),
- IpAddress.valueOf(ipAddress));
- fixedIps = Sets.newHashSet();
- fixedIps.add(fixedIp);
- }
-
- private void initPropertyMap() {
- String deviceOwner = "james";
- propertyMap = Maps.newHashMap();
- propertyMap.putIfAbsent("deviceOwner", deviceOwner);
- }
-
- private void initAddressPairSet() {
- allowedAddressPairs = Sets.newHashSet();
- AllowedAddressPair allowedAddressPair = AllowedAddressPair
- .allowedAddressPair(IpAddress.valueOf(ipAddress),
- MacAddress.valueOf(macAddressStr));
- allowedAddressPairs.add(allowedAddressPair);
- }
-
- private void initSecurityGroupSet() {
- securityGroups = Sets.newHashSet();
- }
-
- /**
- * Checks that the DefaultVirtualPort class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SecurityGroup.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- initVirtualPortId();
- initFixedIpSet();
- initPropertyMap();
- initAddressPairSet();
- initSecurityGroupSet();
- TenantNetworkId networkId = TenantNetworkId.networkId(tenantNetworkId);
- MacAddress macAddress = MacAddress.valueOf(macAddressStr);
- TenantId tenantId = TenantId.tenantId(tenantIdStr);
- DeviceId deviceId = DeviceId.deviceId(deviceStr);
- BindingHostId bindingHostId = BindingHostId.bindingHostId(hostIdStr);
-
- VirtualPort d1 = new DefaultVirtualPort(id1, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- VirtualPort d2 = new DefaultVirtualPort(id1, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- VirtualPort d3 = new DefaultVirtualPort(id2, networkId, true,
- propertyMap,
- VirtualPort.State.ACTIVE,
- macAddress, tenantId, deviceId,
- fixedIps, bindingHostId,
- allowedAddressPairs,
- securityGroups);
- new EqualsTester().addEqualityGroup(d1, d2).addEqualityGroup(d3)
- .testEquals();
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java
deleted file mode 100644
index 1e33da09..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/FixedIpTest.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * 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.virtualport;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SubnetId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for FixedIp class.
- */
-public class FixedIpTest {
-
- final SubnetId subnetId1 = SubnetId.subnetId("lef11-95w-4er-9c9c");
- final SubnetId subnetId2 = SubnetId.subnetId("lefaa-95w-4er-9c9c");
- final IpAddress ip1 = IpAddress.valueOf("192.168.0.1");
- final IpAddress ip2 = IpAddress.valueOf("192.168.1.1");
-
- /**
- * Checks that the FixedIp class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(FixedIp.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- FixedIp fixedIp1 = FixedIp.fixedIp(subnetId1, ip1);
- FixedIp fixedIp2 = FixedIp.fixedIp(subnetId1, ip1);
- FixedIp fixedIp3 = FixedIp.fixedIp(subnetId2, ip2);
- new EqualsTester().addEqualityGroup(fixedIp1, fixedIp2)
- .addEqualityGroup(fixedIp3).testEquals();
- }
-
- /**
- * Checks the construction of a FixedIp object.
- */
- @Test
- public void testConstruction() {
- FixedIp fixedIp = FixedIp.fixedIp(subnetId1, ip1);
- assertThat(ip1, is(notNullValue()));
- assertThat(ip1, is(fixedIp.ip()));
- assertThat(subnetId1, is(notNullValue()));
- assertThat(subnetId1, is(fixedIp.subnetId()));
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java
deleted file mode 100644
index 8c04e499..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/SecurityGroupTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.virtualport;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.SecurityGroup;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for SecurityGroup class.
- */
-public class SecurityGroupTest {
-
- final SecurityGroup securityGroup1 = SecurityGroup.securityGroup("1");
- final SecurityGroup sameAssecurityGroup = SecurityGroup.securityGroup("1");
- final SecurityGroup securityGroup2 = SecurityGroup.securityGroup("2");
-
- /**
- * Checks that the SecurityGroup class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(SecurityGroup.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(securityGroup1, sameAssecurityGroup)
- .addEqualityGroup(securityGroup2).testEquals();
- }
-
- /**
- * Checks the construction of a SecurityGroup object.
- */
- @Test
- public void testConstruction() {
- final String securityGroupValue = "1";
- final SecurityGroup securityGroup = SecurityGroup.securityGroup(securityGroupValue);
- assertThat(securityGroup, is(notNullValue()));
- assertThat(securityGroup.securityGroup(), is(securityGroupValue));
-
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java b/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java
deleted file mode 100644
index 2d63e91c..00000000
--- a/framework/src/onos/apps/vtn/vtnrsc/src/test/java/org/onosproject/vtnrsc/virtualport/VirtualPortIdTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.virtualport;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.Matchers.notNullValue;
-import static org.onlab.junit.ImmutableClassChecker.assertThatClassIsImmutable;
-
-import org.junit.Test;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-import com.google.common.testing.EqualsTester;
-
-/**
- * Unit tests for VirtualPortId class.
- */
-public class VirtualPortIdTest {
-
- final VirtualPortId virtualPortId1 = VirtualPortId.portId("1");
- final VirtualPortId sameAsVirtualPortId1 = VirtualPortId.portId("1");
- final VirtualPortId virtualPortId2 = VirtualPortId.portId("2");
-
- /**
- * Checks that the VirtualPortId class is immutable.
- */
- @Test
- public void testImmutability() {
- assertThatClassIsImmutable(VirtualPortId.class);
- }
-
- /**
- * Checks the operation of equals().
- */
- @Test
- public void testEquals() {
- new EqualsTester().addEqualityGroup(virtualPortId1, sameAsVirtualPortId1)
- .addEqualityGroup(virtualPortId2).testEquals();
- }
-
- /**
- * Checks the construction of a VirtualPortId object.
- */
- @Test
- public void testConstruction() {
- final String vPortIdValue = "aaa";
- final VirtualPortId virtualPortId = VirtualPortId.portId(vPortIdValue);
- assertThat(virtualPortId, is(notNullValue()));
- assertThat(virtualPortId.portId(), is(vPortIdValue));
-
- }
-}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java
index 7a57c0ab..b0e2f38d 100644
--- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java
+++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FlowClassifierWebResource.java
@@ -15,15 +15,12 @@
*/
package org.onosproject.vtnweb.resources;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static org.onlab.util.Tools.nullIsNotFound;
import static javax.ws.rs.core.Response.Status.NOT_FOUND;
+import static javax.ws.rs.core.Response.Status.OK;
+import static org.onlab.util.Tools.nullIsNotFound;
import java.io.IOException;
import java.io.InputStream;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.UUID;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
@@ -36,13 +33,17 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
+import org.onosproject.rest.AbstractWebResource;
import org.onosproject.vtnrsc.FlowClassifier;
import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.rest.AbstractWebResource;
import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService;
import org.onosproject.vtnweb.web.FlowClassifierCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
@@ -51,73 +52,51 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
@Path("flow_classifiers")
public class FlowClassifierWebResource extends AbstractWebResource {
+ private final Logger log = LoggerFactory.getLogger(FlowClassifierWebResource.class);
+
final FlowClassifierService service = get(FlowClassifierService.class);
- final ObjectNode root = mapper().createObjectNode();
public static final String FLOW_CLASSIFIER_NOT_FOUND = "Flow classifier not found";
/**
- * Get all flow classifiers created. Returns list of all flow classifiers
- * created.
+ * Get all flow classifiers created.
*
* @return 200 OK
*/
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getFlowClassifiers() {
- Iterable<FlowClassifier> flowClassifiers = service.getFlowClassifiers();
+ final Iterable<FlowClassifier> flowClassifiers = service.getFlowClassifiers();
ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("flow_classifiers", new FlowClassifierCodec().encode(flowClassifiers, this));
+ ArrayNode flowClassifierEntry = result.putArray("flow_classifiers");
+ if (flowClassifiers != null) {
+ for (final FlowClassifier flowClassifier : flowClassifiers) {
+ flowClassifierEntry.add(new FlowClassifierCodec().encode(flowClassifier, this));
+ }
+ }
return ok(result.toString()).build();
}
/**
- * Get details of a flow classifier. Returns details of a specified flow
- * classifier id.
+ * Get details of a flow classifier.
*
* @param id flow classifier id
- * @return 200 OK
+ * @return 200 OK , 404 if given identifier does not exist
*/
@GET
@Path("{flow_id}")
@Produces(MediaType.APPLICATION_JSON)
public Response getFlowClassifier(@PathParam("flow_id") String id) {
- if (!service.hasFlowClassifier(FlowClassifierId.of(UUID.fromString(id)))) {
+ if (!service.hasFlowClassifier(FlowClassifierId.of(id))) {
return Response.status(NOT_FOUND).entity(FLOW_CLASSIFIER_NOT_FOUND).build();
}
- FlowClassifier flowClassifier = nullIsNotFound(
- service.getFlowClassifier(FlowClassifierId.of(UUID.fromString(id))),
+ FlowClassifier flowClassifier = nullIsNotFound(service.getFlowClassifier(FlowClassifierId.of(id)),
FLOW_CLASSIFIER_NOT_FOUND);
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("flow_classifier", new FlowClassifierCodec().encode(flowClassifier, this));
- return ok(result.toString()).build();
- }
- /**
- * Creates and stores a new flow classifier.
- *
- * @param flowClassifierId flow classifier identifier
- * @param stream flow classifier from JSON
- * @return status of the request - CREATED if the JSON is correct,
- * BAD_REQUEST if the JSON is invalid
- */
- @POST
- @Path("{flow_id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createFlowClassifier(@PathParam("flow_id") String flowClassifierId, InputStream stream) {
- URI location;
- try {
- ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
-
- FlowClassifier flowClassifier = codec(FlowClassifier.class).decode(jsonTree, this);
- service.createFlowClassifier(flowClassifier);
- location = new URI(flowClassifierId);
- } catch (IOException | URISyntaxException ex) {
- throw new IllegalArgumentException(ex);
- }
- return Response.created(location).build();
+ return ok(result.toString()).build();
}
/**
@@ -125,32 +104,32 @@ public class FlowClassifierWebResource extends AbstractWebResource {
*
* @param stream flow classifier from JSON
* @return status of the request - CREATED if the JSON is correct,
- * BAD_REQUEST if the JSON is invalid
+ * BAD_REQUEST if the JSON is invalid
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
public Response createFlowClassifier(InputStream stream) {
- URI location;
try {
- ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
-
- FlowClassifier flowClassifier = codec(FlowClassifier.class).decode(jsonTree, this);
- service.createFlowClassifier(flowClassifier);
- location = new URI(flowClassifier.flowClassifierId().toString());
- } catch (IOException | URISyntaxException ex) {
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream);
+ JsonNode flow = jsonTree.get("flow_classifier");
+
+ FlowClassifier flowClassifier = new FlowClassifierCodec().decode((ObjectNode) flow, this);
+ Boolean issuccess = nullIsNotFound(service.createFlowClassifier(flowClassifier), FLOW_CLASSIFIER_NOT_FOUND);
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (IOException ex) {
+ log.error("Exception while creating flow classifier {}.", ex.toString());
throw new IllegalArgumentException(ex);
}
- return Response.created(location).build();
}
/**
- * Update details of a flow classifier. Update details of a specified flow
- * classifier id.
+ * Update details of a flow classifier.
*
* @param id flow classifier id
* @param stream InputStream
- * @return 200 OK
+ * @return 200 OK, 404 if given identifier does not exist
*/
@PUT
@Path("{flow_id}")
@@ -158,35 +137,29 @@ public class FlowClassifierWebResource extends AbstractWebResource {
@Consumes(MediaType.APPLICATION_JSON)
public Response updateFlowClassifier(@PathParam("flow_id") String id, final InputStream stream) {
try {
- ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
- FlowClassifier flowClassifier = codec(FlowClassifier.class).decode(jsonTree, this);
+
+ JsonNode jsonTree = mapper().readTree(stream);
+ JsonNode flow = jsonTree.get("flow_classifier");
+ FlowClassifier flowClassifier = new FlowClassifierCodec().decode((ObjectNode) flow, this);
Boolean result = nullIsNotFound(service.updateFlowClassifier(flowClassifier), FLOW_CLASSIFIER_NOT_FOUND);
- if (!result) {
- return Response.status(204).entity(FLOW_CLASSIFIER_NOT_FOUND).build();
- }
- return Response.status(203).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()).build();
+ return Response.status(OK).entity(result.toString()).build();
+ } catch (IOException e) {
+ log.error("Update flow classifier failed because of exception {}.", e.toString());
+ throw new IllegalArgumentException(e);
}
}
/**
- * Delete details of a flow classifier. Delete details of a specified flow
- * classifier id.
+ * Delete details of a flow classifier.
*
* @param id flow classifier id
- * @return 200 OK
- * @throws IOException when input doesn't match.
*/
@Path("{flow_id}")
@DELETE
- public Response deleteFlowClassifier(@PathParam("flow_id") String id) throws IOException {
- try {
- FlowClassifierId flowClassifierId = FlowClassifierId.of(UUID.fromString(id));
- service.removeFlowClassifier(flowClassifierId);
- return Response.status(201).entity("SUCCESS").build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString()).build();
- }
+ public void deleteFlowClassifier(@PathParam("flow_id") String id) {
+ log.debug("Deletes flow classifier by identifier {}.", id);
+ FlowClassifierId flowClassifierId = FlowClassifierId.of(id);
+ Boolean issuccess = nullIsNotFound(service.removeFlowClassifier(flowClassifierId), FLOW_CLASSIFIER_NOT_FOUND);
+
}
}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java
index 8bf459c2..b9012898 100644
--- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java
+++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/PortPairWebResource.java
@@ -42,7 +42,9 @@ import org.onosproject.vtnweb.web.PortPairCodec;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
/**
@@ -67,8 +69,13 @@ public class PortPairWebResource extends AbstractWebResource {
public Response getPortPairs() {
Iterable<PortPair> portPairs = service.getPortPairs();
ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("port_pairs", new PortPairCodec().encode(portPairs, this));
- return ok(result).build();
+ ArrayNode portPairEntry = result.putArray("port_pairs");
+ if (portPairs != null) {
+ for (final PortPair portPair : portPairs) {
+ portPairEntry.add(new PortPairCodec().encode(portPair, this));
+ }
+ }
+ return ok(result.toString()).build();
}
/**
@@ -80,18 +87,15 @@ public class PortPairWebResource extends AbstractWebResource {
@GET
@Path("{pair_id}")
@Produces(MediaType.APPLICATION_JSON)
- public Response getPortPair(@PathParam("portPairId") String id) {
+ public Response getPortPair(@PathParam("pair_id") String id) {
if (!service.exists(PortPairId.of(id))) {
- return Response.status(NOT_FOUND)
- .entity(PORT_PAIR_NOT_FOUND).build();
+ return Response.status(NOT_FOUND).entity(PORT_PAIR_NOT_FOUND).build();
}
- PortPair portPair = nullIsNotFound(service.getPortPair(PortPairId.of(id)),
- PORT_PAIR_NOT_FOUND);
-
+ PortPair portPair = nullIsNotFound(service.getPortPair(PortPairId.of(id)), PORT_PAIR_NOT_FOUND);
ObjectNode result = new ObjectMapper().createObjectNode();
result.set("port_pair", new PortPairCodec().encode(portPair, this));
- return ok(result).build();
+ return ok(result.toString()).build();
}
/**
@@ -106,11 +110,11 @@ public class PortPairWebResource extends AbstractWebResource {
@Produces(MediaType.APPLICATION_JSON)
public Response createPortPair(InputStream stream) {
try {
- ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
-
- PortPair portPair = codec(PortPair.class).decode(jsonTree, this);
- Boolean isSuccess = nullIsNotFound(service.createPortPair(portPair),
- PORT_PAIR_NOT_FOUND);
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream);
+ JsonNode port = jsonTree.get("port_pair");
+ PortPair portPair = new PortPairCodec().decode((ObjectNode) port, this);
+ Boolean isSuccess = nullIsNotFound(service.createPortPair(portPair), PORT_PAIR_NOT_FOUND);
return Response.status(OK).entity(isSuccess.toString()).build();
} catch (IOException e) {
log.error("Exception while creating port pair {}.", e.toString());
@@ -132,8 +136,10 @@ public class PortPairWebResource extends AbstractWebResource {
public Response updatePortPair(@PathParam("pair_id") String id,
final InputStream stream) {
try {
- ObjectNode jsonTree = (ObjectNode) mapper().readTree(stream);
- PortPair portPair = codec(PortPair.class).decode(jsonTree, this);
+ ObjectMapper mapper = new ObjectMapper();
+ ObjectNode jsonTree = (ObjectNode) mapper.readTree(stream);
+ JsonNode port = jsonTree.get("port_pair");
+ PortPair portPair = new PortPairCodec().decode((ObjectNode) port, this);
Boolean isSuccess = nullIsNotFound(service.updatePortPair(portPair), PORT_PAIR_NOT_FOUND);
return Response.status(OK).entity(isSuccess.toString()).build();
} catch (IOException e) {
@@ -152,8 +158,7 @@ public class PortPairWebResource extends AbstractWebResource {
public void deletePortPair(@PathParam("pair_id") String id) {
PortPairId portPairId = PortPairId.of(id);
- Boolean isSuccess = nullIsNotFound(service.removePortPair(portPairId),
- PORT_PAIR_NOT_FOUND);
+ Boolean isSuccess = nullIsNotFound(service.removePortPair(portPairId), PORT_PAIR_NOT_FOUND);
if (!isSuccess) {
log.debug("Port pair identifier {} does not exist", id);
}
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
index 4c17633c..a18ca362 100644
--- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
+++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/web/FlowClassifierCodec.java
@@ -18,16 +18,14 @@ package org.onosproject.vtnweb.web;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.nullIsIllegal;
-import java.util.UUID;
-
import org.onlab.packet.IpPrefix;
import org.onosproject.codec.CodecContext;
import org.onosproject.codec.JsonCodec;
import org.onosproject.vtnrsc.DefaultFlowClassifier;
import org.onosproject.vtnrsc.FlowClassifier;
import org.onosproject.vtnrsc.FlowClassifierId;
-import org.onosproject.vtnrsc.VirtualPortId;
import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.VirtualPortId;
import com.fasterxml.jackson.databind.node.ObjectNode;
@@ -40,7 +38,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
private static final String TENANT_ID = "tenant_id";
private static final String NAME = "name";
private static final String DESCRIPTION = "description";
- private static final String ETHER_TYPE = "etherType";
+ private static final String ETHER_TYPE = "ethertype";
private static final String PROTOCOL = "protocol";
private static final String MIN_SRC_PORT_RANGE = "source_port_range_min";
private static final String MAX_SRC_PORT_RANGE = "source_port_range_max";
@@ -62,7 +60,7 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
String flowClassifierId = nullIsIllegal(json.get(FLOW_CLASSIFIER_ID),
FLOW_CLASSIFIER_ID + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setFlowClassifierId(FlowClassifierId.of(UUID.fromString(flowClassifierId)));
+ resultBuilder.setFlowClassifierId(FlowClassifierId.of(flowClassifierId));
String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setTenantId(TenantId.tenantId(tenantId));
@@ -70,44 +68,46 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
String flowClassiferName = nullIsIllegal(json.get(NAME), NAME + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setName(flowClassiferName);
- String flowClassiferDescription = nullIsIllegal(json.get(DESCRIPTION), DESCRIPTION + MISSING_MEMBER_MESSAGE)
- .asText();
+ String flowClassiferDescription = (json.get(DESCRIPTION)).asText();
resultBuilder.setDescription(flowClassiferDescription);
String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText();
resultBuilder.setEtherType(etherType);
- String protocol = nullIsIllegal(json.get(PROTOCOL), PROTOCOL + MISSING_MEMBER_MESSAGE).asText();
+ String protocol = (json.get(PROTOCOL)).asText();
resultBuilder.setProtocol(protocol);
- int minSrcPortRange = nullIsIllegal(json.get(MIN_SRC_PORT_RANGE), MIN_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE)
- .asInt();
+ int minSrcPortRange = (json.get(MIN_SRC_PORT_RANGE)).asInt();
resultBuilder.setMinSrcPortRange(minSrcPortRange);
- int maxSrcPortRange = nullIsIllegal(json.get(MAX_SRC_PORT_RANGE), MAX_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE)
- .asInt();
+ int maxSrcPortRange = (json.get(MAX_SRC_PORT_RANGE)).asInt();
resultBuilder.setMaxSrcPortRange(maxSrcPortRange);
- int minDstPortRange = nullIsIllegal(json.get(MIN_DST_PORT_RANGE), MIN_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE)
- .asInt();
+ int minDstPortRange = (json.get(MIN_DST_PORT_RANGE)).asInt();
resultBuilder.setMinDstPortRange(minDstPortRange);
- int maxDstPortRange = nullIsIllegal(json.get(MAX_DST_PORT_RANGE), MAX_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE)
- .asInt();
+ int maxDstPortRange = (json.get(MAX_DST_PORT_RANGE)).asInt();
resultBuilder.setMaxDstPortRange(maxDstPortRange);
- String srcIpPrefix = nullIsIllegal(json.get(SRC_IP_PREFIX), SRC_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix));
-
- String dstIpPrefix = nullIsIllegal(json.get(DST_IP_PREFIX), DST_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix));
+ String srcIpPrefix = (json.get(SRC_IP_PREFIX)).asText();
+ if (!srcIpPrefix.isEmpty()) {
+ resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix));
+ }
- String srcPort = nullIsIllegal(json.get(SRC_PORT), SRC_PORT + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setSrcPort(VirtualPortId.portId(srcPort));
+ String dstIpPrefix = (json.get(DST_IP_PREFIX)).asText();
+ if (!dstIpPrefix.isEmpty()) {
+ resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix));
+ }
- String dstPort = nullIsIllegal(json.get(DST_PORT), DST_PORT + MISSING_MEMBER_MESSAGE).asText();
- resultBuilder.setDstPort(VirtualPortId.portId(dstPort));
+ String srcPort = json.get(SRC_PORT) != null ? (json.get(SRC_PORT)).asText() : "";
+ if (!srcPort.isEmpty()) {
+ resultBuilder.setSrcPort(VirtualPortId.portId(srcPort));
+ }
+ String dstPort = json.get(DST_PORT) != null ? (json.get(DST_PORT)).asText() : "";
+ if (!dstPort.isEmpty()) {
+ resultBuilder.setDstPort(VirtualPortId.portId(dstPort));
+ }
return resultBuilder.build();
}
@@ -115,20 +115,20 @@ public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
public ObjectNode encode(FlowClassifier flowClassifier, CodecContext context) {
checkNotNull(flowClassifier, "flowClassifier cannot be null");
ObjectNode result = context.mapper().createObjectNode()
- .put("FLOW_CLASSIFIER_ID", flowClassifier.flowClassifierId().toString())
- .put("TENANT_ID", flowClassifier.tenantId().toString())
- .put("NAME", flowClassifier.name())
- .put("DESCRIPTION", flowClassifier.description())
- .put("ETHER_TYPE", flowClassifier.etherType())
- .put("PROTOCOL", flowClassifier.protocol())
- .put("MIN_SRC_PORT_RANGE", flowClassifier.minSrcPortRange())
- .put("MAX_SRC_PORT_RANGE", flowClassifier.maxSrcPortRange())
- .put("MIN_DST_PORT_RANGE", flowClassifier.minDstPortRange())
- .put("MAX_DST_PORT_RANGE", flowClassifier.maxDstPortRange())
- .put("SRC_IP_PREFIX", flowClassifier.srcIpPrefix().toString())
- .put("DST_IP_PREFIX", flowClassifier.dstIpPrefix().toString())
- .put("SRC_PORT", flowClassifier.srcPort().toString())
- .put("DST_PORT", flowClassifier.dstPort().toString());
+ .put(FLOW_CLASSIFIER_ID, flowClassifier.flowClassifierId().toString())
+ .put(TENANT_ID, flowClassifier.tenantId().toString())
+ .put(NAME, flowClassifier.name())
+ .put(DESCRIPTION, flowClassifier.description())
+ .put(ETHER_TYPE, flowClassifier.etherType())
+ .put(PROTOCOL, flowClassifier.protocol())
+ .put(MIN_SRC_PORT_RANGE, flowClassifier.minSrcPortRange())
+ .put(MAX_SRC_PORT_RANGE, flowClassifier.maxSrcPortRange())
+ .put(MIN_DST_PORT_RANGE, flowClassifier.minDstPortRange())
+ .put(MAX_DST_PORT_RANGE, flowClassifier.maxDstPortRange())
+ .put(SRC_IP_PREFIX, flowClassifier.srcIpPrefix().toString())
+ .put(DST_IP_PREFIX, flowClassifier.dstIpPrefix().toString())
+ .put(SRC_PORT, flowClassifier.srcPort().toString())
+ .put(DST_PORT, flowClassifier.dstPort().toString());
return result;
}
}