summaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps')
-rw-r--r--framework/src/onos/apps/aaa/pom.xml2
-rw-r--r--framework/src/onos/apps/acl/pom.xml6
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java4
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java20
-rw-r--r--framework/src/onos/apps/bgprouter/app.xml1
-rw-r--r--framework/src/onos/apps/bgprouter/features.xml1
-rw-r--r--framework/src/onos/apps/bgprouter/pom.xml8
-rw-r--r--framework/src/onos/apps/cip/pom.xml2
-rw-r--r--framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java21
-rw-r--r--framework/src/onos/apps/cordfabric/pom.xml2
-rw-r--r--framework/src/onos/apps/cordvtn/pom.xml54
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java36
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java311
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java101
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java57
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java97
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java145
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java74
-rw-r--r--framework/src/onos/apps/demo/cord-gui/pom.xml2
-rw-r--r--framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java15
-rw-r--r--framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh2
-rw-r--r--framework/src/onos/apps/demo/cord-gui/src/scripts/run.me2
-rw-r--r--framework/src/onos/apps/dhcp/pom.xml2
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java3
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java23
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java19
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java6
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java20
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java148
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java214
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java19
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java186
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java20
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java13
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java20
-rw-r--r--framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html8
-rw-r--r--framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java5
-rw-r--r--framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java25
-rw-r--r--framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json4
-rw-r--r--framework/src/onos/apps/flowanalyzer/pom.xml2
-rw-r--r--framework/src/onos/apps/fwd/pom.xml2
-rw-r--r--framework/src/onos/apps/metrics/pom.xml2
-rw-r--r--framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java2
-rw-r--r--framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java2
-rw-r--r--framework/src/onos/apps/mobility/pom.xml2
-rw-r--r--framework/src/onos/apps/olt/pom.xml2
-rw-r--r--framework/src/onos/apps/optical/pom.xml2
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java4
-rw-r--r--framework/src/onos/apps/pcep-api/pom.xml37
-rw-r--r--framework/src/onos/apps/pom.xml6
-rw-r--r--framework/src/onos/apps/proxyarp/pom.xml2
-rw-r--r--framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java6
-rw-r--r--framework/src/onos/apps/reactive-routing/pom.xml2
-rw-r--r--framework/src/onos/apps/routing-api/pom.xml2
-rw-r--r--framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java13
-rw-r--r--framework/src/onos/apps/routing/pom.xml2
-rw-r--r--framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java27
-rw-r--r--framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java14
-rw-r--r--framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java7
-rw-r--r--framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java22
-rw-r--r--framework/src/onos/apps/sdnip/pom.xml8
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java2
-rw-r--r--framework/src/onos/apps/segmentrouting/pom.xml2
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java25
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java26
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java4
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java2
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java19
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java15
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java29
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java15
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java17
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java23
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java6
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java16
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java8
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java6
-rw-r--r--framework/src/onos/apps/test/demo/pom.xml2
-rw-r--r--framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java2
-rw-r--r--framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java9
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/pom.xml4
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java4
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java2
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java4
-rw-r--r--framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java2
-rw-r--r--framework/src/onos/apps/test/election/pom.xml2
-rw-r--r--framework/src/onos/apps/test/intent-perf/pom.xml2
-rw-r--r--framework/src/onos/apps/test/messaging-perf/pom.xml2
-rw-r--r--framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java15
-rw-r--r--framework/src/onos/apps/test/pom.xml2
-rw-r--r--framework/src/onos/apps/virtualbng/pom.xml2
-rw-r--r--framework/src/onos/apps/vtn/pom.xml26
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java46
-rw-r--r--framework/src/onos/apps/vtnrsc/pom.xml17
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java76
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java188
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java129
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java162
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java158
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java366
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java320
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java458
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java186
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java78
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java156
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java154
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java154
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java258
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java152
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java154
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java260
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java152
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java312
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java140
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java2
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java144
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java362
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java160
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java334
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java144
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java200
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java444
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java80
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java80
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java80
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java80
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java78
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java106
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java94
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java114
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnweb/pom.xml150
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java730
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java743
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java820
-rw-r--r--framework/src/onos/apps/xos-integration/pom.xml2
148 files changed, 6464 insertions, 4980 deletions
diff --git a/framework/src/onos/apps/aaa/pom.xml b/framework/src/onos/apps/aaa/pom.xml
index 6f850750..78fd4a62 100644
--- a/framework/src/onos/apps/aaa/pom.xml
+++ b/framework/src/onos/apps/aaa/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/acl/pom.xml b/framework/src/onos/apps/acl/pom.xml
index 20f784fc..54dee432 100644
--- a/framework/src/onos/apps/acl/pom.xml
+++ b/framework/src/onos/apps/acl/pom.xml
@@ -24,19 +24,19 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>onos-app-acl</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<packaging>bundle</packaging>
<description>ONOS ACL application</description>
<url>http://onosproject.org</url>
<properties>
- <onos.version>1.3.0-SNAPSHOT</onos.version>
+ <onos.version>1.4.0-SNAPSHOT</onos.version>
<onos.app.name>org.onosproject.acl</onos.app.name>
<onos.app.origin>DLUT</onos.app.origin>
<web.context>/onos/acl</web.context>
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java
index 6d909a97..5c8a93cb 100644
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java
+++ b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java
@@ -234,7 +234,7 @@ public class DistributedAclStore extends AbstractStore implements AclStore {
ruleToDevice.computeIf(ruleId,
deviceIdSet -> (deviceIdSet == null || !deviceIdSet.contains(deviceId)),
(id, deviceIdSet) -> {
- Set<DeviceId> newSet = new HashSet<DeviceId>();
+ Set<DeviceId> newSet = new HashSet<>();
if (deviceIdSet != null) {
newSet.addAll(deviceIdSet);
}
@@ -248,4 +248,4 @@ public class DistributedAclStore extends AbstractStore implements AclStore {
ruleToDevice.remove(ruleId);
}
-} \ No newline at end of file
+}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java
new file mode 100644
index 00000000..e9aa1448
--- /dev/null
+++ b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * ACL application implementation.
+ */
+package org.onos.acl.impl;
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java
new file mode 100644
index 00000000..fa4131ee
--- /dev/null
+++ b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * ACL application.
+ */
+package org.onos.acl;
diff --git a/framework/src/onos/apps/bgprouter/app.xml b/framework/src/onos/apps/bgprouter/app.xml
index c85e469a..2fc47be9 100644
--- a/framework/src/onos/apps/bgprouter/app.xml
+++ b/framework/src/onos/apps/bgprouter/app.xml
@@ -22,5 +22,4 @@
<artifact>mvn:${project.groupId}/onos-app-routing-api/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-routing/${project.version}</artifact>
<artifact>mvn:${project.groupId}/onos-app-proxyarp/${project.version}</artifact>
- <artifact>mvn:${project.groupId}/onos-app-config/${project.version}</artifact>
</app>
diff --git a/framework/src/onos/apps/bgprouter/features.xml b/framework/src/onos/apps/bgprouter/features.xml
index 3457321c..c91a7f10 100644
--- a/framework/src/onos/apps/bgprouter/features.xml
+++ b/framework/src/onos/apps/bgprouter/features.xml
@@ -20,7 +20,6 @@
description="${project.description}">
<feature>onos-api</feature>
<bundle>mvn:${project.groupId}/onos-app-routing-api/${project.version}</bundle>
- <bundle>mvn:${project.groupId}/onos-app-config/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-proxyarp/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-bgprouter/${project.version}</bundle>
<bundle>mvn:${project.groupId}/onos-app-routing/${project.version}</bundle>
diff --git a/framework/src/onos/apps/bgprouter/pom.xml b/framework/src/onos/apps/bgprouter/pom.xml
index d3f6f522..decdf5c2 100644
--- a/framework/src/onos/apps/bgprouter/pom.xml
+++ b/framework/src/onos/apps/bgprouter/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -60,12 +60,6 @@
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onos-app-config</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
- <groupId>org.onosproject</groupId>
<artifactId>onos-app-proxyarp</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/framework/src/onos/apps/cip/pom.xml b/framework/src/onos/apps/cip/pom.xml
index a3645931..77cfe150 100644
--- a/framework/src/onos/apps/cip/pom.xml
+++ b/framework/src/onos/apps/cip/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java b/framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java
new file mode 100644
index 00000000..1d358eb0
--- /dev/null
+++ b/framework/src/onos/apps/cip/src/main/java/org/onosproject/cip/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+/**
+ * Cluster IP Manager, which is responsible for managing the cluster IP
+ * address alias.
+ */
+package org.onosproject.cip;
diff --git a/framework/src/onos/apps/cordfabric/pom.xml b/framework/src/onos/apps/cordfabric/pom.xml
index f5388553..a10db440 100644
--- a/framework/src/onos/apps/cordfabric/pom.xml
+++ b/framework/src/onos/apps/cordfabric/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/framework/src/onos/apps/cordvtn/pom.xml b/framework/src/onos/apps/cordvtn/pom.xml
new file mode 100644
index 00000000..a019bec2
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-app-cordvtn</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Virtual tenant network service for CORD</description>
+
+ <properties>
+ <onos.app.name>org.onosproject.cordvtn</onos.app.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java
new file mode 100644
index 00000000..af738230
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/ConnectionHandler.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+/**
+ * Entity capable of handling a subject connected and disconnected situation.
+ */
+public interface ConnectionHandler<T> {
+
+ /**
+ * Processes the connected subject.
+ *
+ * @param subject subject
+ */
+ void connected(T subject);
+
+ /**
+ * Processes the disconnected subject.
+ *
+ * @param subject subject.
+ */
+ void disconnected(T subject);
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java
new file mode 100644
index 00000000..072254de
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java
@@ -0,0 +1,311 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+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.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onlab.util.KryoNamespace;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.LeadershipEvent;
+import org.onosproject.cluster.LeadershipEventListener;
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Host;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigRegistry;
+import org.onosproject.net.config.NetworkConfigService;
+import org.onosproject.net.config.basics.SubjectFactories;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+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.LogicalClockService;
+import org.onosproject.store.service.StorageService;
+import org.slf4j.Logger;
+
+import java.util.List;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.stream.Collectors;
+
+import static org.onlab.util.Tools.groupedThreads;
+import static org.onosproject.cordvtn.OvsdbNode.State.INIT;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * CORD VTN Application that provisions overlay virtual tenant networks.
+ */
+@Component(immediate = true)
+@Service
+public class CordVtn implements CordVtnService {
+
+ protected final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LogicalClockService clockService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LeadershipService leadershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigService configService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected NetworkConfigRegistry configRegistry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ private static final int DEFAULT_NUM_THREADS = 1;
+ private static final KryoNamespace.Builder NODE_SERIALIZER = KryoNamespace.newBuilder()
+ .register(KryoNamespaces.API)
+ .register(OvsdbNode.class);
+
+ private final ExecutorService eventExecutor = Executors.newFixedThreadPool(
+ DEFAULT_NUM_THREADS, groupedThreads("onos/cordvtn", "event-handler"));
+
+ private final LeadershipEventListener leadershipListener = new InternalLeadershipListener();
+ private final DeviceListener deviceListener = new InternalDeviceListener();
+ private final HostListener hostListener = new InternalHostListener();
+ private final NodeHandler nodeHandler = new NodeHandler();
+ private final BridgeHandler bridgeHandler = new BridgeHandler();
+ private final VirtualMachineHandler vmHandler = new VirtualMachineHandler();
+
+ private final ConfigFactory configFactory =
+ new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, CordVtnConfig.class, "cordvtn") {
+ @Override
+ public CordVtnConfig createConfig() {
+ return new CordVtnConfig();
+ }
+ };
+
+ private ApplicationId appId;
+ private NodeId local;
+ private EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore;
+ private NodeConnectionManager nodeConnectionManager;
+
+ @Activate
+ protected void activate() {
+ appId = coreService.registerApplication("org.onosproject.cordvtn");
+
+ local = clusterService.getLocalNode().id();
+ nodeStore = storageService.<DeviceId, OvsdbNode>eventuallyConsistentMapBuilder()
+ .withName("cordvtn-nodestore")
+ .withSerializer(NODE_SERIALIZER)
+ .withTimestampProvider((k, v) -> clockService.getTimestamp())
+ .build();
+ configRegistry.registerConfigFactory(configFactory);
+
+ deviceService.addListener(deviceListener);
+ hostService.addListener(hostListener);
+ leadershipService.addListener(leadershipListener);
+ leadershipService.runForLeadership(appId.name());
+ nodeConnectionManager = new NodeConnectionManager(appId, local, nodeStore,
+ mastershipService, leadershipService);
+ nodeConnectionManager.start();
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ nodeConnectionManager.stop();
+ leadershipService.removeListener(leadershipListener);
+ leadershipService.withdraw(appId.name());
+ deviceService.removeListener(deviceListener);
+ hostService.removeListener(hostListener);
+ eventExecutor.shutdown();
+ nodeStore.destroy();
+ configRegistry.unregisterConfigFactory(configFactory);
+ log.info("Stopped");
+ }
+
+ @Override
+ public void addNode(String hostname, IpAddress ip, TpPort port) {
+ DefaultOvsdbNode node = new DefaultOvsdbNode(hostname, ip, port, DeviceId.NONE, INIT);
+
+ if (nodeStore.containsKey(node.deviceId())) {
+ log.warn("Node {} with ovsdb-server {}:{} already exists", hostname, ip, port);
+ return;
+ }
+ nodeStore.put(node.deviceId(), node);
+ log.info("New node {} with ovsdb-server {}:{} has been added", hostname, ip, port);
+ }
+
+ @Override
+ public void deleteNode(IpAddress ip, TpPort port) {
+ DeviceId deviceId = DeviceId.deviceId("ovsdb:" + ip + ":" + port);
+ OvsdbNode node = nodeStore.get(deviceId);
+
+ if (node == null) {
+ log.warn("Node with ovsdb-server on {}:{} does not exist", ip, port);
+ return;
+ }
+ nodeConnectionManager.disconnectNode(node);
+ nodeStore.remove(node.deviceId());
+ }
+
+ @Override
+ public int getNodeCount() {
+ return nodeStore.size();
+ }
+
+ @Override
+ public List<OvsdbNode> getNodes() {
+ return nodeStore.values()
+ .stream()
+ .collect(Collectors.toList());
+ }
+
+ private void initialSetup() {
+ // Read ovsdb nodes from network config
+ CordVtnConfig config = configService.getConfig(appId, CordVtnConfig.class);
+ if (config == null) {
+ log.warn("No configuration found");
+ return;
+ }
+ config.ovsdbNodes().forEach(
+ node -> addNode(node.hostname(), node.ip(), node.port()));
+ }
+
+ private synchronized void processLeadershipChange(NodeId leader) {
+ // Only the leader performs the initial setup
+ if (leader == null || !leader.equals(local)) {
+ return;
+ }
+ initialSetup();
+ }
+
+ private class InternalLeadershipListener implements LeadershipEventListener {
+
+ @Override
+ public void event(LeadershipEvent event) {
+ if (event.subject().topic().equals(appId.name())) {
+ processLeadershipChange(event.subject().leader());
+ }
+ }
+ }
+
+ private class InternalDeviceListener implements DeviceListener {
+
+ @Override
+ public void event(DeviceEvent event) {
+ Device device = event.subject();
+ ConnectionHandler handler =
+ (device.type() == Device.Type.CONTROLLER ? nodeHandler : bridgeHandler);
+
+ switch (event.type()) {
+ case DEVICE_ADDED:
+ eventExecutor.submit(() -> handler.connected(device));
+ break;
+ case DEVICE_AVAILABILITY_CHANGED:
+ eventExecutor.submit(() -> handler.disconnected(device));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private class InternalHostListener implements HostListener {
+
+ @Override
+ public void event(HostEvent event) {
+ Host vm = event.subject();
+
+ switch (event.type()) {
+ case HOST_ADDED:
+ eventExecutor.submit(() -> vmHandler.connected(vm));
+ break;
+ case HOST_REMOVED:
+ eventExecutor.submit(() -> vmHandler.disconnected(vm));
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ private class NodeHandler implements ConnectionHandler<Device> {
+
+ @Override
+ public void connected(Device device) {
+ // create bridge and set bridgeId
+ // set node state connected
+ }
+
+ @Override
+ public void disconnected(Device device) {
+ // set node state disconnected if the node exists
+ // which means that the node is not deleted explicitly
+ }
+ }
+
+ private class BridgeHandler implements ConnectionHandler<Device> {
+
+ @Override
+ public void connected(Device device) {
+ // create vxlan port
+ }
+
+ @Override
+ public void disconnected(Device device) {
+
+ }
+ }
+
+ private class VirtualMachineHandler implements ConnectionHandler<Host> {
+
+ @Override
+ public void connected(Host host) {
+ // install flow rules for this vm
+ }
+
+ @Override
+ public void disconnected(Host host) {
+ // uninstall flow rules associated with this vm
+ }
+ }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java
new file mode 100644
index 00000000..c2c37aba
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.google.common.collect.Sets;
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.config.Config;
+
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Configuration object for CORD VTN service.
+ */
+public class CordVtnConfig extends Config<ApplicationId> {
+
+ public static final String OVSDB_NODES = "ovsdbNodes";
+ public static final String HOSTNAME = "hostname";
+ public static final String IP = "ip";
+ public static final String PORT = "port";
+
+ /**
+ * Returns the set of ovsdb nodes read from network config.
+ *
+ * @return set of OvsdbNodeConfig or null
+ */
+ public Set<OvsdbNodeConfig> ovsdbNodes() {
+ Set<OvsdbNodeConfig> ovsdbNodes = Sets.newHashSet();
+
+ JsonNode nodes = object.get(OVSDB_NODES);
+ if (nodes == null) {
+ return null;
+ }
+ nodes.forEach(jsonNode -> ovsdbNodes.add(new OvsdbNodeConfig(
+ jsonNode.path(HOSTNAME).asText(),
+ IpAddress.valueOf(jsonNode.path(IP).asText()),
+ TpPort.tpPort(jsonNode.path(PORT).asInt()))));
+
+ return ovsdbNodes;
+ }
+
+ /**
+ * Configuration for an OVSDB node.
+ */
+ public static class OvsdbNodeConfig {
+
+ private final String hostname;
+ private final IpAddress ip;
+ private final TpPort port;
+
+ public OvsdbNodeConfig(String hostname, IpAddress ip, TpPort port) {
+ this.hostname = checkNotNull(hostname);
+ this.ip = checkNotNull(ip);
+ this.port = checkNotNull(port);
+ }
+
+ /**
+ * Returns hostname of the node.
+ *
+ * @return hostname
+ */
+ public String hostname() {
+ return this.hostname;
+ }
+
+ /**
+ * Returns ip address to access ovsdb-server of the node.
+ *
+ * @return ip address
+ */
+ public IpAddress ip() {
+ return this.ip;
+ }
+
+ /**
+ * Returns port number to access ovsdb-server of the node.
+ *
+ * @return port number
+ */
+ public TpPort port() {
+ return this.port;
+ }
+ }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java
new file mode 100644
index 00000000..d26a10aa
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+
+import java.util.List;
+
+/**
+ * Service for provisioning overlay virtual networks on compute nodes.
+ */
+public interface CordVtnService {
+ /**
+ * Adds a new node to the service.
+ *
+ * @param hostname hostname of the node
+ * @param ip ip address to access the ovsdb server running on the node
+ * @param port port number to access the ovsdb server running on the node
+ */
+ void addNode(String hostname, IpAddress ip, TpPort port);
+
+ /**
+ * Deletes the node from the service.
+ *
+ * @param ip ip address to access the ovsdb server running on the node
+ * @param port port number to access the ovsdb server running on the node
+ */
+ void deleteNode(IpAddress ip, TpPort port);
+
+ /**
+ * Returns the number of the nodes known to the service.
+ *
+ * @return number of nodes
+ */
+ int getNodeCount();
+
+ /**
+ * Returns all nodes known to the service.
+ *
+ * @return list of nodes
+ */
+ List<OvsdbNode> getNodes();
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java
new file mode 100644
index 00000000..b8cdbe94
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.net.DeviceId;
+
+import java.util.Objects;
+
+/**
+ * OvsdbNode implementation.
+ */
+public class DefaultOvsdbNode implements OvsdbNode {
+
+ private final String hostname;
+ private final IpAddress ip;
+ private final TpPort port;
+ private final DeviceId deviceId;
+ private final DeviceId bridgeId;
+ private final State state;
+
+ public DefaultOvsdbNode(String hostname, IpAddress ip, TpPort port,
+ DeviceId bridgeId, State state) {
+ this.hostname = hostname;
+ this.ip = ip;
+ this.port = port;
+ this.deviceId = DeviceId.deviceId(
+ "ovsdb:" + ip.toString() + ":" + port.toString());
+ this.bridgeId = bridgeId;
+ this.state = state;
+ }
+
+ @Override
+ public IpAddress ip() {
+ return this.ip;
+ }
+
+ @Override
+ public TpPort port() {
+ return this.port;
+ }
+
+ @Override
+ public String hostname() {
+ return this.hostname;
+ }
+
+ @Override
+ public State state() {
+ return this.state;
+ }
+
+ @Override
+ public DeviceId deviceId() {
+ return this.deviceId;
+ }
+
+ @Override
+ public DeviceId bridgeId() {
+ return this.bridgeId;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (o instanceof DefaultOvsdbNode) {
+ DefaultOvsdbNode that = (DefaultOvsdbNode) o;
+ // We compare the ip and port only.
+ if (this.ip.equals(that.ip) && this.port.equals(that.port)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ip, port);
+ }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java
new file mode 100644
index 00000000..0b7029ef
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+import org.onosproject.cluster.LeadershipService;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.store.service.EventuallyConsistentMap;
+import org.slf4j.Logger;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+
+import static org.onlab.util.Tools.groupedThreads;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Node connection manager.
+ */
+public class NodeConnectionManager {
+ protected final Logger log = getLogger(getClass());
+
+ private final ApplicationId appId;
+ private final NodeId localId;
+ private final EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore;
+ private final MastershipService mastershipService;
+ private final LeadershipService leadershipService;
+
+ private static final int DELAY_SEC = 5;
+ private ScheduledExecutorService connectionExecutor;
+
+ /**
+ * Creates a new NodeConnectionManager.
+ *
+ * @param localId local id
+ * @param nodeStore node store
+ * @param mastershipService mastership service
+ */
+ public NodeConnectionManager(ApplicationId appId, NodeId localId,
+ EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore,
+ MastershipService mastershipService,
+ LeadershipService leadershipService) {
+ this.appId = appId;
+ this.localId = localId;
+ this.nodeStore = nodeStore;
+ this.mastershipService = mastershipService;
+ this.leadershipService = leadershipService;
+ }
+
+ /**
+ * Starts the node connection manager.
+ */
+ public void start() {
+ connectionExecutor = Executors.newSingleThreadScheduledExecutor(
+ groupedThreads("onos/cordvtn", "connection-executor"));
+ connectionExecutor.scheduleWithFixedDelay(() -> nodeStore.values()
+ .stream()
+ .filter(node -> localId.equals(getMaster(node)))
+ .forEach(node -> connectNode(node)), 0, DELAY_SEC, TimeUnit.SECONDS);
+ }
+
+ /**
+ * Stops the node connection manager.
+ */
+ public void stop() {
+ connectionExecutor.shutdown();
+ }
+
+ /**
+ * Adds a new node to the system.
+ *
+ * @param ovsdbNode ovsdb node
+ */
+ public void connectNode(OvsdbNode ovsdbNode) {
+ switch (ovsdbNode.state()) {
+ case INIT:
+ case DISCONNECTED:
+ // TODO: set the node to passive mode
+ case READY:
+ // TODO: initiate connection
+ break;
+ case CONNECTED:
+ break;
+ default:
+ }
+ }
+
+ /**
+ * Deletes the ovsdb node.
+ *
+ * @param ovsdbNode ovsdb node
+ */
+ public void disconnectNode(OvsdbNode ovsdbNode) {
+ switch (ovsdbNode.state()) {
+ case CONNECTED:
+ // TODO: disconnect
+ break;
+ case INIT:
+ case READY:
+ case DISCONNECTED:
+ break;
+ default:
+ }
+ }
+
+ private NodeId getMaster(OvsdbNode ovsdbNode) {
+ // Return the master of the bridge(switch) if it exist or
+ // return the current leader
+ if (ovsdbNode.bridgeId() == DeviceId.NONE) {
+ return leadershipService.getLeader(this.appId.name());
+ } else {
+ return mastershipService.getMasterFor(ovsdbNode.bridgeId());
+ }
+ }
+
+ private void setPassiveMode(OvsdbNode ovsdbNode) {
+ // TODO: need ovsdb client implementation first
+ // TODO: set the remove ovsdb server passive mode
+ // TODO: set the node state READY if it succeed
+ }
+
+ private void connect(OvsdbNode ovsdbNode) {
+ // TODO: need ovsdb client implementation first
+ }
+
+ private void disconnect(OvsdbNode ovsdbNode) {
+ // TODO: need ovsdb client implementation first
+ }
+}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java
new file mode 100644
index 00000000..bb2a0b7d
--- /dev/null
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2014-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.cordvtn;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.TpPort;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Representation of a node with ovsdb server.
+ */
+public interface OvsdbNode {
+ /**
+ * State of the ovsdb node.
+ */
+ enum State {
+ INIT, READY, CONNECTED, DISCONNECTED
+ }
+
+ /**
+ * Returns the IP address of ovsdb server.
+ *
+ * @return ip address
+ */
+ IpAddress ip();
+
+ /**
+ * Returns the port number of ovsdb server.
+ *
+ * @return port number
+ */
+ TpPort port();
+
+ /**
+ * Returns the hostname of the node.
+ *
+ * @return hostname
+ */
+ String hostname();
+
+ /**
+ * Returns the state of the node.
+ *
+ * @return state of the node
+ */
+ State state();
+
+ /**
+ * Returns the device ID of the node.
+ *
+ * @return device id
+ */
+ DeviceId deviceId();
+
+ /**
+ * Returns the device ID of the bridge associated with this node.
+ *
+ * @return device id
+ */
+ DeviceId bridgeId();
+}
diff --git a/framework/src/onos/apps/demo/cord-gui/pom.xml b/framework/src/onos/apps/demo/cord-gui/pom.xml
index eeda585a..16ed5d95 100644
--- a/framework/src/onos/apps/demo/cord-gui/pom.xml
+++ b/framework/src/onos/apps/demo/cord-gui/pom.xml
@@ -27,7 +27,7 @@
</parent>
<artifactId>cord-gui</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<packaging>war</packaging>
<description>Demo CORD Subscriber Web GUI</description>
diff --git a/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java b/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java
index a91dbfbf..dffabceb 100644
--- a/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java
+++ b/framework/src/onos/apps/demo/cord-gui/src/main/java/org/onosproject/cord/gui/model/XosFunctionFactory.java
@@ -1,3 +1,18 @@
+/*
+ * 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.cord.gui.model;
import com.fasterxml.jackson.databind.node.ArrayNode;
diff --git a/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh b/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh
index e7ad3322..d5a75289 100644
--- a/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh
+++ b/framework/src/onos/apps/demo/cord-gui/src/scripts/pullwar.sh
@@ -1 +1 @@
-cp $ONOS_ROOT/apps/demo/cord-gui/target/cord-gui-1.3.0-SNAPSHOT.war .
+cp $ONOS_ROOT/apps/demo/cord-gui/target/cord-gui-1.4.0-SNAPSHOT.war .
diff --git a/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me b/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me
index db76fb6d..496b18e4 100644
--- a/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me
+++ b/framework/src/onos/apps/demo/cord-gui/src/scripts/run.me
@@ -4,7 +4,7 @@
export LISTENPORT=8080
export JETTY="-jar jetty-runner.jar"
-export CORD=./cord-gui-1.3.0-SNAPSHOT.war
+export CORD=./cord-gui-1.4.0-SNAPSHOT.war
export LOGDBG=-Dorg.onosproject.cord.gui.LEVEL=DEBUG
export DEBUG="-Xdebug -Xrunjdwp:transport=dt_socket,address=5005,server=y,suspend=n"
export LOG=cord.log
diff --git a/framework/src/onos/apps/dhcp/pom.xml b/framework/src/onos/apps/dhcp/pom.xml
index 13298163..0daa4f7b 100644
--- a/framework/src/onos/apps/dhcp/pom.xml
+++ b/framework/src/onos/apps/dhcp/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java
index 20e1c614..7c2127f9 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpService.java
@@ -17,6 +17,7 @@ package org.onosproject.dhcp;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
+import org.onosproject.net.HostId;
import java.util.Map;
@@ -30,7 +31,7 @@ public interface DhcpService {
*
* @return collection of mappings.
*/
- Map<MacAddress, IpAssignment> listMapping();
+ Map<HostId, IpAssignment> listMapping();
/**
* Returns the default lease time granted by the DHCP Server.
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java
index 4e2d67d6..c9fade9e 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java
@@ -17,6 +17,7 @@ package org.onosproject.dhcp;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
+import org.onosproject.net.HostId;
import java.util.Map;
@@ -36,21 +37,21 @@ public interface DhcpStore {
/**
* Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
*
- * @param macID Mac ID of the client requesting an IP
+ * @param hostId Host ID of the client requesting an IP
* @param requestedIP requested IP address
* @return IP address assigned to the Mac ID
*/
- Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP);
+ Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP);
/**
* Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
*
- * @param macID Mac Id of the client requesting an IP
+ * @param hostId Host Id of the client requesting an IP
* @param ipAddr IP Address being requested
* @param leaseTime Lease time offered by the server for this mapping
* @return returns true if the assignment was successful, false otherwise
*/
- boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime);
+ boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime);
/**
* Sets the default time for which suggested IP mappings are valid.
@@ -60,25 +61,25 @@ public interface DhcpStore {
void setDefaultTimeoutForPurge(int timeInSeconds);
/**
- * Sets the delay after which the dhcp server will purge expired entries.
+ * Releases the IP assigned to a Mac ID into the free pool.
*
- * @param timeInSeconds default time
+ * @param hostId the host ID for which the mapping needs to be changed
*/
- void setTimerDelay(int timeInSeconds);
+ void releaseIP(HostId hostId);
/**
- * Releases the IP assigned to a Mac ID into the free pool.
+ * Returns a collection of all the MacAddress to IPAddress mapping assigned to the hosts.
*
- * @param macID the macID for which the mapping needs to be changed
+ * @return the collection of the mappings
*/
- void releaseIP(MacAddress macID);
+ Map<HostId, IpAssignment> listAssignedMapping();
/**
* Returns a collection of all the MacAddress to IPAddress mapping.
*
* @return the collection of the mappings
*/
- Map<MacAddress, IpAssignment> listMapping();
+ Map<HostId, IpAssignment> listAllMapping();
/**
* Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java
index c8bd1906..9b3aa686 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/IpAssignment.java
@@ -49,7 +49,7 @@ public final class IpAssignment {
/**
* IP mapping is no longer active.
*/
- Option_Expired;
+ Option_Expired
}
/**
@@ -100,10 +100,19 @@ public final class IpAssignment {
/**
* Returns the lease period of the IP assignment.
*
- * @return the lease period
+ * @return the lease period in seconds
*/
public int leasePeriod() {
- return (int) this.leasePeriod / 1000;
+ return (int) this.leasePeriod;
+ }
+
+ /**
+ * Returns the lease period of the IP assignment.
+ *
+ * @return the lease period in milliseconds
+ */
+ public int leasePeriodMs() {
+ return (int) this.leasePeriod * 1000;
}
@Override
@@ -155,7 +164,7 @@ public final class IpAssignment {
private Builder(IpAssignment ipAssignment) {
ipAddress = ipAssignment.ipAddress();
timeStamp = ipAssignment.timestamp();
- leasePeriod = ipAssignment.leasePeriod() * 1000;
+ leasePeriod = ipAssignment.leasePeriod();
assignmentStatus = ipAssignment.assignmentStatus();
}
@@ -178,7 +187,7 @@ public final class IpAssignment {
}
public Builder leasePeriod(int leasePeriodinSeconds) {
- leasePeriod = leasePeriodinSeconds * 1000;
+ leasePeriod = leasePeriodinSeconds;
return this;
}
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java
index fc470ce3..209ba683 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/DhcpListAllMappings.java
@@ -16,10 +16,10 @@
package org.onosproject.dhcp.cli;
import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.MacAddress;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.dhcp.DhcpService;
import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
import java.util.Map;
@@ -35,9 +35,9 @@ public class DhcpListAllMappings extends AbstractShellCommand {
protected void execute() {
DhcpService dhcpService = AbstractShellCommand.get(DhcpService.class);
- Map<MacAddress, IpAssignment> allocationMap = dhcpService.listMapping();
+ Map<HostId, IpAssignment> allocationMap = dhcpService.listMapping();
- for (Map.Entry<MacAddress, IpAssignment> entry : allocationMap.entrySet()) {
+ for (Map.Entry<HostId, IpAssignment> entry : allocationMap.entrySet()) {
print(DHCP_MAPPING_FORMAT, entry.getKey().toString(), entry.getValue().ipAddress().toString());
}
}
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java
new file mode 100644
index 00000000..f8780195
--- /dev/null
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/cli/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * CLI implementation for sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp.cli; \ No newline at end of file
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java
index f8d5e63b..4353d623 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpConfig.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.dhcp.impl;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.MacAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.net.config.Config;
import org.onosproject.net.config.basics.BasicElementConfig;
@@ -34,14 +36,21 @@ public class DhcpConfig extends Config<ApplicationId> {
public static final String LEASE_TIME = "lease";
public static final String RENEW_TIME = "renew";
public static final String REBIND_TIME = "rebind";
+ public static final String TIMER_DELAY = "delay";
+ public static final String DEFAULT_TIMEOUT = "timeout";
+ public static final String START_IP = "startip";
+ public static final String END_IP = "endip";
+
+ public static final int DEFAULT = -1;
/**
* Returns the dhcp server ip.
*
* @return ip address or null if not set
*/
- public String ip() {
- return get(MY_IP, null);
+ public Ip4Address ip() {
+ String ip = get(MY_IP, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
}
/**
@@ -59,8 +68,9 @@ public class DhcpConfig extends Config<ApplicationId> {
*
* @return server mac or null if not set
*/
- public String mac() {
- return get(MY_MAC, null);
+ public MacAddress mac() {
+ String mac = get(MY_MAC, null);
+ return mac != null ? MacAddress.valueOf(mac) : null;
}
/**
@@ -78,8 +88,9 @@ public class DhcpConfig extends Config<ApplicationId> {
*
* @return subnet mask or null if not set
*/
- public String subnetMask() {
- return get(SUBNET_MASK, null);
+ public Ip4Address subnetMask() {
+ String ip = get(SUBNET_MASK, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
}
/**
@@ -97,8 +108,9 @@ public class DhcpConfig extends Config<ApplicationId> {
*
* @return broadcast address or null if not set
*/
- public String broadcastAddress() {
- return get(BROADCAST_ADDRESS, null);
+ public Ip4Address broadcastAddress() {
+ String ip = get(BROADCAST_ADDRESS, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
}
/**
@@ -114,10 +126,10 @@ public class DhcpConfig extends Config<ApplicationId> {
/**
* Returns the Time To Live for the reply packets.
*
- * @return ttl or null if not set
+ * @return ttl or -1 if not set
*/
- public String ttl() {
- return get(TTL, null);
+ public int ttl() {
+ return get(TTL, DEFAULT);
}
/**
@@ -126,17 +138,17 @@ public class DhcpConfig extends Config<ApplicationId> {
* @param ttl new ttl; null to clear
* @return self
*/
- public BasicElementConfig ttl(String ttl) {
+ public BasicElementConfig ttl(int ttl) {
return (BasicElementConfig) setOrClear(TTL, ttl);
}
/**
* Returns the Lease Time offered by the DHCP Server.
*
- * @return lease time or null if not set
+ * @return lease time or -1 if not set
*/
- public String leaseTime() {
- return get(LEASE_TIME, null);
+ public int leaseTime() {
+ return get(LEASE_TIME, DEFAULT);
}
/**
@@ -145,17 +157,17 @@ public class DhcpConfig extends Config<ApplicationId> {
* @param lease new lease time; null to clear
* @return self
*/
- public BasicElementConfig leaseTime(String lease) {
+ public BasicElementConfig leaseTime(int lease) {
return (BasicElementConfig) setOrClear(LEASE_TIME, lease);
}
/**
* Returns the Renew Time offered by the DHCP Server.
*
- * @return renew time or null if not set
+ * @return renew time or -1 if not set
*/
- public String renewTime() {
- return get(RENEW_TIME, null);
+ public int renewTime() {
+ return get(RENEW_TIME, DEFAULT);
}
/**
@@ -164,17 +176,17 @@ public class DhcpConfig extends Config<ApplicationId> {
* @param renew new renew time; null to clear
* @return self
*/
- public BasicElementConfig renewTime(String renew) {
+ public BasicElementConfig renewTime(int renew) {
return (BasicElementConfig) setOrClear(RENEW_TIME, renew);
}
/**
* Returns the Rebind Time offered by the DHCP Server.
*
- * @return rebind time or null if not set
+ * @return rebind time or -1 if not set
*/
- public String rebindTime() {
- return get(REBIND_TIME, null);
+ public int rebindTime() {
+ return get(REBIND_TIME, DEFAULT);
}
/**
@@ -183,7 +195,7 @@ public class DhcpConfig extends Config<ApplicationId> {
* @param rebind new rebind time; null to clear
* @return self
*/
- public BasicElementConfig rebindTime(String rebind) {
+ public BasicElementConfig rebindTime(int rebind) {
return (BasicElementConfig) setOrClear(REBIND_TIME, rebind);
}
@@ -192,8 +204,9 @@ public class DhcpConfig extends Config<ApplicationId> {
*
* @return router address or null if not set
*/
- public String routerAddress() {
- return get(ROUTER_ADDRESS, null);
+ public Ip4Address routerAddress() {
+ String ip = get(ROUTER_ADDRESS, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
}
/**
@@ -211,8 +224,9 @@ public class DhcpConfig extends Config<ApplicationId> {
*
* @return domain server address or null if not set
*/
- public String domainServer() {
- return get(DOMAIN_SERVER, null);
+ public Ip4Address domainServer() {
+ String ip = get(DOMAIN_SERVER, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
}
/**
@@ -224,4 +238,82 @@ public class DhcpConfig extends Config<ApplicationId> {
public BasicElementConfig domainServer(String domain) {
return (BasicElementConfig) setOrClear(DOMAIN_SERVER, domain);
}
+
+ /**
+ * Returns the delay in minutes after which the dhcp server will purge expired entries.
+ *
+ * @return time delay or -1 if not set
+ */
+ public int timerDelay() {
+ return get(TIMER_DELAY, DEFAULT);
+ }
+
+ /**
+ * Sets the delay after which the dhcp server will purge expired entries.
+ *
+ * @param delay new time delay; null to clear
+ * @return self
+ */
+ public BasicElementConfig timerDelay(int delay) {
+ return (BasicElementConfig) setOrClear(TIMER_DELAY, delay);
+ }
+
+ /**
+ * Returns the default timeout for pending assignments.
+ *
+ * @return default timeout or -1 if not set
+ */
+ public int defaultTimeout() {
+ return get(DEFAULT_TIMEOUT, DEFAULT);
+ }
+
+ /**
+ * Sets the default timeout for pending assignments.
+ *
+ * @param defaultTimeout new default timeout; null to clear
+ * @return self
+ */
+ public BasicElementConfig defaultTimeout(int defaultTimeout) {
+ return (BasicElementConfig) setOrClear(DEFAULT_TIMEOUT, defaultTimeout);
+ }
+
+ /**
+ * Returns the start IP for the available IP Range.
+ *
+ * @return start IP or null if not set
+ */
+ public Ip4Address startIp() {
+ String ip = get(START_IP, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
+ }
+
+ /**
+ * Sets the start IP for the available IP Range.
+ *
+ * @param startIp new start IP; null to clear
+ * @return self
+ */
+ public BasicElementConfig startIp(String startIp) {
+ return (BasicElementConfig) setOrClear(START_IP, startIp);
+ }
+
+ /**
+ * Returns the end IP for the available IP Range.
+ *
+ * @return end IP or null if not set
+ */
+ public Ip4Address endIp() {
+ String ip = get(END_IP, null);
+ return ip != null ? Ip4Address.valueOf(ip) : null;
+ }
+
+ /**
+ * Sets the end IP for the available IP Range.
+ *
+ * @param endIp new end IP; null to clear
+ * @return self
+ */
+ public BasicElementConfig endIp(String endIp) {
+ return (BasicElementConfig) setOrClear(END_IP, endIp);
+ }
}
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
index 24cb0878..345d5ad0 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
@@ -22,6 +22,8 @@ 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.jboss.netty.util.Timeout;
+import org.jboss.netty.util.TimerTask;
import org.onlab.packet.ARP;
import org.onlab.packet.DHCP;
import org.onlab.packet.DHCPOption;
@@ -34,20 +36,20 @@ import org.onlab.packet.MacAddress;
import org.onlab.packet.TpPort;
import org.onlab.packet.UDP;
import org.onlab.packet.VlanId;
+import org.onlab.util.Timer;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.dhcp.DhcpService;
import org.onosproject.dhcp.DhcpStore;
import org.onosproject.dhcp.IpAssignment;
-import org.onosproject.net.config.ConfigFactory;
-import org.onosproject.net.config.NetworkConfigEvent;
-import org.onosproject.net.config.NetworkConfigListener;
-import org.onosproject.net.config.NetworkConfigRegistry;
-
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.HostLocation;
+import org.onosproject.net.config.ConfigFactory;
+import org.onosproject.net.config.NetworkConfigEvent;
+import org.onosproject.net.config.NetworkConfigListener;
+import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
@@ -68,10 +70,13 @@ import org.slf4j.LoggerFactory;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
+import java.util.concurrent.TimeUnit;
import static org.onlab.packet.MacAddress.valueOf;
import static org.onosproject.net.config.basics.SubjectFactories.APP_SUBJECT_FACTORY;
@@ -86,7 +91,7 @@ public class DhcpManager implements DhcpService {
private static final ProviderId PID = new ProviderId("of", "org.onosproject.dhcp", true);
private final Logger log = LoggerFactory.getLogger(getClass());
- private final NetworkConfigListener cfgListener = new InternalConfigListener();
+ private final InternalConfigListener cfgListener = new InternalConfigListener();
private final Set<ConfigFactory> factories = ImmutableSet.of(
new ConfigFactory<ApplicationId, DhcpConfig>(APP_SUBJECT_FACTORY,
@@ -96,14 +101,6 @@ public class DhcpManager implements DhcpService {
public DhcpConfig createConfig() {
return new DhcpConfig();
}
- },
- new ConfigFactory<ApplicationId, DhcpStoreConfig>(APP_SUBJECT_FACTORY,
- DhcpStoreConfig.class,
- "dhcpstore") {
- @Override
- public DhcpStoreConfig createConfig() {
- return new DhcpStoreConfig();
- }
}
);
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -125,11 +122,13 @@ public class DhcpManager implements DhcpService {
protected HostProviderService hostProviderService;
+ private final HostProvider hostProvider = new InternalHostProvider();
+
private ApplicationId appId;
// Hardcoded values are default values.
- private static String myIP = "10.0.0.2";
+ private static Ip4Address myIP = Ip4Address.valueOf("10.0.0.2");
private static MacAddress myMAC = valueOf("4f:4f:4f:4f:4f:4f");
@@ -147,14 +146,17 @@ public class DhcpManager implements DhcpService {
private static byte packetTTL = (byte) 127;
- private static String subnetMask = "255.0.0.0";
+ private static Ip4Address subnetMask = Ip4Address.valueOf("255.0.0.0");
- private static String broadcastAddress = "10.255.255.255";
+ private static Ip4Address broadcastAddress = Ip4Address.valueOf("10.255.255.255");
- private static String routerAddress = "10.0.0.2";
+ private static Ip4Address routerAddress = Ip4Address.valueOf("10.0.0.2");
- private static String domainServer = "10.0.0.2";
- private final HostProvider hostProvider = new InternalHostProvider();
+ private static Ip4Address domainServer = Ip4Address.valueOf("10.0.0.2");
+
+ protected Timeout timeout;
+
+ protected static int timerDelay = 2;
@Activate
protected void activate() {
@@ -163,9 +165,12 @@ public class DhcpManager implements DhcpService {
cfgService.addListener(cfgListener);
factories.forEach(cfgService::registerConfigFactory);
+ cfgListener.reconfigureNetwork(cfgService.getConfig(appId, DhcpConfig.class));
+
hostProviderService = hostProviderRegistry.register(hostProvider);
- packetService.addProcessor(processor, PacketProcessor.observer(1));
+ packetService.addProcessor(processor, PacketProcessor.director(0));
requestPackets();
+ timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
log.info("Started");
}
@@ -177,6 +182,7 @@ public class DhcpManager implements DhcpService {
hostProviderRegistry.unregister(hostProvider);
hostProviderService = null;
cancelPackets();
+ timeout.cancel();
log.info("Stopped");
}
@@ -214,8 +220,8 @@ public class DhcpManager implements DhcpService {
}
@Override
- public Map<MacAddress, IpAssignment> listMapping() {
- return dhcpStore.listMapping();
+ public Map<HostId, IpAssignment> listMapping() {
+ return dhcpStore.listAssignedMapping();
}
@Override
@@ -258,9 +264,7 @@ public class DhcpManager implements DhcpService {
* @param outgoingMessageType the message type of the outgoing packet
* @return the Ethernet reply frame
*/
- private Ethernet buildReply(Ethernet packet, String ipOffered, byte outgoingMessageType) {
- Ip4Address myIPAddress = Ip4Address.valueOf(myIP);
- Ip4Address ipAddress;
+ private Ethernet buildReply(Ethernet packet, Ip4Address ipOffered, byte outgoingMessageType) {
// Ethernet Frame.
Ethernet ethReply = new Ethernet();
@@ -272,9 +276,8 @@ public class DhcpManager implements DhcpService {
// IP Packet
IPv4 ipv4Packet = (IPv4) packet.getPayload();
IPv4 ipv4Reply = new IPv4();
- ipv4Reply.setSourceAddress(myIPAddress.toInt());
- ipAddress = Ip4Address.valueOf(ipOffered);
- ipv4Reply.setDestinationAddress(ipAddress.toInt());
+ ipv4Reply.setSourceAddress(myIP.toInt());
+ ipv4Reply.setDestinationAddress(ipOffered.toInt());
ipv4Reply.setTtl(packetTTL);
// UDP Datagram.
@@ -288,9 +291,8 @@ public class DhcpManager implements DhcpService {
DHCP dhcpReply = new DHCP();
dhcpReply.setOpCode(DHCP.OPCODE_REPLY);
- ipAddress = Ip4Address.valueOf(ipOffered);
- dhcpReply.setYourIPAddress(ipAddress.toInt());
- dhcpReply.setServerIPAddress(myIPAddress.toInt());
+ dhcpReply.setYourIPAddress(ipOffered.toInt());
+ dhcpReply.setServerIPAddress(myIP.toInt());
dhcpReply.setTransactionId(dhcpPacket.getTransactionId());
dhcpReply.setClientHardwareAddress(dhcpPacket.getClientHardwareAddress());
@@ -312,7 +314,7 @@ public class DhcpManager implements DhcpService {
option = new DHCPOption();
option.setCode(DHCP.DHCPOptionCode.OptionCode_DHCPServerIp.getValue());
option.setLength((byte) 4);
- option.setData(myIPAddress.toOctets());
+ option.setData(myIP.toOctets());
optionList.add(option);
// IP Address Lease Time.
@@ -340,32 +342,28 @@ public class DhcpManager implements DhcpService {
option = new DHCPOption();
option.setCode(DHCP.DHCPOptionCode.OptionCode_SubnetMask.getValue());
option.setLength((byte) 4);
- ipAddress = Ip4Address.valueOf(subnetMask);
- option.setData(ipAddress.toOctets());
+ option.setData(subnetMask.toOctets());
optionList.add(option);
// Broadcast Address.
option = new DHCPOption();
option.setCode(DHCP.DHCPOptionCode.OptionCode_BroadcastAddress.getValue());
option.setLength((byte) 4);
- ipAddress = Ip4Address.valueOf(broadcastAddress);
- option.setData(ipAddress.toOctets());
+ option.setData(broadcastAddress.toOctets());
optionList.add(option);
// Router Address.
option = new DHCPOption();
option.setCode(DHCP.DHCPOptionCode.OptionCode_RouterAddress.getValue());
option.setLength((byte) 4);
- ipAddress = Ip4Address.valueOf(routerAddress);
- option.setData(ipAddress.toOctets());
+ option.setData(routerAddress.toOctets());
optionList.add(option);
// DNS Server Address.
option = new DHCPOption();
option.setCode(DHCP.DHCPOptionCode.OptionCode_DomainServer.getValue());
option.setLength((byte) 4);
- ipAddress = Ip4Address.valueOf(domainServer);
- option.setData(ipAddress.toOctets());
+ option.setData(domainServer.toOctets());
optionList.add(option);
// End Option.
@@ -394,7 +392,7 @@ public class DhcpManager implements DhcpService {
TrafficTreatment.Builder builder = DefaultTrafficTreatment.builder();
ConnectPoint sourcePoint = context.inPacket().receivedFrom();
builder.setOutput(sourcePoint.port());
-
+ context.block();
packetService.emit(new DefaultOutboundPacket(sourcePoint.deviceId(),
builder.build(), ByteBuffer.wrap(reply.serialize())));
}
@@ -407,7 +405,6 @@ public class DhcpManager implements DhcpService {
* @param dhcpPayload the extracted DHCP payload
*/
private void processDHCPPacket(PacketContext context, DHCP dhcpPayload) {
-
Ethernet packet = context.inPacket().parsed();
boolean flagIfRequestedIP = false;
boolean flagIfServerIP = false;
@@ -416,12 +413,11 @@ public class DhcpManager implements DhcpService {
if (dhcpPayload != null) {
- // TODO Convert this to enum value.
- byte incomingPacketType = 0;
+ DHCPPacketType incomingPacketType = DHCPPacketType.getType(0);
for (DHCPOption option : dhcpPayload.getOptions()) {
if (option.getCode() == DHCP.DHCPOptionCode.OptionCode_MessageType.getValue()) {
byte[] data = option.getData();
- incomingPacketType = data[0];
+ incomingPacketType = DHCPPacketType.getType(data[0]);
}
if (option.getCode() == DHCP.DHCPOptionCode.OptionCode_RequestedIP.getValue()) {
byte[] data = option.getData();
@@ -434,37 +430,39 @@ public class DhcpManager implements DhcpService {
flagIfServerIP = true;
}
}
-
- String ipOffered = "";
DHCPPacketType outgoingPacketType;
MacAddress clientMAC = new MacAddress(dhcpPayload.getClientHardwareAddress());
+ VlanId vlanId = VlanId.vlanId(packet.getVlanID());
+ HostId hostId = HostId.hostId(clientMAC, vlanId);
- if (incomingPacketType == DHCPPacketType.DHCPDISCOVER.getValue()) {
+ if (incomingPacketType.getValue() == DHCPPacketType.DHCPDISCOVER.getValue()) {
outgoingPacketType = DHCPPacketType.DHCPOFFER;
- ipOffered = dhcpStore.suggestIP(clientMAC, requestedIP).toString();
-
- Ethernet ethReply = buildReply(packet, ipOffered, (byte) outgoingPacketType.getValue());
- sendReply(context, ethReply);
+ Ip4Address ipOffered = dhcpStore.suggestIP(hostId, requestedIP);
+ if (ipOffered != null) {
+ Ethernet ethReply = buildReply(packet, ipOffered,
+ (byte) outgoingPacketType.getValue());
+ sendReply(context, ethReply);
+ }
- } else if (incomingPacketType == DHCPPacketType.DHCPREQUEST.getValue()) {
+ } else if (incomingPacketType.getValue() == DHCPPacketType.DHCPREQUEST.getValue()) {
outgoingPacketType = DHCPPacketType.DHCPACK;
if (flagIfServerIP && flagIfRequestedIP) {
// SELECTING state
- if (myIP.equals(serverIP.toString()) &&
- dhcpStore.assignIP(clientMAC, requestedIP, leaseTime)) {
+ if (myIP.equals(serverIP) &&
+ dhcpStore.assignIP(hostId, requestedIP, leaseTime)) {
- Ethernet ethReply = buildReply(packet, requestedIP.toString(),
+ Ethernet ethReply = buildReply(packet, requestedIP,
(byte) outgoingPacketType.getValue());
sendReply(context, ethReply);
discoverHost(context, requestedIP);
}
} else if (flagIfRequestedIP) {
// INIT-REBOOT state
- if (dhcpStore.assignIP(clientMAC, requestedIP, leaseTime)) {
- Ethernet ethReply = buildReply(packet, requestedIP.toString(),
+ if (dhcpStore.assignIP(hostId, requestedIP, leaseTime)) {
+ Ethernet ethReply = buildReply(packet, requestedIP,
(byte) outgoingPacketType.getValue());
sendReply(context, ethReply);
discoverHost(context, requestedIP);
@@ -474,17 +472,16 @@ public class DhcpManager implements DhcpService {
int ciaadr = dhcpPayload.getClientIPAddress();
if (ciaadr != 0) {
Ip4Address clientIaddr = Ip4Address.valueOf(ciaadr);
- if (dhcpStore.assignIP(clientMAC, clientIaddr, leaseTime)) {
- Ethernet ethReply = buildReply(packet, clientIaddr.toString(),
+ if (dhcpStore.assignIP(hostId, clientIaddr, leaseTime)) {
+ Ethernet ethReply = buildReply(packet, clientIaddr,
(byte) outgoingPacketType.getValue());
sendReply(context, ethReply);
discoverHost(context, clientIaddr);
}
}
}
- } else if (incomingPacketType == DHCPPacketType.DHCPRELEASE.getValue()) {
-
- dhcpStore.releaseIP(clientMAC);
+ } else if (incomingPacketType.getValue() == DHCPPacketType.DHCPRELEASE.getValue()) {
+ dhcpStore.releaseIP(hostId);
}
}
}
@@ -540,7 +537,6 @@ public class DhcpManager implements DhcpService {
@Override
public void process(PacketContext context) {
-
Ethernet packet = context.inPacket().parsed();
if (packet == null) {
return;
@@ -564,7 +560,7 @@ public class DhcpManager implements DhcpService {
ARP arpPacket = (ARP) packet.getPayload();
if ((arpPacket.getOpCode() == ARP.OP_REQUEST) &&
- (Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()).toString().equals(myIP))) {
+ Objects.equals(myIP, Ip4Address.valueOf(arpPacket.getTargetProtocolAddress()))) {
processARPPacket(context, packet);
@@ -581,12 +577,14 @@ public class DhcpManager implements DhcpService {
* @param cfg configuration object
*/
private void reconfigureNetwork(DhcpConfig cfg) {
-
+ if (cfg == null) {
+ return;
+ }
if (cfg.ip() != null) {
myIP = cfg.ip();
}
if (cfg.mac() != null) {
- myMAC = MacAddress.valueOf(cfg.mac());
+ myMAC = cfg.mac();
}
if (cfg.subnetMask() != null) {
subnetMask = cfg.subnetMask();
@@ -600,54 +598,40 @@ public class DhcpManager implements DhcpService {
if (cfg.domainServer() != null) {
domainServer = cfg.domainServer();
}
- if (cfg.ttl() != null) {
- packetTTL = Byte.valueOf(cfg.ttl());
+ if (cfg.ttl() != -1) {
+ packetTTL = (byte) cfg.ttl();
}
- if (cfg.leaseTime() != null) {
- leaseTime = Integer.valueOf(cfg.leaseTime());
+ if (cfg.leaseTime() != -1) {
+ leaseTime = cfg.leaseTime();
}
- if (cfg.renewTime() != null) {
- renewalTime = Integer.valueOf(cfg.renewTime());
+ if (cfg.renewTime() != -1) {
+ renewalTime = cfg.renewTime();
}
- if (cfg.rebindTime() != null) {
- rebindingTime = Integer.valueOf(cfg.rebindTime());
+ if (cfg.rebindTime() != -1) {
+ rebindingTime = cfg.rebindTime();
}
- }
-
- /**
- * Reconfigures the DHCP Store according to the configuration parameters passed.
- *
- * @param cfg configuration object
- */
- private void reconfigureStore(DhcpStoreConfig cfg) {
-
- if (cfg.defaultTimeout() != null) {
- dhcpStore.setDefaultTimeoutForPurge(Integer.valueOf(cfg.defaultTimeout()));
+ if (cfg.defaultTimeout() != -1) {
+ dhcpStore.setDefaultTimeoutForPurge(cfg.defaultTimeout());
}
- if (cfg.timerDelay() != null) {
- dhcpStore.setTimerDelay(Integer.valueOf(cfg.defaultTimeout()));
+ if (cfg.timerDelay() != -1) {
+ timerDelay = cfg.timerDelay();
}
- if ((cfg.startIP() != null) && (cfg.endIP() != null)) {
- dhcpStore.populateIPPoolfromRange(Ip4Address.valueOf(cfg.startIP()),
- Ip4Address.valueOf(cfg.endIP()));
+ if ((cfg.startIp() != null) && (cfg.endIp() != null)) {
+ dhcpStore.populateIPPoolfromRange(cfg.startIp(), cfg.endIp());
}
}
+
@Override
public void event(NetworkConfigEvent event) {
if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
- event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED)) {
- if (event.configClass().equals(DhcpConfig.class)) {
- DhcpConfig cfg = cfgService.getConfig(appId, DhcpConfig.class);
- reconfigureNetwork(cfg);
- log.info("Reconfigured Manager");
- }
- if (event.configClass().equals(DhcpStoreConfig.class)) {
- DhcpStoreConfig cfg = cfgService.getConfig(appId, DhcpStoreConfig.class);
- reconfigureStore(cfg);
- log.info("Reconfigured Store");
- }
+ event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
+ event.configClass().equals(DhcpConfig.class)) {
+
+ DhcpConfig cfg = cfgService.getConfig(appId, DhcpConfig.class);
+ reconfigureNetwork(cfg);
+ log.info("Reconfigured");
}
}
}
@@ -666,4 +650,28 @@ public class DhcpManager implements DhcpService {
// nothing to do
}
}
+
+ private class PurgeListTask implements TimerTask {
+
+ @Override
+ public void run(Timeout to) {
+ IpAssignment ipAssignment;
+ Date dateNow = new Date();
+
+ Map<HostId, IpAssignment> ipAssignmentMap = dhcpStore.listAllMapping();
+ for (Map.Entry<HostId, IpAssignment> entry: ipAssignmentMap.entrySet()) {
+ ipAssignment = entry.getValue();
+
+ long timeLapsed = dateNow.getTime() - ipAssignment.timestamp().getTime();
+ if ((ipAssignment.assignmentStatus() != IpAssignment.AssignmentStatus.Option_Expired) &&
+ (ipAssignment.leasePeriod() > 0) && (timeLapsed > (ipAssignment.leasePeriodMs()))) {
+
+ dhcpStore.releaseIP(entry.getKey());
+ // TODO remove only the IP from the host entry when the API is in place.
+ hostProviderService.hostVanished(entry.getKey());
+ }
+ }
+ timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
+ }
+ }
} \ No newline at end of file
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java
index 89ed5720..9ce65d5e 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpViewMessageHandler.java
@@ -17,10 +17,10 @@ package org.onosproject.dhcp.impl;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.collect.ImmutableSet;
-import org.onlab.packet.MacAddress;
import org.onosproject.cli.AbstractShellCommand;
import org.onosproject.dhcp.DhcpService;
import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
import org.onosproject.ui.RequestHandler;
import org.onosproject.ui.UiMessageHandler;
import org.onosproject.ui.table.TableModel;
@@ -39,12 +39,12 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
private static final String DHCP_DATA_RESP = "dhcpDataResponse";
private static final String DHCP = "dhcps";
- private static final String MAC = "mac";
+ private static final String HOST = "host";
private static final String IP = "ip";
private static final String LEASE = "lease";
private static final String[] COL_IDS = {
- MAC, IP, LEASE
+ HOST, IP, LEASE
};
@Override
@@ -54,6 +54,7 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
);
}
+ // handler for dhcp table requests
private final class DataRequestHandler extends TableRequestHandler {
private DataRequestHandler() {
@@ -62,7 +63,7 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
@Override
protected String defaultColumnId() {
- return MAC;
+ return HOST;
}
@Override
@@ -73,21 +74,21 @@ public class DhcpViewMessageHandler extends UiMessageHandler {
@Override
protected void populateTable(TableModel tm, ObjectNode payload) {
DhcpService dhcpService = AbstractShellCommand.get(DhcpService.class);
- Map<MacAddress, IpAssignment> allocationMap = dhcpService.listMapping();
+ Map<HostId, IpAssignment> allocationMap = dhcpService.listMapping();
- for (Map.Entry<MacAddress, IpAssignment> entry : allocationMap.entrySet()) {
+ for (Map.Entry<HostId, IpAssignment> entry : allocationMap.entrySet()) {
populateRow(tm.addRow(), entry);
}
}
- private void populateRow(TableModel.Row row, Map.Entry<MacAddress, IpAssignment> entry) {
+ private void populateRow(TableModel.Row row, Map.Entry<HostId, IpAssignment> entry) {
if (entry.getValue().leasePeriod() > 0) {
Date now = new Date(entry.getValue().timestamp().getTime() + entry.getValue().leasePeriod());
- row.cell(MAC, entry.getKey())
+ row.cell(HOST, entry.getKey())
.cell(IP, entry.getValue().ipAddress())
.cell(LEASE, now.toString());
} else {
- row.cell(MAC, entry.getKey())
+ row.cell(HOST, entry.getKey())
.cell(IP, entry.getValue().ipAddress())
.cell(LEASE, "Infinite Static Lease");
}
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java
index 6e29216a..dbdadb34 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DistributedDhcpStore.java
@@ -22,14 +22,12 @@ 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.jboss.netty.util.Timeout;
-import org.jboss.netty.util.TimerTask;
import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
import org.onlab.util.KryoNamespace;
-import org.onlab.util.Timer;
import org.onosproject.dhcp.DhcpStore;
import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
import org.onosproject.store.serializers.KryoNamespaces;
import org.onosproject.store.service.ConsistentMap;
import org.onosproject.store.service.DistributedSet;
@@ -42,7 +40,7 @@ import org.slf4j.LoggerFactory;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
+import java.util.Objects;
/**
* Manages the pool of available IP Addresses in the network and
@@ -58,25 +56,21 @@ public class DistributedDhcpStore implements DhcpStore {
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected StorageService storageService;
- private ConsistentMap<MacAddress, IpAssignment> allocationMap;
+ private ConsistentMap<HostId, IpAssignment> allocationMap;
private DistributedSet<Ip4Address> freeIPPool;
- private Timeout timeout;
-
private static Ip4Address startIPRange;
private static Ip4Address endIPRange;
// Hardcoded values are default values.
- private static int timerDelay = 2;
-
private static int timeoutForPendingAssignments = 60;
@Activate
protected void activate() {
- allocationMap = storageService.<MacAddress, IpAssignment>consistentMapBuilder()
+ allocationMap = storageService.<HostId, IpAssignment>consistentMapBuilder()
.withName("onos-dhcp-assignedIP")
.withSerializer(Serializer.using(
new KryoNamespace.Builder()
@@ -94,30 +88,27 @@ public class DistributedDhcpStore implements DhcpStore {
.withSerializer(Serializer.using(KryoNamespaces.API))
.build();
- timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
-
log.info("Started");
}
@Deactivate
protected void deactivate() {
- timeout.cancel();
log.info("Stopped");
}
@Override
- public Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP) {
+ public Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP) {
IpAssignment assignmentInfo;
- if (allocationMap.containsKey(macID)) {
- assignmentInfo = allocationMap.get(macID).value();
+ if (allocationMap.containsKey(hostId)) {
+ assignmentInfo = allocationMap.get(hostId).value();
IpAssignment.AssignmentStatus status = assignmentInfo.assignmentStatus();
Ip4Address ipAddr = assignmentInfo.ipAddress();
if (status == IpAssignment.AssignmentStatus.Option_Assigned ||
status == IpAssignment.AssignmentStatus.Option_Requested) {
// Client has a currently Active Binding.
- if ((ipAddr.toInt() > startIPRange.toInt()) && (ipAddr.toInt() < endIPRange.toInt())) {
+ if (ipWithinRange(ipAddr)) {
return ipAddr;
}
@@ -131,13 +122,11 @@ public class DistributedDhcpStore implements DhcpStore {
.assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
.build();
if (freeIPPool.remove(ipAddr)) {
- allocationMap.put(macID, assignmentInfo);
+ allocationMap.put(hostId, assignmentInfo);
return ipAddr;
}
}
}
- return assignmentInfo.ipAddress();
-
} else if (requestedIP.toInt() != 0) {
// Client has requested an IP.
if (freeIPPool.contains(requestedIP)) {
@@ -148,7 +137,7 @@ public class DistributedDhcpStore implements DhcpStore {
.assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
.build();
if (freeIPPool.remove(requestedIP)) {
- allocationMap.put(macID, assignmentInfo);
+ allocationMap.put(hostId, assignmentInfo);
return requestedIP;
}
}
@@ -156,35 +145,56 @@ public class DistributedDhcpStore implements DhcpStore {
// Allocate a new IP from the server's pool of available IP.
Ip4Address nextIPAddr = fetchNextIP();
- assignmentInfo = IpAssignment.builder()
- .ipAddress(nextIPAddr)
- .timestamp(new Date())
- .leasePeriod(timeoutForPendingAssignments)
- .assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
- .build();
+ if (nextIPAddr != null) {
+ assignmentInfo = IpAssignment.builder()
+ .ipAddress(nextIPAddr)
+ .timestamp(new Date())
+ .leasePeriod(timeoutForPendingAssignments)
+ .assignmentStatus(IpAssignment.AssignmentStatus.Option_Requested)
+ .build();
- allocationMap.put(macID, assignmentInfo);
+ allocationMap.put(hostId, assignmentInfo);
+ }
return nextIPAddr;
}
@Override
- public boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime) {
+ public boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime) {
IpAssignment assignmentInfo;
- if (allocationMap.containsKey(macID)) {
- assignmentInfo = allocationMap.get(macID).value();
- if ((assignmentInfo.ipAddress().toInt() == ipAddr.toInt()) &&
- (ipAddr.toInt() > startIPRange.toInt()) && (ipAddr.toInt() < endIPRange.toInt())) {
+ if (allocationMap.containsKey(hostId)) {
+ assignmentInfo = allocationMap.get(hostId).value();
+ IpAssignment.AssignmentStatus status = assignmentInfo.assignmentStatus();
- assignmentInfo = IpAssignment.builder()
- .ipAddress(ipAddr)
- .timestamp(new Date())
- .leasePeriod(leaseTime)
- .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
- .build();
- allocationMap.put(macID, assignmentInfo);
- return true;
+ if (Objects.equals(assignmentInfo.ipAddress(), ipAddr) && ipWithinRange(ipAddr)) {
+
+ if (status == IpAssignment.AssignmentStatus.Option_Assigned ||
+ status == IpAssignment.AssignmentStatus.Option_Requested) {
+ // Client has a currently active binding with the server.
+ assignmentInfo = IpAssignment.builder()
+ .ipAddress(ipAddr)
+ .timestamp(new Date())
+ .leasePeriod(leaseTime)
+ .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
+ .build();
+ allocationMap.put(hostId, assignmentInfo);
+ return true;
+ } else if (status == IpAssignment.AssignmentStatus.Option_Expired) {
+ // Client has an expired binding with the server.
+ if (freeIPPool.contains(ipAddr)) {
+ assignmentInfo = IpAssignment.builder()
+ .ipAddress(ipAddr)
+ .timestamp(new Date())
+ .leasePeriod(leaseTime)
+ .assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
+ .build();
+ if (freeIPPool.remove(ipAddr)) {
+ allocationMap.put(hostId, assignmentInfo);
+ return true;
+ }
+ }
+ }
}
} else if (freeIPPool.contains(ipAddr)) {
assignmentInfo = IpAssignment.builder()
@@ -194,7 +204,7 @@ public class DistributedDhcpStore implements DhcpStore {
.assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
.build();
if (freeIPPool.remove(ipAddr)) {
- allocationMap.put(macID, assignmentInfo);
+ allocationMap.put(hostId, assignmentInfo);
return true;
}
}
@@ -202,14 +212,16 @@ public class DistributedDhcpStore implements DhcpStore {
}
@Override
- public void releaseIP(MacAddress macID) {
- if (allocationMap.containsKey(macID)) {
- IpAssignment newAssignment = IpAssignment.builder(allocationMap.get(macID).value())
+ public void releaseIP(HostId hostId) {
+ if (allocationMap.containsKey(hostId)) {
+ IpAssignment newAssignment = IpAssignment.builder(allocationMap.get(hostId).value())
.assignmentStatus(IpAssignment.AssignmentStatus.Option_Expired)
.build();
Ip4Address freeIP = newAssignment.ipAddress();
- allocationMap.put(macID, newAssignment);
- freeIPPool.add(freeIP);
+ allocationMap.put(hostId, newAssignment);
+ if (ipWithinRange(freeIP)) {
+ freeIPPool.add(freeIP);
+ }
}
}
@@ -219,37 +231,45 @@ public class DistributedDhcpStore implements DhcpStore {
}
@Override
- public void setTimerDelay(int timeInSeconds) {
- timerDelay = timeInSeconds;
- }
+ public Map<HostId, IpAssignment> listAssignedMapping() {
- @Override
- public Map<MacAddress, IpAssignment> listMapping() {
-
- Map<MacAddress, IpAssignment> allMapping = new HashMap<>();
- for (Map.Entry<MacAddress, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
- IpAssignment assignment = entry.getValue().value();
+ Map<HostId, IpAssignment> validMapping = new HashMap<>();
+ IpAssignment assignment;
+ for (Map.Entry<HostId, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
+ assignment = entry.getValue().value();
if (assignment.assignmentStatus() == IpAssignment.AssignmentStatus.Option_Assigned) {
- allMapping.put(entry.getKey(), assignment);
+ validMapping.put(entry.getKey(), assignment);
}
}
- return allMapping;
+ return validMapping;
+ }
+ @Override
+ public Map<HostId, IpAssignment> listAllMapping() {
+ Map<HostId, IpAssignment> validMapping = new HashMap<>();
+ for (Map.Entry<HostId, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
+ validMapping.put(entry.getKey(), entry.getValue().value());
+ }
+ return validMapping;
}
@Override
public boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr) {
- return assignIP(macID, ipAddr, -1);
+ HostId host = HostId.hostId(macID);
+ return assignIP(host, ipAddr, -1);
}
@Override
public boolean removeStaticIP(MacAddress macID) {
- if (allocationMap.containsKey(macID)) {
- IpAssignment assignment = allocationMap.get(macID).value();
+ HostId host = HostId.hostId(macID);
+ if (allocationMap.containsKey(host)) {
+ IpAssignment assignment = allocationMap.get(host).value();
Ip4Address freeIP = assignment.ipAddress();
if (assignment.leasePeriod() < 0) {
- allocationMap.remove(macID);
- freeIPPool.add(freeIP);
+ allocationMap.remove(host);
+ if (ipWithinRange(freeIP)) {
+ freeIPPool.add(freeIP);
+ }
return true;
}
}
@@ -258,15 +278,16 @@ public class DistributedDhcpStore implements DhcpStore {
@Override
public Iterable<Ip4Address> getAvailableIPs() {
- return ImmutableSet.<Ip4Address>copyOf(freeIPPool);
+ return ImmutableSet.copyOf(freeIPPool);
}
@Override
public void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP) {
// Clear all entries from previous range.
+ allocationMap.clear();
+ freeIPPool.clear();
startIPRange = startIP;
endIPRange = endIP;
- freeIPPool.clear();
int lastIP = endIP.toInt();
Ip4Address nextIP;
@@ -291,34 +312,15 @@ public class DistributedDhcpStore implements DhcpStore {
}
/**
- * Purges the IP allocation map to remove expired entries and returns the freed IPs to the free pool.
+ * Returns true if the given ip is within the range of available IPs.
+ *
+ * @param ip given ip address
+ * @return true if within range, false otherwise
*/
- private class PurgeListTask implements TimerTask {
-
- @Override
- public void run(Timeout to) {
- IpAssignment ipAssignment, newAssignment;
- Date dateNow = new Date();
- for (Map.Entry<MacAddress, Versioned<IpAssignment>> entry: allocationMap.entrySet()) {
- ipAssignment = entry.getValue().value();
- long timeLapsed = dateNow.getTime() - ipAssignment.timestamp().getTime();
- if ((ipAssignment.assignmentStatus() != IpAssignment.AssignmentStatus.Option_Expired) &&
- (ipAssignment.leasePeriod() > 0) && (timeLapsed > (ipAssignment.leasePeriod()))) {
- Ip4Address freeIP = ipAssignment.ipAddress();
-
- newAssignment = IpAssignment.builder(ipAssignment)
- .assignmentStatus(IpAssignment.AssignmentStatus.Option_Expired)
- .build();
- allocationMap.put(entry.getKey(), newAssignment);
-
- if ((freeIP.toInt() > startIPRange.toInt()) && (freeIP.toInt() < endIPRange.toInt())) {
- freeIPPool.add(freeIP);
- }
- }
- }
- timeout = Timer.getTimer().newTimeout(new PurgeListTask(), timerDelay, TimeUnit.MINUTES);
+ private boolean ipWithinRange(Ip4Address ip) {
+ if ((ip.toInt() >= startIPRange.toInt()) && (ip.toInt() <= endIPRange.toInt())) {
+ return true;
}
-
+ return false;
}
-
}
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java
new file mode 100644
index 00000000..12e14e48
--- /dev/null
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation classes for sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp.impl; \ No newline at end of file
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java
new file mode 100644
index 00000000..56778a35
--- /dev/null
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp; \ No newline at end of file
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java
index bfa2767d..646ab7ea 100644
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/DHCPWebResource.java
@@ -22,6 +22,7 @@ import org.onlab.packet.Ip4Address;
import org.onlab.packet.MacAddress;
import org.onosproject.dhcp.DhcpService;
import org.onosproject.dhcp.IpAssignment;
+import org.onosproject.net.HostId;
import org.onosproject.rest.AbstractWebResource;
import javax.ws.rs.Consumes;
@@ -72,10 +73,10 @@ public class DHCPWebResource extends AbstractWebResource {
public Response listMappings() {
ObjectNode root = mapper().createObjectNode();
- final Map<MacAddress, IpAssignment> intents = service.listMapping();
+ final Map<HostId, IpAssignment> intents = service.listMapping();
ArrayNode arrayNode = root.putArray("mappings");
intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
- .put("mac", i.getKey().toString())
+ .put("host", i.getKey().toString())
.put("ip", i.getValue().ipAddress().toString())));
return ok(root.toString()).build();
@@ -125,10 +126,10 @@ public class DHCPWebResource extends AbstractWebResource {
}
}
- final Map<MacAddress, IpAssignment> intents = service.listMapping();
+ final Map<HostId, IpAssignment> intents = service.listMapping();
ArrayNode arrayNode = root.putArray("mappings");
intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
- .put("mac", i.getKey().toString())
+ .put("host", i.getKey().toString())
.put("ip", i.getValue().ipAddress().toString())));
} catch (IOException e) {
throw new IllegalArgumentException(e.getMessage());
@@ -152,10 +153,10 @@ public class DHCPWebResource extends AbstractWebResource {
if (!service.removeStaticMapping(MacAddress.valueOf(macID))) {
throw new IllegalArgumentException("Static Mapping Removal Failed.");
}
- final Map<MacAddress, IpAssignment> intents = service.listMapping();
+ final Map<HostId, IpAssignment> intents = service.listMapping();
ArrayNode arrayNode = root.putArray("mappings");
intents.entrySet().forEach(i -> arrayNode.add(mapper().createObjectNode()
- .put("mac", i.getKey().toString())
+ .put("host", i.getKey().toString())
.put("ip", i.getValue().ipAddress().toString())));
return ok(root.toString()).build();
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java
new file mode 100644
index 00000000..73173c55
--- /dev/null
+++ b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/rest/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * REST APIs for sample application that assigns and manages DHCP leases.
+ */
+package org.onosproject.dhcp.rest; \ No newline at end of file
diff --git a/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html b/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html
index 3e14570a..5782badf 100644
--- a/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html
+++ b/framework/src/onos/apps/dhcp/src/main/resources/app/view/dhcp/dhcp.html
@@ -17,7 +17,7 @@
<div class="table-header" onos-sortable-header>
<table>
<tr>
- <td colId="mac" sortable>MAC Address</td>
+ <td colId="host" sortable>Host ID</td>
<td colId="ip" sortable>IP Address</td>
<td colId="lease" sortable>Lease Expiry</td>
</tr>
@@ -25,7 +25,7 @@
</div>
<div class="table-body">
- <table onos-flash-changes id-prop="mac">
+ <table onos-flash-changes id-prop="host">
<tr ng-if="!tableData.length" class="no-data">
<td colspan="2">
No mappings found
@@ -34,8 +34,8 @@
<tr ng-repeat="dhcp in tableData track by $index"
ng-click="selectCallback($event, dhcp)"
- ng-repeat-complete row-id="{{dhcp.mac}}">
- <td>{{dhcp.mac}}</td>
+ ng-repeat-complete row-id="{{dhcp.host}}">
+ <td>{{dhcp.host}}</td>
<td>{{dhcp.ip}}</td>
<td>{{dhcp.lease}}</td>
</tr>
diff --git a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java
index dad5ef55..3ecc5cfa 100644
--- a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java
+++ b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/IpAssignmentTest.java
@@ -16,7 +16,6 @@
package org.onosproject.dhcp;
import com.google.common.testing.EqualsTester;
-import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import org.onlab.packet.Ip4Address;
@@ -31,7 +30,7 @@ import static org.junit.Assert.fail;
/**
* Unit Tests for IPAssignment class.
*/
-public class IpAssignmentTest extends TestCase {
+public class IpAssignmentTest {
private final Date dateNow = new Date();
@@ -98,4 +97,4 @@ public class IpAssignmentTest extends TestCase {
Assert.assertThat(e.getMessage(), containsString("must be specified"));
}
}
-} \ No newline at end of file
+}
diff --git a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java
index 42ac73d3..3ea3b1b8 100644
--- a/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java
+++ b/framework/src/onos/apps/dhcp/src/test/java/org/onosproject/dhcp/impl/DhcpManagerTest.java
@@ -72,7 +72,7 @@ public class DhcpManagerTest {
protected HostProviderService hostProviderService;
- private static final MacAddress CLIENT1_MAC = MacAddress.valueOf("1a:1a:1a:1a:1a:1a");
+ private static final HostId CLIENT1_HOST = HostId.hostId(MacAddress.valueOf("1a:1a:1a:1a:1a:1a"));
private static final String EXPECTED_IP = "10.2.0.2";
@@ -141,7 +141,7 @@ public class DhcpManagerTest {
// Ethernet Frame.
Ethernet ethReply = new Ethernet();
- ethReply.setSourceMACAddress(CLIENT1_MAC);
+ ethReply.setSourceMACAddress(CLIENT1_HOST.mac());
ethReply.setDestinationMACAddress(MacAddress.BROADCAST);
ethReply.setEtherType(Ethernet.TYPE_IPV4);
ethReply.setVlanID((short) 2);
@@ -165,7 +165,7 @@ public class DhcpManagerTest {
dhcpReply.setServerIPAddress(0);
dhcpReply.setTransactionId(TRANSACTION_ID);
- dhcpReply.setClientHardwareAddress(CLIENT1_MAC.toBytes());
+ dhcpReply.setClientHardwareAddress(CLIENT1_HOST.mac().toBytes());
dhcpReply.setHardwareType(DHCP.HWTYPE_ETHERNET);
dhcpReply.setHardwareAddressLength((byte) 6);
@@ -209,7 +209,7 @@ public class DhcpManagerTest {
*/
private void validatePacket(Ethernet packet) {
DHCP dhcpPacket = (DHCP) packet.getPayload().getPayload().getPayload();
- assertEquals(MacAddress.valueOf(dhcpPacket.getClientHardwareAddress()), CLIENT1_MAC);
+ assertEquals(MacAddress.valueOf(dhcpPacket.getClientHardwareAddress()), CLIENT1_HOST.mac());
assertEquals(Ip4Address.valueOf(dhcpPacket.getYourIPAddress()), Ip4Address.valueOf(EXPECTED_IP));
assertEquals(dhcpPacket.getTransactionId(), TRANSACTION_ID);
}
@@ -223,32 +223,33 @@ public class DhcpManagerTest {
public void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP) {
}
- public Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP) {
+ public Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP) {
return Ip4Address.valueOf(EXPECTED_IP);
}
- public boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime) {
+ public boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime) {
return true;
}
public void setDefaultTimeoutForPurge(int timeInSeconds) {
}
- public void setTimerDelay(int timeInSeconds) {
+ public void releaseIP(HostId hostId) {
}
- public void releaseIP(MacAddress macID) {
+ public Map<HostId, IpAssignment> listAssignedMapping() {
+ return listAllMapping();
}
- public Map<MacAddress, IpAssignment> listMapping() {
- Map<MacAddress, IpAssignment> map = new HashMap<>();
+ public Map<HostId, IpAssignment> listAllMapping() {
+ Map<HostId, IpAssignment> map = new HashMap<>();
IpAssignment assignment = IpAssignment.builder()
.ipAddress(Ip4Address.valueOf(EXPECTED_IP))
.assignmentStatus(IpAssignment.AssignmentStatus.Option_Assigned)
.leasePeriod(300)
.timestamp(new Date())
.build();
- map.put(CLIENT1_MAC, assignment);
+ map.put(CLIENT1_HOST, assignment);
return map;
}
@@ -329,7 +330,7 @@ public class DhcpManagerTest {
}
@Override
- public void hostDetected(HostId hostId, HostDescription hostDescription) {
+ public void hostDetected(HostId hostId, HostDescription hostDescription, boolean replaceIps) {
}
@Override
diff --git a/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json b/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json
index 8ce5486f..abc48a83 100644
--- a/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json
+++ b/framework/src/onos/apps/dhcp/src/test/resources/dhcp-cfg.json
@@ -11,9 +11,7 @@
"ttl": "63",
"lease": "300",
"renew": "150",
- "rebind": "200"
- },
- "dhcpstore" : {
+ "rebind": "200",
"delay": "3",
"timeout": "150",
"startip": "10.0.0.110",
diff --git a/framework/src/onos/apps/flowanalyzer/pom.xml b/framework/src/onos/apps/flowanalyzer/pom.xml
index e068be6c..f5dfcf2b 100644
--- a/framework/src/onos/apps/flowanalyzer/pom.xml
+++ b/framework/src/onos/apps/flowanalyzer/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/fwd/pom.xml b/framework/src/onos/apps/fwd/pom.xml
index 324f46cd..977a75a4 100644
--- a/framework/src/onos/apps/fwd/pom.xml
+++ b/framework/src/onos/apps/fwd/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/metrics/pom.xml b/framework/src/onos/apps/metrics/pom.xml
index 89757c9a..8a39990a 100644
--- a/framework/src/onos/apps/metrics/pom.xml
+++ b/framework/src/onos/apps/metrics/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java
index 78a540c9..9a42e9ee 100644
--- a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java
+++ b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/intent/IntentMetrics.java
@@ -107,7 +107,7 @@ public class IntentMetrics implements IntentMetricsService,
@Override
public List<IntentEvent> getEvents() {
synchronized (lastEvents) {
- return ImmutableList.<IntentEvent>copyOf(lastEvents);
+ return ImmutableList.copyOf(lastEvents);
}
}
diff --git a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java
index 5785f5f2..fb984c9e 100644
--- a/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java
+++ b/framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java
@@ -138,7 +138,7 @@ public class TopologyMetrics implements TopologyMetricsService {
@Override
public List<Event> getEvents() {
synchronized (lastEvents) {
- return ImmutableList.<Event>copyOf(lastEvents);
+ return ImmutableList.copyOf(lastEvents);
}
}
diff --git a/framework/src/onos/apps/mobility/pom.xml b/framework/src/onos/apps/mobility/pom.xml
index bc50813f..59fd6668 100644
--- a/framework/src/onos/apps/mobility/pom.xml
+++ b/framework/src/onos/apps/mobility/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/olt/pom.xml b/framework/src/onos/apps/olt/pom.xml
index a2a7b968..180e026a 100644
--- a/framework/src/onos/apps/olt/pom.xml
+++ b/framework/src/onos/apps/olt/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/optical/pom.xml b/framework/src/onos/apps/optical/pom.xml
index ac298e0b..9ae6f85e 100644
--- a/framework/src/onos/apps/optical/pom.xml
+++ b/framework/src/onos/apps/optical/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java
index f3f8d174..2ef5cd57 100644
--- a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java
@@ -34,8 +34,8 @@ public class OpticalNetworkConfig {
private List<OpticalLinkDescription> opticalLinks;
public OpticalNetworkConfig() {
- opticalSwitches = new ArrayList<OpticalSwitchDescription>();
- opticalLinks = new ArrayList<OpticalLinkDescription>();
+ opticalSwitches = new ArrayList<>();
+ opticalLinks = new ArrayList<>();
}
public List<OpticalSwitchDescription> getOpticalSwitches() {
diff --git a/framework/src/onos/apps/pcep-api/pom.xml b/framework/src/onos/apps/pcep-api/pom.xml
index 80b4a436..5e871678 100644
--- a/framework/src/onos/apps/pcep-api/pom.xml
+++ b/framework/src/onos/apps/pcep-api/pom.xml
@@ -1,12 +1,29 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- </parent>
- <artifactId>onos-app-pcep-api</artifactId>
- <packaging>bundle</packaging>
+<!--
+ ~ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <artifactId>onos-app-pcep-api</artifactId>
+ <packaging>bundle</packaging>
- <description>PCEP protocol API</description>
+ <description>PCEP protocol API</description>
</project> \ No newline at end of file
diff --git a/framework/src/onos/apps/pom.xml b/framework/src/onos/apps/pom.xml
index e5ceddde..334c690b 100644
--- a/framework/src/onos/apps/pom.xml
+++ b/framework/src/onos/apps/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -37,7 +37,6 @@
<module>fwd</module>
<module>mobility</module>
<module>proxyarp</module>
- <module>config</module>
<module>sdnip</module>
<module>optical</module>
<module>metrics</module>
@@ -58,7 +57,8 @@
<module>vtn</module>
<module>vtnweb</module>
<module>dhcp</module>
- </modules>
+ <module>cordvtn</module>
+ </modules>
<properties>
<web.context>default</web.context>
diff --git a/framework/src/onos/apps/proxyarp/pom.xml b/framework/src/onos/apps/proxyarp/pom.xml
index e6e76585..69f64ddb 100644
--- a/framework/src/onos/apps/proxyarp/pom.xml
+++ b/framework/src/onos/apps/proxyarp/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java b/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
index 742d7af7..2eb96df2 100644
--- a/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
+++ b/framework/src/onos/apps/proxyarp/src/main/java/org/onosproject/proxyarp/ProxyArp.java
@@ -82,7 +82,7 @@ public class ProxyArp {
packetService.addProcessor(processor, PacketProcessor.director(1));
readComponentConfiguration(context);
- requestPackests();
+ requestPackets();
log.info("Started with Application ID {}", appId.id());
}
@@ -99,13 +99,13 @@ public class ProxyArp {
@Modified
public void modified(ComponentContext context) {
readComponentConfiguration(context);
- requestPackests();
+ requestPackets();
}
/**
* Request packet in via PacketService.
*/
- private void requestPackests() {
+ private void requestPackets() {
TrafficSelector.Builder selectorBuilder =
DefaultTrafficSelector.builder();
selectorBuilder.matchEthType(TYPE_ARP);
diff --git a/framework/src/onos/apps/reactive-routing/pom.xml b/framework/src/onos/apps/reactive-routing/pom.xml
index 1d93cbf1..58fb91ee 100644
--- a/framework/src/onos/apps/reactive-routing/pom.xml
+++ b/framework/src/onos/apps/reactive-routing/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/routing-api/pom.xml b/framework/src/onos/apps/routing-api/pom.xml
index 1b9fc2fa..48fc2920 100644
--- a/framework/src/onos/apps/routing-api/pom.xml
+++ b/framework/src/onos/apps/routing-api/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
index d6f6e574..8d563b87 100644
--- a/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
+++ b/framework/src/onos/apps/routing-api/src/main/java/org/onosproject/routing/config/Interface.java
@@ -21,7 +21,6 @@ import org.onlab.packet.MacAddress;
import org.onlab.packet.VlanId;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
import java.util.Objects;
import java.util.Set;
@@ -55,18 +54,6 @@ public class Interface {
}
/**
- * Creates an Interface based on a PortAddresses object.
- *
- * @param portAddresses the PortAddresses object to turn into an Interface
- */
- public Interface(PortAddresses portAddresses) {
- connectPoint = portAddresses.connectPoint();
- ipAddresses = Sets.newHashSet(portAddresses.ipAddresses());
- macAddress = portAddresses.mac();
- vlan = portAddresses.vlan();
- }
-
- /**
* Retrieves the connection point that this interface maps to.
*
* @return the connection point
diff --git a/framework/src/onos/apps/routing/pom.xml b/framework/src/onos/apps/routing/pom.xml
index 1d9f19b7..c461ef3f 100644
--- a/framework/src/onos/apps/routing/pom.xml
+++ b/framework/src/onos/apps/routing/pom.xml
@@ -20,7 +20,7 @@
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
index 57481c20..ab8a0493 100644
--- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
+++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/bgp/BgpSessionManager.java
@@ -300,21 +300,18 @@ public class BgpSessionManager implements BgpInfoService, BgpService {
ChannelFactory channelFactory = new NioServerSocketChannelFactory(
newCachedThreadPool(groupedThreads("onos/bgp", "sm-boss-%d")),
newCachedThreadPool(groupedThreads("onos/bgp", "sm-worker-%d")));
- ChannelPipelineFactory pipelineFactory = new ChannelPipelineFactory() {
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- // Allocate a new session per connection
- BgpSession bgpSessionHandler =
- new BgpSession(BgpSessionManager.this);
- BgpFrameDecoder bgpFrameDecoder =
- new BgpFrameDecoder(bgpSessionHandler);
-
- // Setup the processing pipeline
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
- pipeline.addLast("BgpSession", bgpSessionHandler);
- return pipeline;
- }
+ ChannelPipelineFactory pipelineFactory = () -> {
+ // Allocate a new session per connection
+ BgpSession bgpSessionHandler =
+ new BgpSession(BgpSessionManager.this);
+ BgpFrameDecoder bgpFrameDecoder =
+ new BgpFrameDecoder(bgpSessionHandler);
+
+ // Setup the processing pipeline
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("BgpFrameDecoder", bgpFrameDecoder);
+ pipeline.addLast("BgpSession", bgpSessionHandler);
+ return pipeline;
};
InetSocketAddress listenAddress =
new InetSocketAddress(bgpPort);
diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
index 1078319d..0a6f9d4c 100644
--- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
+++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/RoutingConfigurationImpl.java
@@ -38,7 +38,6 @@ import org.onosproject.net.config.ConfigFactory;
import org.onosproject.net.config.NetworkConfigRegistry;
import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
-import org.onosproject.net.host.HostService;
import org.onosproject.routing.config.BgpConfig;
import org.onosproject.routing.config.BgpPeer;
import org.onosproject.routing.config.BgpSpeaker;
@@ -76,9 +75,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
private String configFileName = DEFAULT_CONFIG_FILE;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected NetworkConfigRegistry registry;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -103,7 +99,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
new DefaultByteArrayNodeFactory());
private MacAddress virtualGatewayMacAddress;
- private HostToInterfaceAdaptor hostAdaptor;
private ConfigFactory configFactory =
new ConfigFactory(SubjectFactories.APP_SUBJECT_FACTORY, BgpConfig.class, "bgp") {
@@ -117,7 +112,6 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
public void activate() {
registry.registerConfigFactory(configFactory);
readConfiguration();
- hostAdaptor = new HostToInterfaceAdaptor(hostService);
log.info("Routing configuration service started");
}
@@ -189,7 +183,7 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
@Override
public Set<Interface> getInterfaces() {
- return hostAdaptor.getInterfaces();
+ return Collections.emptySet();
}
@Override
@@ -212,17 +206,17 @@ public class RoutingConfigurationImpl implements RoutingConfigurationService {
@Override
public Interface getInterface(ConnectPoint connectPoint) {
- return hostAdaptor.getInterface(connectPoint);
+ return null;
}
@Override
public Interface getInterface(IpAddress ip) {
- return hostAdaptor.getInterface(ip);
+ return null;
}
@Override
public Interface getMatchingInterface(IpAddress ipAddress) {
- return hostAdaptor.getMatchingInterface(ipAddress);
+ return null;
}
@Override
diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
index c4f291ba..6700d530 100644
--- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
+++ b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/impl/Router.java
@@ -159,12 +159,7 @@ public class Router implements RoutingService {
bgpService.start(new InternalRouteListener());
- bgpUpdatesExecutor.execute(new Runnable() {
- @Override
- public void run() {
- doUpdatesThread();
- }
- });
+ bgpUpdatesExecutor.execute(this::doUpdatesThread);
}
@Override
diff --git a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java b/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
index 634e87b9..3f5a6b8b 100644
--- a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
+++ b/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/bgp/BgpSessionManagerTest.java
@@ -151,19 +151,15 @@ public class BgpSessionManagerTest {
new NioClientSocketChannelFactory(
Executors.newCachedThreadPool(),
Executors.newCachedThreadPool());
- ChannelPipelineFactory pipelineFactory =
- new ChannelPipelineFactory() {
- @Override
- public ChannelPipeline getPipeline() throws Exception {
- // Setup the transmitting pipeline
- ChannelPipeline pipeline = Channels.pipeline();
- pipeline.addLast("TestBgpPeerFrameDecoder",
- peerFrameDecoder);
- pipeline.addLast("TestBgpPeerChannelHandler",
- peerChannelHandler);
- return pipeline;
- }
- };
+ ChannelPipelineFactory pipelineFactory = () -> {
+ // Setup the transmitting pipeline
+ ChannelPipeline pipeline = Channels.pipeline();
+ pipeline.addLast("TestBgpPeerFrameDecoder",
+ peerFrameDecoder);
+ pipeline.addLast("TestBgpPeerChannelHandler",
+ peerChannelHandler);
+ return pipeline;
+ };
peerBootstrap = new ClientBootstrap(channelFactory);
peerBootstrap.setOption("child.keepAlive", true);
diff --git a/framework/src/onos/apps/sdnip/pom.xml b/framework/src/onos/apps/sdnip/pom.xml
index 68b500d5..99314aa8 100644
--- a/framework/src/onos/apps/sdnip/pom.xml
+++ b/framework/src/onos/apps/sdnip/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -69,12 +69,6 @@
</dependency>
<dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-config</artifactId>
- <version>${project.version}</version>
- </dependency>
-
- <dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
</dependency>
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
index 35ff7054..d8d8f45d 100644
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
+++ b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/IntentSynchronizer.java
@@ -887,7 +887,7 @@ public class IntentSynchronizer implements FibListener, IntentRequestListener {
checkNotNull(dstMacAddress);
checkNotNull(srcConnectPoint);
- Set<ConnectPoint> ingressPoints = new HashSet<ConnectPoint>();
+ Set<ConnectPoint> ingressPoints = new HashSet<>();
ingressPoints.add(srcConnectPoint);
IpPrefix dstIpPrefix = dstIpAddress.toIpPrefix();
diff --git a/framework/src/onos/apps/segmentrouting/pom.xml b/framework/src/onos/apps/segmentrouting/pom.xml
index 3ed4c4fe..83ae76db 100644
--- a/framework/src/onos/apps/segmentrouting/pom.xml
+++ b/framework/src/onos/apps/segmentrouting/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>onos-apps</artifactId>
<groupId>org.onosproject</groupId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
index d82eb5ec..ef9d444a 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting;
import com.google.common.collect.Lists;
@@ -33,7 +48,7 @@ public class DeviceConfiguration implements DeviceProperties {
private static final Logger log = LoggerFactory
.getLogger(DeviceConfiguration.class);
- private final List<Integer> allSegmentIds = new ArrayList<Integer>();
+ private final List<Integer> allSegmentIds = new ArrayList<>();
private final HashMap<DeviceId, SegmentRouterInfo> deviceConfigMap = new HashMap<>();
private final NetworkConfigManager configService;
@@ -73,7 +88,7 @@ public class DeviceConfiguration implements DeviceProperties {
info.ip = prefix.address();
info.isEdge = ((SegmentRouterConfig) cfg).isEdgeRouter();
info.subnets = new HashMap<>();
- info.gatewayIps = new HashMap<PortNumber, Ip4Address>();
+ info.gatewayIps = new HashMap<>();
for (Subnet s: ((SegmentRouterConfig) cfg).getSubnets()) {
info.subnets.put(PortNumber.portNumber(s.getPortNo()),
Ip4Prefix.valueOf(s.getSubnetIp()));
@@ -264,8 +279,7 @@ public class DeviceConfiguration implements DeviceProperties {
log.debug("getSubnetGatewayIps for device{} is {}",
deviceId,
deviceConfigMap.get(deviceId).gatewayIps.values());
- return new ArrayList<Ip4Address>(deviceConfigMap.
- get(deviceId).gatewayIps.values());
+ return new ArrayList<>(deviceConfigMap.get(deviceId).gatewayIps.values());
} else {
return null;
}
@@ -282,8 +296,7 @@ public class DeviceConfiguration implements DeviceProperties {
log.debug("getSubnets for device{} is {}",
deviceId,
deviceConfigMap.get(deviceId).subnets.values());
- return new ArrayList<Ip4Prefix>(deviceConfigMap.
- get(deviceId).subnets.values());
+ return new ArrayList<>(deviceConfigMap.get(deviceId).subnets.values());
} else {
return null;
}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java
index cd28fcf9..2e2041c4 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ECMPShortestPathGraph.java
@@ -97,7 +97,7 @@ public class ECMPShortestPathGraph {
}
Integer distance = deviceSearched.get(reachedDevice);
- if ((distance != null) && (distance.intValue() < (currDistance + 1))) {
+ if ((distance != null) && (distance < (currDistance + 1))) {
continue;
}
if (distance == null) {
@@ -109,7 +109,7 @@ public class ECMPShortestPathGraph {
ArrayList<DeviceId> distanceSwArray = distanceDeviceMap
.get(currDistance + 1);
if (distanceSwArray == null) {
- distanceSwArray = new ArrayList<DeviceId>();
+ distanceSwArray = new ArrayList<>();
distanceSwArray.add(reachedDevice);
distanceDeviceMap.put(currDistance + 1, distanceSwArray);
} else {
@@ -120,7 +120,7 @@ public class ECMPShortestPathGraph {
ArrayList<Link> upstreamLinkArray =
upstreamLinks.get(reachedDevice);
if (upstreamLinkArray == null) {
- upstreamLinkArray = new ArrayList<Link>();
+ upstreamLinkArray = new ArrayList<>();
upstreamLinkArray.add(copyDefaultLink(link));
//upstreamLinkArray.add(link);
upstreamLinks.put(reachedDevice, upstreamLinkArray);
@@ -171,7 +171,7 @@ public class ECMPShortestPathGraph {
}
Integer distance = deviceSearched.get(reachedDevice);
- if ((distance != null) && (distance.intValue() < (currDistance + 1))) {
+ if ((distance != null) && (distance < (currDistance + 1))) {
continue;
}
if (distance == null) {
@@ -183,7 +183,7 @@ public class ECMPShortestPathGraph {
ArrayList<DeviceId> distanceSwArray = distanceDeviceMap
.get(currDistance + 1);
if (distanceSwArray == null) {
- distanceSwArray = new ArrayList<DeviceId>();
+ distanceSwArray = new ArrayList<>();
distanceSwArray.add(reachedDevice);
distanceDeviceMap.put(currDistance + 1, distanceSwArray);
} else {
@@ -194,7 +194,7 @@ public class ECMPShortestPathGraph {
ArrayList<Link> upstreamLinkArray =
upstreamLinks.get(reachedDevice);
if (upstreamLinkArray == null) {
- upstreamLinkArray = new ArrayList<Link>();
+ upstreamLinkArray = new ArrayList<>();
upstreamLinkArray.add(copyDefaultLink(link));
upstreamLinks.put(reachedDevice, upstreamLinkArray);
} else {
@@ -234,7 +234,7 @@ public class ECMPShortestPathGraph {
for (Link upstreamLink : upstreamLinks.get(dstDeviceDeviceId)) {
/* Deep clone the path object */
Path sofarPath;
- ArrayList<Link> sofarLinks = new ArrayList<Link>();
+ ArrayList<Link> sofarLinks = new ArrayList<>();
if (path != null && !path.links().isEmpty()) {
sofarLinks.addAll(path.links());
}
@@ -288,12 +288,10 @@ public class ECMPShortestPathGraph {
public HashMap<Integer, HashMap<DeviceId,
ArrayList<Path>>> getCompleteLearnedDeviceesAndPaths() {
- HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new
- HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>>();
+ HashMap<Integer, HashMap<DeviceId, ArrayList<Path>>> pathGraph = new HashMap<>();
for (Integer itrIndx : distanceDeviceMap.keySet()) {
- HashMap<DeviceId, ArrayList<Path>> swMap = new
- HashMap<DeviceId, ArrayList<Path>>();
+ HashMap<DeviceId, ArrayList<Path>> swMap = new HashMap<>();
for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
swMap.put(sw, getECMPPaths(sw));
}
@@ -314,12 +312,10 @@ public class ECMPShortestPathGraph {
public HashMap<Integer, HashMap<DeviceId,
ArrayList<ArrayList<DeviceId>>>> getAllLearnedSwitchesAndVia() {
- HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap =
- new HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>>();
+ HashMap<Integer, HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>> deviceViaMap = new HashMap<>();
for (Integer itrIndx : distanceDeviceMap.keySet()) {
- HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap =
- new HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>>();
+ HashMap<DeviceId, ArrayList<ArrayList<DeviceId>>> swMap = new HashMap<>();
for (DeviceId sw : distanceDeviceMap.get(itrIndx)) {
ArrayList<ArrayList<DeviceId>> swViaArray = new ArrayList<>();
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
index 81d00f50..e37fe52a 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/IpHandler.java
@@ -50,7 +50,7 @@ public class IpHandler {
public IpHandler(SegmentRoutingManager srManager) {
this.srManager = srManager;
this.config = checkNotNull(srManager.deviceConfiguration);
- ipPacketQueue = new ConcurrentHashMap<Ip4Address, ConcurrentLinkedQueue<IPv4>>();
+ ipPacketQueue = new ConcurrentHashMap<>();
}
/**
@@ -104,7 +104,7 @@ public class IpHandler {
Ip4Address destIpAddress = Ip4Address.valueOf(ipPacket.getDestinationAddress());
if (ipPacketQueue.get(destIpAddress) == null) {
- ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<IPv4>();
+ ConcurrentLinkedQueue<IPv4> queue = new ConcurrentLinkedQueue<>();
queue.add(ipPacket);
ipPacketQueue.put(destIpAddress, queue);
} else {
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
index 59fc4ca7..d802be91 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/RoutingRulePopulator.java
@@ -221,7 +221,7 @@ public class RoutingRulePopulator {
Set<DeviceId> nextHops) {
TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
- List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<ForwardingObjective.Builder>();
+ List<ForwardingObjective.Builder> fwdObjBuilders = new ArrayList<>();
// TODO Handle the case of Bos == false
sbuilder.matchMplsLabel(MplsLabel.mplsLabel(config.getSegmentId(destSwId)));
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java
index 6ae0779e..0c7749e6 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
import java.util.ArrayList;
@@ -30,8 +45,8 @@ public class NetworkConfig {
* Default constructor.
*/
public NetworkConfig() {
- switches = new ArrayList<SwitchConfig>();
- links = new ArrayList<LinkConfig>();
+ switches = new ArrayList<>();
+ links = new ArrayList<>();
}
@JsonProperty("comment")
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java
index 91942216..0c0dac86 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
import org.onosproject.net.DeviceId;
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java
index 44e4f1c6..f034f372 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
import java.io.File;
@@ -135,7 +150,7 @@ public class NetworkConfigManager implements NetworkConfigService {
@Override
public List<SwitchConfig> getConfiguredAllowedSwitches() {
- List<SwitchConfig> allowed = new ArrayList<SwitchConfig>();
+ List<SwitchConfig> allowed = new ArrayList<>();
for (SwitchConfig swc : configuredSwitches.values()) {
if (swc.isAllowed()) {
allowed.add(swc);
@@ -146,7 +161,7 @@ public class NetworkConfigManager implements NetworkConfigService {
@Override
public List<LinkConfig> getConfiguredAllowedLinks() {
- List<LinkConfig> allowed = new ArrayList<LinkConfig>();
+ List<LinkConfig> allowed = new ArrayList<>();
for (LinkConfig lkc : configuredLinks.values()) {
if (lkc.isAllowed()) {
allowed.add(lkc);
@@ -244,8 +259,8 @@ public class NetworkConfigManager implements NetworkConfigService {
}
private void validateSwitchConfig(List<SwitchConfig> swConfList) {
- Set<DeviceId> swDpids = new HashSet<DeviceId>();
- Set<String> swNames = new HashSet<String>();
+ Set<DeviceId> swDpids = new HashSet<>();
+ Set<String> swNames = new HashSet<>();
for (SwitchConfig swc : swConfList) {
if (swc.getNodeDpid() == null || swc.getDpid() == null) {
throw new NetworkConfigException.DpidNotSpecified(swc.getName());
@@ -315,9 +330,9 @@ public class NetworkConfigManager implements NetworkConfigService {
*/
public void init() {
loadNetworkConfig();
- configuredSwitches = new ConcurrentHashMap<DeviceId, SwitchConfig>();
- configuredLinks = new ConcurrentHashMap<Link, LinkConfig>();
- nameToDpid = new HashMap<String, DeviceId>();
+ configuredSwitches = new ConcurrentHashMap<>();
+ configuredLinks = new ConcurrentHashMap<>();
+ nameToDpid = new HashMap<>();
parseNetworkConfig();
}
}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
index 56855271..afbb0fcc 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
import java.util.List;
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java
index c66ac3c7..3c51fa9d 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
import java.util.List;
@@ -33,7 +48,7 @@ public class PktLinkConfig extends LinkConfig {
type = lkc.getType();
allowed = lkc.isAllowed();
params = lkc.getParams();
- publishAttributes = new ConcurrentHashMap<String, String>();
+ publishAttributes = new ConcurrentHashMap<>();
parseParams();
validateParams();
setPublishAttributes();
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java
index 4775c77f..c8d4a54a 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java
@@ -1,3 +1,18 @@
+/*
+ * 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.segmentrouting.config;
import java.io.IOException;
@@ -52,9 +67,9 @@ public class SegmentRouterConfig extends SwitchConfig {
this.setLongitude(swc.getLongitude());
this.setParams(swc.getParams());
this.setAllowed(swc.isAllowed());
- publishAttributes = new ConcurrentHashMap<String, String>();
- adjacencySids = new ArrayList<AdjacencySid>();
- subnets = new ArrayList<Subnet>();
+ publishAttributes = new ConcurrentHashMap<>();
+ adjacencySids = new ArrayList<>();
+ subnets = new ArrayList<>();
parseParams();
validateParams();
setPublishAttributes();
@@ -267,7 +282,7 @@ public class SegmentRouterConfig extends SwitchConfig {
} else if (fe.getKey().equals("ports")) {
if (fe.getValue().isArray()) {
Iterator<JsonNode> i = fe.getValue().elements();
- ports = new ArrayList<Integer>();
+ ports = new ArrayList<>();
while (i.hasNext()) {
ports.add(i.next().asInt());
}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java
index 41cf8acc..3dc312df 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultEdgeGroupHandler.java
@@ -69,7 +69,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(neighbors);
log.trace("createGroupsAtEdgeRouter: The size of neighbor powerset "
+ "for sw {} is {}", deviceId, powerSet.size());
- Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+ Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : powerSet) {
if (combo.isEmpty()) {
continue;
@@ -148,7 +148,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
Set<DeviceId> updatedNeighbors) {
Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors);
- Set<DeviceId> tmp = new HashSet<DeviceId>();
+ Set<DeviceId> tmp = new HashSet<>();
tmp.addAll(updatedNeighbors);
tmp.remove(impactedNeighbor);
Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp);
@@ -156,7 +156,7 @@ public class DefaultEdgeGroupHandler extends DefaultGroupHandler {
// Compute the impacted neighbor sets
powerSet.removeAll(tmpPowerSet);
- Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+ Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : powerSet) {
if (combo.isEmpty()) {
continue;
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
index a43a0f09..9bbde2f3 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultGroupHandler.java
@@ -313,13 +313,13 @@ public class DefaultGroupHandler {
return -1;
} else {
log.debug("getNextObjectiveId in device{}: Next objective id {} "
- + "created for {}", deviceId, nextId.intValue(), ns);
+ + "created for {}", deviceId, nextId, ns);
}
} else {
log.trace("getNextObjectiveId in device{}: Next objective id {} "
- + "found for {}", deviceId, nextId.intValue(), ns);
+ + "found for {}", deviceId, nextId, ns);
}
- return nextId.intValue();
+ return nextId;
}
/**
@@ -371,7 +371,7 @@ public class DefaultGroupHandler {
if (devicePortMap.get(neighborId) != null) {
devicePortMap.get(neighborId).add(portToNeighbor);
} else {
- Set<PortNumber> ports = new HashSet<PortNumber>();
+ Set<PortNumber> ports = new HashSet<>();
ports.add(portToNeighbor);
devicePortMap.put(neighborId, ports);
}
@@ -383,8 +383,8 @@ public class DefaultGroupHandler {
}
protected Set<Set<DeviceId>> getPowerSetOfNeighbors(Set<DeviceId> neighbors) {
- List<DeviceId> list = new ArrayList<DeviceId>(neighbors);
- Set<Set<DeviceId>> sets = new HashSet<Set<DeviceId>>();
+ List<DeviceId> list = new ArrayList<>(neighbors);
+ Set<Set<DeviceId>> sets = new HashSet<>();
// get the number of elements in the neighbors
int elements = list.size();
// the number of members of a power set is 2^n
@@ -394,7 +394,7 @@ public class DefaultGroupHandler {
// run a binary counter for the number of power elements
// NOTE: Exclude empty set
for (long i = 1; i < powerElements; i++) {
- Set<DeviceId> neighborSubSet = new HashSet<DeviceId>();
+ Set<DeviceId> neighborSubSet = new HashSet<>();
for (int j = 0; j < elements; j++) {
if ((i >> j) % 2 == 1) {
neighborSubSet.add(list.get(j));
@@ -411,7 +411,7 @@ public class DefaultGroupHandler {
protected List<Integer> getSegmentIdsTobePairedWithNeighborSet(Set<DeviceId> neighbors) {
- List<Integer> nsSegmentIds = new ArrayList<Integer>();
+ List<Integer> nsSegmentIds = new ArrayList<>();
// Always pair up with no edge label
// If (neighbors.size() == 1) {
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java
index e12426c2..3cb73aba 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/DefaultTransitGroupHandler.java
@@ -63,7 +63,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
sets = filterEdgeRouterOnlyPairings(sets);
log.debug("createGroupsAtTransitRouter: The size of neighbor powerset "
+ "for sw {} is {}", deviceId, sets.size());
- Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+ Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : sets) {
if (combo.isEmpty()) {
continue;
@@ -137,7 +137,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
Set<DeviceId> updatedNeighbors) {
Set<Set<DeviceId>> powerSet = getPowerSetOfNeighbors(updatedNeighbors);
- Set<DeviceId> tmp = new HashSet<DeviceId>();
+ Set<DeviceId> tmp = new HashSet<>();
tmp.addAll(updatedNeighbors);
tmp.remove(impactedNeighbor);
Set<Set<DeviceId>> tmpPowerSet = getPowerSetOfNeighbors(tmp);
@@ -146,7 +146,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
powerSet.removeAll(tmpPowerSet);
powerSet = filterEdgeRouterOnlyPairings(powerSet);
- Set<NeighborSet> nsSet = new HashSet<NeighborSet>();
+ Set<NeighborSet> nsSet = new HashSet<>();
for (Set<DeviceId> combo : powerSet) {
if (combo.isEmpty()) {
continue;
@@ -163,7 +163,7 @@ public class DefaultTransitGroupHandler extends DefaultGroupHandler {
}
private Set<Set<DeviceId>> filterEdgeRouterOnlyPairings(Set<Set<DeviceId>> sets) {
- Set<Set<DeviceId>> fiteredSets = new HashSet<Set<DeviceId>>();
+ Set<Set<DeviceId>> fiteredSets = new HashSet<>();
for (Set<DeviceId> deviceSubSet : sets) {
if (deviceSubSet.size() > 1) {
boolean avoidEdgeRouterPairing = true;
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java
index 7ada3224..44715d24 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/grouphandler/NeighborSet.java
@@ -44,7 +44,7 @@ public class NeighborSet {
public NeighborSet(Set<DeviceId> neighbors) {
checkNotNull(neighbors);
this.edgeLabel = NO_EDGE_LABEL;
- this.neighbors = new HashSet<DeviceId>();
+ this.neighbors = new HashSet<>();
this.neighbors.addAll(neighbors);
}
@@ -57,7 +57,7 @@ public class NeighborSet {
public NeighborSet(Set<DeviceId> neighbors, int edgeLabel) {
checkNotNull(neighbors);
this.edgeLabel = edgeLabel;
- this.neighbors = new HashSet<DeviceId>();
+ this.neighbors = new HashSet<>();
this.neighbors.addAll(neighbors);
}
@@ -66,7 +66,7 @@ public class NeighborSet {
*/
public NeighborSet() {
this.edgeLabel = NO_EDGE_LABEL;
- this.neighbors = new HashSet<DeviceId>();
+ this.neighbors = new HashSet<>();
}
/**
diff --git a/framework/src/onos/apps/test/demo/pom.xml b/framework/src/onos/apps/test/demo/pom.xml
index 27dd6675..4b08430d 100644
--- a/framework/src/onos/apps/test/demo/pom.xml
+++ b/framework/src/onos/apps/test/demo/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps-test</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java
index 4197bb60..00956763 100644
--- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java
+++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoAPI.java
@@ -24,7 +24,7 @@ import java.util.Optional;
*/
public interface DemoAPI {
- enum InstallType { MESH, RANDOM };
+ enum InstallType { MESH, RANDOM }
/**
* Tests flow subsystem based on the parameters supplied.
diff --git a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
index 27d1ca96..a408e695 100644
--- a/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
+++ b/framework/src/onos/apps/test/demo/src/main/java/org/onosproject/demo/DemoInstaller.java
@@ -393,13 +393,8 @@ public class DemoInstaller implements DemoAPI {
}
private Predicate<? super Host> hasLocalMaster() {
- return new Predicate<Host>() {
- @Override
- public boolean apply(Host host) {
- return mastershipService.getLocalRole(
- host.location().deviceId()).equals(MastershipRole.MASTER);
- }
- };
+ return host -> mastershipService.getLocalRole(
+ host.location().deviceId()).equals(MastershipRole.MASTER);
}
diff --git a/framework/src/onos/apps/test/distributed-primitives/pom.xml b/framework/src/onos/apps/test/distributed-primitives/pom.xml
index e0376ee7..f77fd57f 100644
--- a/framework/src/onos/apps/test/distributed-primitives/pom.xml
+++ b/framework/src/onos/apps/test/distributed-primitives/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps-test</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -54,7 +54,7 @@
<dependency>
<groupId>org.onosproject</groupId>
<artifactId>onos-core-dist</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java
index d8e8e0be..12c8140a 100644
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java
+++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/CounterTestIncrementCommand.java
@@ -91,9 +91,7 @@ public class CounterTestIncrementCommand extends AbstractShellCommand {
print("%s was updated to %d", counter, result.get(3, TimeUnit.SECONDS));
} catch (InterruptedException e) {
return;
- } catch (ExecutionException e) {
- e.printStackTrace();
- } catch (TimeoutException e) {
+ } catch (ExecutionException | TimeoutException e) {
e.printStackTrace();
}
}
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java
index 0ccc2d3c..204471c2 100644
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java
+++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestAddCommand.java
@@ -44,7 +44,7 @@ public class SetTestAddCommand extends AbstractShellCommand {
String[] values = null;
Set<String> set;
- Set<String> toAdd = new HashSet<String>();
+ Set<String> toAdd = new HashSet<>();
Serializer serializer = Serializer.using(
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java
index 792eab90..fb36a06a 100644
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java
+++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestGetCommand.java
@@ -49,8 +49,8 @@ public class SetTestGetCommand extends AbstractShellCommand {
String[] values = null;
Set<String> set;
- Set<String> toCheck = new HashSet<String>();
- String output = new String();
+ Set<String> toCheck = new HashSet<>();
+ String output = "";
Serializer serializer = Serializer.using(
new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
diff --git a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java
index 7e3a3e82..d1f81e42 100644
--- a/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java
+++ b/framework/src/onos/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/SetTestRemoveCommand.java
@@ -54,7 +54,7 @@ public class SetTestRemoveCommand extends AbstractShellCommand {
String[] values = null;
Set<String> set;
- Set<String> givenValues = new HashSet<String>();
+ Set<String> givenValues = new HashSet<>();
Serializer serializer = Serializer.using(
new KryoNamespace.Builder().register(KryoNamespaces.BASIC).build());
diff --git a/framework/src/onos/apps/test/election/pom.xml b/framework/src/onos/apps/test/election/pom.xml
index 4c18baee..3ceadb4d 100644
--- a/framework/src/onos/apps/test/election/pom.xml
+++ b/framework/src/onos/apps/test/election/pom.xml
@@ -23,7 +23,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps-test</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/test/intent-perf/pom.xml b/framework/src/onos/apps/test/intent-perf/pom.xml
index 7d325394..b837d114 100644
--- a/framework/src/onos/apps/test/intent-perf/pom.xml
+++ b/framework/src/onos/apps/test/intent-perf/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps-test</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/test/messaging-perf/pom.xml b/framework/src/onos/apps/test/messaging-perf/pom.xml
index 66a7c306..28de5b7c 100644
--- a/framework/src/onos/apps/test/messaging-perf/pom.xml
+++ b/framework/src/onos/apps/test/messaging-perf/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps-test</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java b/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
index 24697933..8b41bd5a 100644
--- a/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
+++ b/framework/src/onos/apps/test/messaging-perf/src/main/java/org/onosproject/messagingperf/MessagingPerfApp.java
@@ -1,3 +1,18 @@
+/*
+ * 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.messagingperf;
import static com.google.common.base.Strings.isNullOrEmpty;
diff --git a/framework/src/onos/apps/test/pom.xml b/framework/src/onos/apps/test/pom.xml
index 41e1f201..ead2252e 100644
--- a/framework/src/onos/apps/test/pom.xml
+++ b/framework/src/onos/apps/test/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/virtualbng/pom.xml b/framework/src/onos/apps/virtualbng/pom.xml
index 835272ae..01caa66c 100644
--- a/framework/src/onos/apps/virtualbng/pom.xml
+++ b/framework/src/onos/apps/virtualbng/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/vtn/pom.xml b/framework/src/onos/apps/vtn/pom.xml
index 56aa99d6..fb8fcb13 100644
--- a/framework/src/onos/apps/vtn/pom.xml
+++ b/framework/src/onos/apps/vtn/pom.xml
@@ -1,12 +1,28 @@
<?xml version="1.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.
+ -->
<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
@@ -26,10 +42,6 @@
</dependency>
<dependency>
<groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
<artifactId>onos-incubator-api</artifactId>
</dependency>
<dependency>
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
index 01c98825..ba4745b6 100644
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
+++ b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
@@ -289,12 +289,10 @@ public class VTNManager implements VTNService {
ports.stream()
.filter(p -> p.name()
.equalsIgnoreCase(tunnelName))
- .forEach(p -> {
- programTunnelOut(sw.deviceId(),
- network.segmentationId(), p,
- host.mac(), appId,
- Objective.Operation.ADD);
- });
+ .forEach(p -> programTunnelOut(sw.deviceId(),
+ network.segmentationId(), p,
+ host.mac(), appId,
+ Objective.Operation.ADD));
}
});
programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(),
@@ -355,12 +353,10 @@ public class VTNManager implements VTNService {
ports.stream()
.filter(p -> p.name()
.equalsIgnoreCase(tunnelName))
- .forEach(p -> {
- programTunnelOut(sw.deviceId(),
- segId, p,
- host.mac(), appId,
- Objective.Operation.REMOVE);
- });
+ .forEach(p -> programTunnelOut(sw.deviceId(),
+ segId, p,
+ host.mac(), appId,
+ Objective.Operation.REMOVE));
}
});
programLocalIn(deviceId, segId, inPort, host.mac(),
@@ -379,26 +375,18 @@ public class VTNManager implements VTNService {
Device device = event.subject();
if (Device.Type.CONTROLLER == device.type()
&& DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> {
- onServerDetected(device);
- });
+ backgroundService.execute(() -> onServerDetected(device));
} else if (Device.Type.CONTROLLER == device.type()
&& DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
.type()) {
- backgroundService.execute(() -> {
- onServerVanished(device);
- });
+ backgroundService.execute(() -> onServerVanished(device));
} else if (Device.Type.SWITCH == device.type()
&& DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> {
- onOvsDetected(device);
- });
+ backgroundService.execute(() -> onOvsDetected(device));
} else if (Device.Type.SWITCH == device.type()
&& DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
.type()) {
- backgroundService.execute(() -> {
- onOvsVanished(device);
- });
+ backgroundService.execute(() -> onOvsVanished(device));
} else {
log.info("Do nothing for this device type");
}
@@ -412,13 +400,9 @@ public class VTNManager implements VTNService {
public void event(HostEvent event) {
Host host = event.subject();
if (HostEvent.Type.HOST_ADDED == event.type()) {
- backgroundService.execute(() -> {
- onHostDetected(host);
- });
+ backgroundService.execute(() -> onHostDetected(host));
} else if (HostEvent.Type.HOST_REMOVED == event.type()) {
- backgroundService.execute(() -> {
- onHostVanished(host);
- });
+ backgroundService.execute(() -> onHostVanished(host));
} else if (HostEvent.Type.HOST_UPDATED == event.type()) {
backgroundService.execute(() -> {
onHostVanished(host);
@@ -626,7 +610,7 @@ public class VTNManager implements VTNService {
VirtualPort port = virtualPortService.getPort(portId);
TenantNetwork network = tenantNetworkService
.getNetwork(port.networkId());
- Collection<String> ifaceIds = new HashSet<String>();
+ Collection<String> ifaceIds = new HashSet<>();
Collection<VirtualPort> ports = virtualPortService
.getPorts(network.id());
Sets.newHashSet(ports).stream()
diff --git a/framework/src/onos/apps/vtnrsc/pom.xml b/framework/src/onos/apps/vtnrsc/pom.xml
index ce4e2c8c..0874f6d9 100644
--- a/framework/src/onos/apps/vtnrsc/pom.xml
+++ b/framework/src/onos/apps/vtnrsc/pom.xml
@@ -1,4 +1,19 @@
<?xml version="1.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.
+ -->
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@@ -6,7 +21,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
index 85d1fa9d..3d6ba8e8 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
@@ -1,38 +1,38 @@
-/*
- * 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;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * The continuous IP address range between the start address and the end address for the allocation pools.
- */
-public interface AllocationPool {
-
- /**
- * The start address for the allocation pool.
- *
- * @return startIp
- */
- IpAddress startIp();
-
- /**
- * The end address for the allocation pool.
- *
- * @return endIp
- */
- IpAddress endIp();
-}
+/*
+ * 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;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * The continuous IP address range between the start address and the end address for the allocation pools.
+ */
+public interface AllocationPool {
+
+ /**
+ * The start address for the allocation pool.
+ *
+ * @return startIp
+ */
+ IpAddress startIp();
+
+ /**
+ * The end address for the allocation pool.
+ *
+ * @return endIp
+ */
+ IpAddress endIp();
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
index b60cb676..4e1028d8 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
@@ -1,94 +1,94 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-
-/**
- * Immutable representation of a allowed address pair.
- */
-public final class AllowedAddressPair {
- private final IpAddress ip;
- private final MacAddress mac;
- // Public construction is prohibited
- private AllowedAddressPair(IpAddress ip, MacAddress mac) {
- checkNotNull(ip, "IpAddress cannot be null");
- checkNotNull(mac, "MacAddress cannot be null");
- this.ip = ip;
- this.mac = mac;
- }
- /**
- * Returns the AllowedAddressPair ip address.
- *
- * @return ip address
- */
- public IpAddress ip() {
- return ip;
- }
-
- /**
- * Returns the AllowedAddressPair MAC address.
- *
- * @return MAC address
- */
- public MacAddress mac() {
- return mac;
- }
-
-
- /**
- * Creates a allowedAddressPair using the supplied ipAddress &amp;
- * macAddress.
- *
- * @param ip IP address
- * @param mac MAC address
- * @return AllowedAddressPair
- */
- public static AllowedAddressPair allowedAddressPair(IpAddress ip,
- MacAddress mac) {
- return new AllowedAddressPair(ip, mac);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(ip, mac);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AllowedAddressPair) {
- final AllowedAddressPair that = (AllowedAddressPair) obj;
- return Objects.equals(this.ip, that.ip)
- && Objects.equals(this.mac, that.mac);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("ip", ip).add("mac", mac).toString();
- }
-
-}
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+
+/**
+ * Immutable representation of a allowed address pair.
+ */
+public final class AllowedAddressPair {
+ private final IpAddress ip;
+ private final MacAddress mac;
+ // Public construction is prohibited
+ private AllowedAddressPair(IpAddress ip, MacAddress mac) {
+ checkNotNull(ip, "IpAddress cannot be null");
+ checkNotNull(mac, "MacAddress cannot be null");
+ this.ip = ip;
+ this.mac = mac;
+ }
+ /**
+ * Returns the AllowedAddressPair ip address.
+ *
+ * @return ip address
+ */
+ public IpAddress ip() {
+ return ip;
+ }
+
+ /**
+ * Returns the AllowedAddressPair MAC address.
+ *
+ * @return MAC address
+ */
+ public MacAddress mac() {
+ return mac;
+ }
+
+
+ /**
+ * Creates a allowedAddressPair using the supplied ipAddress &amp;
+ * macAddress.
+ *
+ * @param ip IP address
+ * @param mac MAC address
+ * @return AllowedAddressPair
+ */
+ public static AllowedAddressPair allowedAddressPair(IpAddress ip,
+ MacAddress mac) {
+ return new AllowedAddressPair(ip, mac);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(ip, mac);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof AllowedAddressPair) {
+ final AllowedAddressPair that = (AllowedAddressPair) obj;
+ return Objects.equals(this.ip, that.ip)
+ && Objects.equals(this.mac, that.mac);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("ip", ip).add("mac", mac).toString();
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
index da403876..c715d08a 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
@@ -1,57 +1,72 @@
-package org.onosproject.vtnrsc;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-public final class BindingHostId {
- private final String bindingHostId;
-
- // Public construction is prohibited
- private BindingHostId(String bindingHostId) {
- checkNotNull(bindingHostId, "BindingHosttId cannot be null");
- this.bindingHostId = bindingHostId;
- }
-
- /**
- * Creates a BindingHostId identifier.
- *
- * @param bindingHostId the bindingHostId identifier
- * @return the bindingHostId identifier
- */
- public static BindingHostId bindingHostId(String bindingHostId) {
- return new BindingHostId(bindingHostId);
- }
-
- /**
- * Returns the bindingHostId identifier.
- *
- * @return the bindingHostId identifier
- */
- public String bindingHostId() {
- return bindingHostId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(bindingHostId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof BindingHostId) {
- final BindingHostId that = (BindingHostId) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.bindingHostId, that.bindingHostId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return bindingHostId;
- }
-}
+/*
+ * 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;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+public final class BindingHostId {
+ private final String bindingHostId;
+
+ // Public construction is prohibited
+ private BindingHostId(String bindingHostId) {
+ checkNotNull(bindingHostId, "BindingHosttId cannot be null");
+ this.bindingHostId = bindingHostId;
+ }
+
+ /**
+ * Creates a BindingHostId identifier.
+ *
+ * @param bindingHostId the bindingHostId identifier
+ * @return the bindingHostId identifier
+ */
+ public static BindingHostId bindingHostId(String bindingHostId) {
+ return new BindingHostId(bindingHostId);
+ }
+
+ /**
+ * Returns the bindingHostId identifier.
+ *
+ * @return the bindingHostId identifier
+ */
+ public String bindingHostId() {
+ return bindingHostId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(bindingHostId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof BindingHostId) {
+ final BindingHostId that = (BindingHostId) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.bindingHostId, that.bindingHostId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return bindingHostId;
+ }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
index 6a6a4750..8a480194 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
@@ -1,81 +1,81 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * The continuous IP address range between the start address and the end address
- * for the allocation pools.
- */
-public final class DefaultAllocationPool implements AllocationPool {
-
- private final IpAddress startIp;
- private final IpAddress endIp;
-
- /**
- * Creates an AllocationPool by using the start IP address and the end IP
- * address.
- *
- * @param startIp the start IP address of the allocation pool
- * @param endIp the end IP address of the allocation pool
- */
- public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) {
- checkNotNull(startIp, "StartIp cannot be null");
- checkNotNull(endIp, "EndIp cannot be null");
- this.startIp = startIp;
- this.endIp = endIp;
- }
-
- @Override
- public IpAddress startIp() {
- return startIp;
- }
-
- @Override
- public IpAddress endIp() {
- return endIp;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(startIp, endIp);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultAllocationPool) {
- final DefaultAllocationPool other = (DefaultAllocationPool) obj;
- return Objects.equals(this.startIp, other.startIp)
- && Objects.equals(this.endIp, other.endIp);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("startIp", startIp).add("endIp", endIp)
- .toString();
- }
-}
-
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * The continuous IP address range between the start address and the end address
+ * for the allocation pools.
+ */
+public final class DefaultAllocationPool implements AllocationPool {
+
+ private final IpAddress startIp;
+ private final IpAddress endIp;
+
+ /**
+ * Creates an AllocationPool by using the start IP address and the end IP
+ * address.
+ *
+ * @param startIp the start IP address of the allocation pool
+ * @param endIp the end IP address of the allocation pool
+ */
+ public DefaultAllocationPool(IpAddress startIp, IpAddress endIp) {
+ checkNotNull(startIp, "StartIp cannot be null");
+ checkNotNull(endIp, "EndIp cannot be null");
+ this.startIp = startIp;
+ this.endIp = endIp;
+ }
+
+ @Override
+ public IpAddress startIp() {
+ return startIp;
+ }
+
+ @Override
+ public IpAddress endIp() {
+ return endIp;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(startIp, endIp);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultAllocationPool) {
+ final DefaultAllocationPool other = (DefaultAllocationPool) obj;
+ return Objects.equals(this.startIp, other.startIp)
+ && Objects.equals(this.endIp, other.endIp);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("startIp", startIp).add("endIp", endIp)
+ .toString();
+ }
+}
+
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
index c84ae181..8679100d 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
@@ -1,79 +1,79 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Host route dictionaries for the subnet.
- */
-public final class DefaultHostRoute implements HostRoute {
-
- private final IpAddress nexthop;
- private final IpPrefix destination;
-
- /**
- *
- * Creates a DefaultHostRoute by using the next hop and the destination.
- *
- * @param nexthop of the DefaultHostRoute
- * @param destination of the DefaultHostRoute
- */
- public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {
- this.nexthop = nexthop;
- this.destination = destination;
- }
-
- @Override
- public IpAddress nexthop() {
- return nexthop;
- }
-
- @Override
- public IpPrefix destination() {
- return destination;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("nexthop", nexthop)
- .add("destination", destination).toString();
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(nexthop, destination);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultHostRoute) {
- final DefaultHostRoute other = (DefaultHostRoute) obj;
- return Objects.equals(this.nexthop, other.nexthop)
- && Objects.equals(this.destination, other.destination);
- }
- return false;
- }
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Host route dictionaries for the subnet.
+ */
+public final class DefaultHostRoute implements HostRoute {
+
+ private final IpAddress nexthop;
+ private final IpPrefix destination;
+
+ /**
+ *
+ * Creates a DefaultHostRoute by using the next hop and the destination.
+ *
+ * @param nexthop of the DefaultHostRoute
+ * @param destination of the DefaultHostRoute
+ */
+ public DefaultHostRoute(IpAddress nexthop, IpPrefix destination) {
+ this.nexthop = nexthop;
+ this.destination = destination;
+ }
+
+ @Override
+ public IpAddress nexthop() {
+ return nexthop;
+ }
+
+ @Override
+ public IpPrefix destination() {
+ return destination;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("nexthop", nexthop)
+ .add("destination", destination).toString();
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(nexthop, destination);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultHostRoute) {
+ final DefaultHostRoute other = (DefaultHostRoute) obj;
+ return Objects.equals(this.nexthop, other.nexthop)
+ && Objects.equals(this.destination, other.destination);
+ }
+ return false;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
index 88fabffb..6049b558 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
@@ -1,183 +1,183 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Default implementation of Subnet interface .
- */
-public final class DefaultSubnet implements Subnet {
- private final SubnetId id;
- private final String subnetName;
- private final TenantNetworkId networkId;
- private final TenantId tenantId;
- private final Version ipVersion;
- private final IpPrefix cidr;
- private final IpAddress gatewayIp;
- private final boolean dhcpEnabled;
- private final boolean shared;
- private final Mode ipV6AddressMode;
- private final Mode ipV6RaMode;
- private final Set<HostRoute> hostRoutes;
- private final Set<AllocationPool> allocationPools;
-
- /**
- * Creates a subnet object.
- *
- * @param id subnet identifier
- * @param subnetName the name of subnet
- * @param networkId network identifier
- * @param tenantId tenant identifier
- * @param ipVersion Version of ipv4 or ipv6
- * @param cidr the cidr
- * @param gatewayIp gateway ip
- * @param dhcpEnabled dhcp enabled or not
- * @param shared indicates whether this network is shared across all
- * tenants, By default, only administrative user can change this
- * value
- * @param hostRoutes a collection of host routes
- * @param ipV6AddressMode ipV6AddressMode
- * @param ipV6RaMode ipV6RaMode
- * @param allocationPoolsIt a collection of allocationPools
- */
- public DefaultSubnet(SubnetId id, String subnetName,
- TenantNetworkId networkId, TenantId tenantId,
- Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
- boolean dhcpEnabled, boolean shared,
- Set<HostRoute> hostRoutes, Mode ipV6AddressMode,
- Mode ipV6RaMode,
- Set<AllocationPool> allocationPoolsIt) {
- this.id = id;
- this.subnetName = subnetName;
- this.networkId = networkId;
- this.tenantId = tenantId;
- this.ipVersion = ipVersion;
- this.cidr = cidr;
- this.gatewayIp = gatewayIp;
- this.dhcpEnabled = dhcpEnabled;
- this.shared = shared;
- this.ipV6AddressMode = ipV6AddressMode;
- this.ipV6RaMode = ipV6RaMode;
- this.hostRoutes = hostRoutes;
- this.allocationPools = allocationPoolsIt;
- }
-
- @Override
- public SubnetId id() {
- return id;
- }
-
- @Override
- public String subnetName() {
- return subnetName;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public Version ipVersion() {
- return ipVersion;
- }
-
- @Override
- public IpPrefix cidr() {
- return cidr;
- }
-
- @Override
- public IpAddress gatewayIp() {
- return gatewayIp;
- }
-
- @Override
- public boolean dhcpEnabled() {
- return dhcpEnabled;
- }
-
- @Override
- public boolean shared() {
- return shared;
- }
-
- @Override
- public Iterable<HostRoute> hostRoutes() {
- return hostRoutes;
- }
-
- @Override
- public Mode ipV6AddressMode() {
- return ipV6AddressMode;
- }
-
- @Override
- public Mode ipV6RaMode() {
- return ipV6RaMode;
- }
-
- @Override
- public Iterable<AllocationPool> allocationPools() {
- return allocationPools;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,
- dhcpEnabled, shared, tenantId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultSubnet) {
- final DefaultSubnet that = (DefaultSubnet) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.subnetName, that.subnetName)
- && Objects.equals(this.ipVersion, that.ipVersion)
- && Objects.equals(this.cidr, that.cidr)
- && Objects.equals(this.shared, that.shared)
- && Objects.equals(this.gatewayIp, that.gatewayIp)
- && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("subnetName", subnetName)
- .add("ipVersion", ipVersion).add("cidr", cidr)
- .add("shared", shared).add("gatewayIp", gatewayIp)
- .add("dhcpEnabled", dhcpEnabled).toString();
- }
-
-}
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+import java.util.Set;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpAddress.Version;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Default implementation of Subnet interface .
+ */
+public final class DefaultSubnet implements Subnet {
+ private final SubnetId id;
+ private final String subnetName;
+ private final TenantNetworkId networkId;
+ private final TenantId tenantId;
+ private final Version ipVersion;
+ private final IpPrefix cidr;
+ private final IpAddress gatewayIp;
+ private final boolean dhcpEnabled;
+ private final boolean shared;
+ private final Mode ipV6AddressMode;
+ private final Mode ipV6RaMode;
+ private final Set<HostRoute> hostRoutes;
+ private final Set<AllocationPool> allocationPools;
+
+ /**
+ * Creates a subnet object.
+ *
+ * @param id subnet identifier
+ * @param subnetName the name of subnet
+ * @param networkId network identifier
+ * @param tenantId tenant identifier
+ * @param ipVersion Version of ipv4 or ipv6
+ * @param cidr the cidr
+ * @param gatewayIp gateway ip
+ * @param dhcpEnabled dhcp enabled or not
+ * @param shared indicates whether this network is shared across all
+ * tenants, By default, only administrative user can change this
+ * value
+ * @param hostRoutes a collection of host routes
+ * @param ipV6AddressMode ipV6AddressMode
+ * @param ipV6RaMode ipV6RaMode
+ * @param allocationPoolsIt a collection of allocationPools
+ */
+ public DefaultSubnet(SubnetId id, String subnetName,
+ TenantNetworkId networkId, TenantId tenantId,
+ Version ipVersion, IpPrefix cidr, IpAddress gatewayIp,
+ boolean dhcpEnabled, boolean shared,
+ Set<HostRoute> hostRoutes, Mode ipV6AddressMode,
+ Mode ipV6RaMode,
+ Set<AllocationPool> allocationPoolsIt) {
+ this.id = id;
+ this.subnetName = subnetName;
+ this.networkId = networkId;
+ this.tenantId = tenantId;
+ this.ipVersion = ipVersion;
+ this.cidr = cidr;
+ this.gatewayIp = gatewayIp;
+ this.dhcpEnabled = dhcpEnabled;
+ this.shared = shared;
+ this.ipV6AddressMode = ipV6AddressMode;
+ this.ipV6RaMode = ipV6RaMode;
+ this.hostRoutes = hostRoutes;
+ this.allocationPools = allocationPoolsIt;
+ }
+
+ @Override
+ public SubnetId id() {
+ return id;
+ }
+
+ @Override
+ public String subnetName() {
+ return subnetName;
+ }
+
+ @Override
+ public TenantNetworkId networkId() {
+ return networkId;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public Version ipVersion() {
+ return ipVersion;
+ }
+
+ @Override
+ public IpPrefix cidr() {
+ return cidr;
+ }
+
+ @Override
+ public IpAddress gatewayIp() {
+ return gatewayIp;
+ }
+
+ @Override
+ public boolean dhcpEnabled() {
+ return dhcpEnabled;
+ }
+
+ @Override
+ public boolean shared() {
+ return shared;
+ }
+
+ @Override
+ public Iterable<HostRoute> hostRoutes() {
+ return hostRoutes;
+ }
+
+ @Override
+ public Mode ipV6AddressMode() {
+ return ipV6AddressMode;
+ }
+
+ @Override
+ public Mode ipV6RaMode() {
+ return ipV6RaMode;
+ }
+
+ @Override
+ public Iterable<AllocationPool> allocationPools() {
+ return allocationPools;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, subnetName, ipVersion, cidr, gatewayIp,
+ dhcpEnabled, shared, tenantId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultSubnet) {
+ final DefaultSubnet that = (DefaultSubnet) obj;
+ return Objects.equals(this.id, that.id)
+ && Objects.equals(this.subnetName, that.subnetName)
+ && Objects.equals(this.ipVersion, that.ipVersion)
+ && Objects.equals(this.cidr, that.cidr)
+ && Objects.equals(this.shared, that.shared)
+ && Objects.equals(this.gatewayIp, that.gatewayIp)
+ && Objects.equals(this.dhcpEnabled, that.dhcpEnabled);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("subnetName", subnetName)
+ .add("ipVersion", ipVersion).add("cidr", cidr)
+ .add("shared", shared).add("gatewayIp", gatewayIp)
+ .add("dhcpEnabled", dhcpEnabled).toString();
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
index 21650789..8c941ea2 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
@@ -1,160 +1,160 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Objects;
-
-/**
- * Default implementation of TenantNetwork interface.
- */
-public final class DefaultTenantNetwork implements TenantNetwork {
- private final TenantNetworkId id;
- private final String name;
- private final boolean adminStateUp;
- private final State state;
- private final boolean shared;
- private final Type type;
- private final TenantId tenantId;
- private final boolean routerExternal;
- private final PhysicalNetwork physicalNetwork;
- private final SegmentationId segmentationId;
-
- /**
- * Creates a neutronNetwork element attributed to the specified provider.
- *
- * @param id network identifier
- * @param name the network name
- * @param adminStateUp administrative state of the network
- * @param state the network state
- * @param shared indicates whether this network is shared across all
- * tenants, By default, only administrative user can change this
- * value
- * @param tenantId tenant identifier
- * @param routerExternal network routerExternal
- * @param type the network type
- * @param physicalNetwork physicalNetwork identifier
- * @param segmentationId segmentation identifier
- */
- public DefaultTenantNetwork(TenantNetworkId id, String name,
- boolean adminStateUp, State state,
- boolean shared, TenantId tenantId,
- boolean routerExternal, Type type,
- PhysicalNetwork physicalNetwork,
- SegmentationId segmentationId) {
- this.id = id;
- this.name = name;
- this.adminStateUp = adminStateUp;
- this.state = state;
- this.shared = shared;
- this.type = type;
- this.tenantId = tenantId;
- this.routerExternal = routerExternal;
- this.physicalNetwork = physicalNetwork;
- this.segmentationId = segmentationId;
- }
-
- @Override
- public TenantNetworkId id() {
- return id;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public State state() {
- return state;
- }
-
- @Override
- public boolean shared() {
- return shared;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public boolean routerExternal() {
- return routerExternal;
- }
-
- @Override
- public Type type() {
- return type;
- }
-
- @Override
- public PhysicalNetwork physicalNetwork() {
- return physicalNetwork;
- }
-
- @Override
- public SegmentationId segmentationId() {
- return segmentationId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
- routerExternal, type, physicalNetwork,
- segmentationId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultTenantNetwork) {
- final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.shared, that.shared)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.routerExternal, that.routerExternal)
- && Objects.equals(this.type, that.type)
- && Objects.equals(this.physicalNetwork,
- that.physicalNetwork)
- && Objects.equals(this.segmentationId, that.segmentationId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("name", name)
- .add("adminStateUp", adminStateUp).add("state", state)
- .add("shared", shared).add("tenantId", tenantId)
- .add("routeExternal", routerExternal).add("type", type)
- .add("physicalNetwork", physicalNetwork)
- .add("segmentationId", segmentationId).toString();
- }
-
-}
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Objects;
+
+/**
+ * Default implementation of TenantNetwork interface.
+ */
+public final class DefaultTenantNetwork implements TenantNetwork {
+ private final TenantNetworkId id;
+ private final String name;
+ private final boolean adminStateUp;
+ private final State state;
+ private final boolean shared;
+ private final Type type;
+ private final TenantId tenantId;
+ private final boolean routerExternal;
+ private final PhysicalNetwork physicalNetwork;
+ private final SegmentationId segmentationId;
+
+ /**
+ * Creates a neutronNetwork element attributed to the specified provider.
+ *
+ * @param id network identifier
+ * @param name the network name
+ * @param adminStateUp administrative state of the network
+ * @param state the network state
+ * @param shared indicates whether this network is shared across all
+ * tenants, By default, only administrative user can change this
+ * value
+ * @param tenantId tenant identifier
+ * @param routerExternal network routerExternal
+ * @param type the network type
+ * @param physicalNetwork physicalNetwork identifier
+ * @param segmentationId segmentation identifier
+ */
+ public DefaultTenantNetwork(TenantNetworkId id, String name,
+ boolean adminStateUp, State state,
+ boolean shared, TenantId tenantId,
+ boolean routerExternal, Type type,
+ PhysicalNetwork physicalNetwork,
+ SegmentationId segmentationId) {
+ this.id = id;
+ this.name = name;
+ this.adminStateUp = adminStateUp;
+ this.state = state;
+ this.shared = shared;
+ this.type = type;
+ this.tenantId = tenantId;
+ this.routerExternal = routerExternal;
+ this.physicalNetwork = physicalNetwork;
+ this.segmentationId = segmentationId;
+ }
+
+ @Override
+ public TenantNetworkId id() {
+ return id;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public boolean adminStateUp() {
+ return adminStateUp;
+ }
+
+ @Override
+ public State state() {
+ return state;
+ }
+
+ @Override
+ public boolean shared() {
+ return shared;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public boolean routerExternal() {
+ return routerExternal;
+ }
+
+ @Override
+ public Type type() {
+ return type;
+ }
+
+ @Override
+ public PhysicalNetwork physicalNetwork() {
+ return physicalNetwork;
+ }
+
+ @Override
+ public SegmentationId segmentationId() {
+ return segmentationId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, name, adminStateUp, state, shared, tenantId,
+ routerExternal, type, physicalNetwork,
+ segmentationId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultTenantNetwork) {
+ final DefaultTenantNetwork that = (DefaultTenantNetwork) obj;
+ return Objects.equals(this.id, that.id)
+ && Objects.equals(this.name, that.name)
+ && Objects.equals(this.adminStateUp, that.adminStateUp)
+ && Objects.equals(this.state, that.state)
+ && Objects.equals(this.shared, that.shared)
+ && Objects.equals(this.tenantId, that.tenantId)
+ && Objects.equals(this.routerExternal, that.routerExternal)
+ && Objects.equals(this.type, that.type)
+ && Objects.equals(this.physicalNetwork,
+ that.physicalNetwork)
+ && Objects.equals(this.segmentationId, that.segmentationId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("name", name)
+ .add("adminStateUp", adminStateUp).add("state", state)
+ .add("shared", shared).add("tenantId", tenantId)
+ .add("routeExternal", routerExternal).add("type", type)
+ .add("physicalNetwork", physicalNetwork)
+ .add("segmentationId", segmentationId).toString();
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
index adf3a3a3..9ee85da7 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
@@ -1,229 +1,229 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-/**
- * Default implementation of VirtualPort interface .
- */
-public final class DefaultVirtualPort implements VirtualPort {
- private final VirtualPortId id;
- private final TenantNetworkId networkId;
- private final Boolean adminStateUp;
- private final String name;
- private final State state;
- private final MacAddress macAddress;
- private final TenantId tenantId;
- private final String deviceOwner;
- private final DeviceId deviceId;
- private final Set<FixedIp> fixedIps;
- private final BindingHostId bindingHostId;
- private final String bindingVnicType;
- private final String bindingVifType;
- private final String bindingVifDetails;
- private final Set<AllowedAddressPair> allowedAddressPairs;
- private final Set<SecurityGroup> securityGroups;
-
- /**
- * Creates a VirtualPort object.
- *
- * @param id the virtual port identifier
- * @param networkId the network identifier
- * @param adminStateUp adminStateup true or false
- * @param strMap the map of properties of virtual port
- * @param state virtual port state
- * @param macAddress the MAC address
- * @param tenantId the tenant identifier
- * @param deviceId the device identifier
- * @param fixedIps set of fixed IP
- * @param bindingHostId the binding host identifier
- * @param allowedAddressPairs the collection of allowdeAddressPairs
- * @param securityGroups the collection of securityGroups
- */
- public DefaultVirtualPort(VirtualPortId id,
- TenantNetworkId networkId,
- Boolean adminStateUp,
- Map<String, String> strMap,
- State state,
- MacAddress macAddress,
- TenantId tenantId,
- DeviceId deviceId,
- Set<FixedIp> fixedIps,
- BindingHostId bindingHostId,
- Set<AllowedAddressPair> allowedAddressPairs,
- Set<SecurityGroup> securityGroups) {
- this.id = id;
- this.networkId = networkId;
- this.adminStateUp = adminStateUp;
- this.name = strMap.get("name");
- this.state = state;
- this.macAddress = macAddress;
- this.tenantId = tenantId;
- this.deviceOwner = strMap.get("deviceOwner");
- this.deviceId = deviceId;
- this.fixedIps = fixedIps;
- this.bindingHostId = bindingHostId;
- this.bindingVnicType = strMap.get("bindingVnicType");
- this.bindingVifType = strMap.get("bindingVifType");
- this.bindingVifDetails = strMap.get("bindingVifDetails");
- this.allowedAddressPairs = allowedAddressPairs;
- this.securityGroups = securityGroups;
- }
-
- @Override
- public VirtualPortId portId() {
- return id;
- }
-
- @Override
- public TenantNetworkId networkId() {
- return networkId;
- }
-
- @Override
- public String name() {
- return name;
- }
-
- @Override
- public boolean adminStateUp() {
- return adminStateUp;
- }
-
- @Override
- public State state() {
- return state;
- }
-
- @Override
- public MacAddress macAddress() {
- return macAddress;
- }
-
- @Override
- public TenantId tenantId() {
- return tenantId;
- }
-
- @Override
- public DeviceId deviceId() {
- return deviceId;
- }
-
- @Override
- public String deviceOwner() {
- return deviceOwner;
- }
-
- @Override
- public Collection<AllowedAddressPair> allowedAddressPairs() {
- return allowedAddressPairs;
- }
-
- @Override
- public Set<FixedIp> fixedIps() {
- return fixedIps;
- }
-
- @Override
- public BindingHostId bindingHostId() {
- return bindingHostId;
- }
-
- @Override
- public String bindingVnicType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifType() {
- return bindingVifType;
- }
-
- @Override
- public String bindingVifDetails() {
- return bindingVifDetails;
- }
-
- @Override
- public Collection<SecurityGroup> securityGroups() {
- return securityGroups;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(id, networkId, adminStateUp, name, state,
- macAddress, tenantId, deviceId, deviceOwner,
- allowedAddressPairs, fixedIps, bindingHostId,
- bindingVnicType, bindingVifType, bindingVifDetails,
- securityGroups);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof DefaultVirtualPort) {
- final DefaultVirtualPort that = (DefaultVirtualPort) obj;
- return Objects.equals(this.id, that.id)
- && Objects.equals(this.networkId, that.networkId)
- && Objects.equals(this.adminStateUp, that.adminStateUp)
- && Objects.equals(this.state, that.state)
- && Objects.equals(this.name, that.name)
- && Objects.equals(this.tenantId, that.tenantId)
- && Objects.equals(this.macAddress, that.macAddress)
- && Objects.equals(this.deviceId, that.deviceId)
- && Objects.equals(this.deviceOwner, that.deviceOwner)
- && Objects.equals(this.allowedAddressPairs,
- that.allowedAddressPairs)
- && Objects.equals(this.fixedIps, that.fixedIps)
- && Objects.equals(this.bindingHostId, that.bindingHostId)
- && Objects.equals(this.bindingVifDetails,
- that.bindingVifDetails)
- && Objects.equals(this.bindingVifType, that.bindingVifType)
- && Objects.equals(this.bindingVnicType,
- that.bindingVnicType)
- && Objects.equals(this.securityGroups, that.securityGroups);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("id", id).add("network_id", networkId)
- .add("adminStateUp", adminStateUp).add("state", state)
- .add("name", name).add("state", state)
- .add("macAddress", macAddress).add("tenantId", tenantId)
- .add("deviced", deviceId).add("deviceOwner", deviceOwner)
- .add("allowedAddressPairs", allowedAddressPairs)
- .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
- .add("bindingVnicType", bindingVnicType)
- .add("bindingVifDetails", bindingVifDetails)
- .add("bindingVifType", bindingVifType)
- .add("securityGroups", securityGroups).toString();
- }
-
-}
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Set;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Default implementation of VirtualPort interface .
+ */
+public final class DefaultVirtualPort implements VirtualPort {
+ private final VirtualPortId id;
+ private final TenantNetworkId networkId;
+ private final Boolean adminStateUp;
+ private final String name;
+ private final State state;
+ private final MacAddress macAddress;
+ private final TenantId tenantId;
+ private final String deviceOwner;
+ private final DeviceId deviceId;
+ private final Set<FixedIp> fixedIps;
+ private final BindingHostId bindingHostId;
+ private final String bindingVnicType;
+ private final String bindingVifType;
+ private final String bindingVifDetails;
+ private final Set<AllowedAddressPair> allowedAddressPairs;
+ private final Set<SecurityGroup> securityGroups;
+
+ /**
+ * Creates a VirtualPort object.
+ *
+ * @param id the virtual port identifier
+ * @param networkId the network identifier
+ * @param adminStateUp adminStateup true or false
+ * @param strMap the map of properties of virtual port
+ * @param state virtual port state
+ * @param macAddress the MAC address
+ * @param tenantId the tenant identifier
+ * @param deviceId the device identifier
+ * @param fixedIps set of fixed IP
+ * @param bindingHostId the binding host identifier
+ * @param allowedAddressPairs the collection of allowdeAddressPairs
+ * @param securityGroups the collection of securityGroups
+ */
+ public DefaultVirtualPort(VirtualPortId id,
+ TenantNetworkId networkId,
+ Boolean adminStateUp,
+ Map<String, String> strMap,
+ State state,
+ MacAddress macAddress,
+ TenantId tenantId,
+ DeviceId deviceId,
+ Set<FixedIp> fixedIps,
+ BindingHostId bindingHostId,
+ Set<AllowedAddressPair> allowedAddressPairs,
+ Set<SecurityGroup> securityGroups) {
+ this.id = id;
+ this.networkId = networkId;
+ this.adminStateUp = adminStateUp;
+ this.name = strMap.get("name");
+ this.state = state;
+ this.macAddress = macAddress;
+ this.tenantId = tenantId;
+ this.deviceOwner = strMap.get("deviceOwner");
+ this.deviceId = deviceId;
+ this.fixedIps = fixedIps;
+ this.bindingHostId = bindingHostId;
+ this.bindingVnicType = strMap.get("bindingVnicType");
+ this.bindingVifType = strMap.get("bindingVifType");
+ this.bindingVifDetails = strMap.get("bindingVifDetails");
+ this.allowedAddressPairs = allowedAddressPairs;
+ this.securityGroups = securityGroups;
+ }
+
+ @Override
+ public VirtualPortId portId() {
+ return id;
+ }
+
+ @Override
+ public TenantNetworkId networkId() {
+ return networkId;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public boolean adminStateUp() {
+ return adminStateUp;
+ }
+
+ @Override
+ public State state() {
+ return state;
+ }
+
+ @Override
+ public MacAddress macAddress() {
+ return macAddress;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public DeviceId deviceId() {
+ return deviceId;
+ }
+
+ @Override
+ public String deviceOwner() {
+ return deviceOwner;
+ }
+
+ @Override
+ public Collection<AllowedAddressPair> allowedAddressPairs() {
+ return allowedAddressPairs;
+ }
+
+ @Override
+ public Set<FixedIp> fixedIps() {
+ return fixedIps;
+ }
+
+ @Override
+ public BindingHostId bindingHostId() {
+ return bindingHostId;
+ }
+
+ @Override
+ public String bindingVnicType() {
+ return bindingVifType;
+ }
+
+ @Override
+ public String bindingVifType() {
+ return bindingVifType;
+ }
+
+ @Override
+ public String bindingVifDetails() {
+ return bindingVifDetails;
+ }
+
+ @Override
+ public Collection<SecurityGroup> securityGroups() {
+ return securityGroups;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, networkId, adminStateUp, name, state,
+ macAddress, tenantId, deviceId, deviceOwner,
+ allowedAddressPairs, fixedIps, bindingHostId,
+ bindingVnicType, bindingVifType, bindingVifDetails,
+ securityGroups);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultVirtualPort) {
+ final DefaultVirtualPort that = (DefaultVirtualPort) obj;
+ return Objects.equals(this.id, that.id)
+ && Objects.equals(this.networkId, that.networkId)
+ && Objects.equals(this.adminStateUp, that.adminStateUp)
+ && Objects.equals(this.state, that.state)
+ && Objects.equals(this.name, that.name)
+ && Objects.equals(this.tenantId, that.tenantId)
+ && Objects.equals(this.macAddress, that.macAddress)
+ && Objects.equals(this.deviceId, that.deviceId)
+ && Objects.equals(this.deviceOwner, that.deviceOwner)
+ && Objects.equals(this.allowedAddressPairs,
+ that.allowedAddressPairs)
+ && Objects.equals(this.fixedIps, that.fixedIps)
+ && Objects.equals(this.bindingHostId, that.bindingHostId)
+ && Objects.equals(this.bindingVifDetails,
+ that.bindingVifDetails)
+ && Objects.equals(this.bindingVifType, that.bindingVifType)
+ && Objects.equals(this.bindingVnicType,
+ that.bindingVnicType)
+ && Objects.equals(this.securityGroups, that.securityGroups);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("id", id).add("network_id", networkId)
+ .add("adminStateUp", adminStateUp).add("state", state)
+ .add("name", name).add("state", state)
+ .add("macAddress", macAddress).add("tenantId", tenantId)
+ .add("deviced", deviceId).add("deviceOwner", deviceOwner)
+ .add("allowedAddressPairs", allowedAddressPairs)
+ .add("fixedIp", fixedIps).add("bindingHostId", bindingHostId)
+ .add("bindingVnicType", bindingVnicType)
+ .add("bindingVifDetails", bindingVifDetails)
+ .add("bindingVifType", bindingVifType)
+ .add("securityGroups", securityGroups).toString();
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
index dcfb72ac..c6569a7b 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
@@ -1,93 +1,93 @@
-/*
- * 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;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-import org.onlab.packet.IpAddress;
-
-/**
- * Immutable representation of a IP address for the port, Include the IP address
- * and subnet identity.
- */
-public final class FixedIp {
- private final SubnetId subnetId;
- private final IpAddress ip;
- // Public construction is prohibited
- private FixedIp(SubnetId subnetId, IpAddress ip) {
- checkNotNull(subnetId, "SubnetId cannot be null");
- checkNotNull(ip, "IpAddress cannot be null");
- this.subnetId = subnetId;
- this.ip = ip;
- }
-
- /**
- * Returns the FixedIp subnet identifier.
- *
- * @return subnet identifier
- */
- public SubnetId subnetId() {
- return subnetId;
- }
-
- /**
- * Returns the FixedIp IP address.
- *
- * @return IP address
- */
- public IpAddress ip() {
- return ip;
- }
-
- /**
- * Creates a fixed ip using the supplied fixedIp.
- *
- * @param subnetId subnet identity
- * @param ip IP address
- * @return FixedIp
- */
- public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {
- return new FixedIp(subnetId, ip);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subnetId, ip);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof FixedIp) {
- final FixedIp that = (FixedIp) obj;
- return Objects.equals(this.subnetId, that.subnetId)
- && Objects.equals(this.ip, that.ip);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)
- .toString();
- }
-
-}
+/*
+ * 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;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.packet.IpAddress;
+
+/**
+ * Immutable representation of a IP address for the port, Include the IP address
+ * and subnet identity.
+ */
+public final class FixedIp {
+ private final SubnetId subnetId;
+ private final IpAddress ip;
+ // Public construction is prohibited
+ private FixedIp(SubnetId subnetId, IpAddress ip) {
+ checkNotNull(subnetId, "SubnetId cannot be null");
+ checkNotNull(ip, "IpAddress cannot be null");
+ this.subnetId = subnetId;
+ this.ip = ip;
+ }
+
+ /**
+ * Returns the FixedIp subnet identifier.
+ *
+ * @return subnet identifier
+ */
+ public SubnetId subnetId() {
+ return subnetId;
+ }
+
+ /**
+ * Returns the FixedIp IP address.
+ *
+ * @return IP address
+ */
+ public IpAddress ip() {
+ return ip;
+ }
+
+ /**
+ * Creates a fixed ip using the supplied fixedIp.
+ *
+ * @param subnetId subnet identity
+ * @param ip IP address
+ * @return FixedIp
+ */
+ public static FixedIp fixedIp(SubnetId subnetId, IpAddress ip) {
+ return new FixedIp(subnetId, ip);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(subnetId, ip);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof FixedIp) {
+ final FixedIp that = (FixedIp) obj;
+ return Objects.equals(this.subnetId, that.subnetId)
+ && Objects.equals(this.ip, that.ip);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("subnetId", subnetId).add("ip", ip)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
index 74c28165..b18cb950 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
@@ -1,39 +1,39 @@
-/*
- * 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;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Host route dictionaries for the subnet.
- */
-public interface HostRoute {
-
- /**
- * Returns the next hop address.
- *
- * @return next hop address
- */
- IpAddress nexthop();
-
- /**
- * Returns the destination address.
- *
- * @return destination address
- */
- IpPrefix destination();
-}
+/*
+ * 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;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Host route dictionaries for the subnet.
+ */
+public interface HostRoute {
+
+ /**
+ * Returns the next hop address.
+ *
+ * @return next hop address
+ */
+ IpAddress nexthop();
+
+ /**
+ * Returns the destination address.
+ *
+ * @return destination address
+ */
+ IpPrefix destination();
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
index 6a0c5cb6..e96e666a 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
@@ -1,78 +1,78 @@
-/*
- * 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;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a physical network identity.
- */
-public final class PhysicalNetwork {
-
- private final String physicalNetwork;
-
- // Public construction is prohibited
- private PhysicalNetwork(String physicalNetwork) {
- checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
- this.physicalNetwork = physicalNetwork;
- }
-
- /**
- * Creates a PhysicalNetwork object.
- *
- * @param physicalNetwork physical network
- * @return physical network
- */
- public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
- return new PhysicalNetwork(physicalNetwork);
- }
-
- /**
- * Returns a physicalNetwork.
- *
- * @return physical network
- */
- public String physicalNetwork() {
- return physicalNetwork;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(physicalNetwork);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof PhysicalNetwork) {
- final PhysicalNetwork that = (PhysicalNetwork) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.physicalNetwork,
- that.physicalNetwork);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return physicalNetwork;
- }
-
-}
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a physical network identity.
+ */
+public final class PhysicalNetwork {
+
+ private final String physicalNetwork;
+
+ // Public construction is prohibited
+ private PhysicalNetwork(String physicalNetwork) {
+ checkNotNull(physicalNetwork, "PhysicalNetwork cannot be null");
+ this.physicalNetwork = physicalNetwork;
+ }
+
+ /**
+ * Creates a PhysicalNetwork object.
+ *
+ * @param physicalNetwork physical network
+ * @return physical network
+ */
+ public static PhysicalNetwork physicalNetwork(String physicalNetwork) {
+ return new PhysicalNetwork(physicalNetwork);
+ }
+
+ /**
+ * Returns a physicalNetwork.
+ *
+ * @return physical network
+ */
+ public String physicalNetwork() {
+ return physicalNetwork;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(physicalNetwork);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof PhysicalNetwork) {
+ final PhysicalNetwork that = (PhysicalNetwork) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.physicalNetwork,
+ that.physicalNetwork);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return physicalNetwork;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
index 7f098064..9ec1dc63 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
@@ -1,77 +1,77 @@
-/*
- * 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;
-
-import java.util.Objects;
-
-import static com.google.common.base.MoreObjects.toStringHelper;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a security group.
- */
-public final class SecurityGroup {
- private final String securityGroup;
-
- /**
- * Returns the securityGroup.
- *
- * @return securityGroup
- */
- public String securityGroup() {
- return securityGroup;
- }
- // Public construction is prohibited
- private SecurityGroup(String securityGroup) {
- checkNotNull(securityGroup, "SecurityGroup cannot be null");
- this.securityGroup = securityGroup;
- }
-
- /**
- * Creates a securityGroup using the supplied securityGroup.
- *
- * @param securityGroup security group
- * @return securityGroup
- */
- public static SecurityGroup securityGroup(String securityGroup) {
- return new SecurityGroup(securityGroup);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(securityGroup);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SecurityGroup) {
- final SecurityGroup that = (SecurityGroup) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.securityGroup, that.securityGroup);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return toStringHelper(this).add("securityGroup", securityGroup)
- .toString();
- }
-
-}
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a security group.
+ */
+public final class SecurityGroup {
+ private final String securityGroup;
+
+ /**
+ * Returns the securityGroup.
+ *
+ * @return securityGroup
+ */
+ public String securityGroup() {
+ return securityGroup;
+ }
+ // Public construction is prohibited
+ private SecurityGroup(String securityGroup) {
+ checkNotNull(securityGroup, "SecurityGroup cannot be null");
+ this.securityGroup = securityGroup;
+ }
+
+ /**
+ * Creates a securityGroup using the supplied securityGroup.
+ *
+ * @param securityGroup security group
+ * @return securityGroup
+ */
+ public static SecurityGroup securityGroup(String securityGroup) {
+ return new SecurityGroup(securityGroup);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(securityGroup);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SecurityGroup) {
+ final SecurityGroup that = (SecurityGroup) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.securityGroup, that.securityGroup);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("securityGroup", securityGroup)
+ .toString();
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
index 69f9dce7..a076265f 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
@@ -1,77 +1,77 @@
-/*
- * 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;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a Segmentation identifier.
- */
-public final class SegmentationId {
-
- private final String segmentationId;
-
- // Public construction is prohibited
- private SegmentationId(String segmentationId) {
- checkNotNull(segmentationId, "SegmentationId cannot be null");
- this.segmentationId = segmentationId;
- }
-
- /**
- * Creates a SegmentationId object.
- *
- * @param segmentationId segmentation identifier
- * @return SegmentationId
- */
- public static SegmentationId segmentationId(String segmentationId) {
- return new SegmentationId(segmentationId);
- }
-
- /**
- * Returns the segmentation identifier.
- *
- * @return segmentationId
- */
- public String segmentationId() {
- return segmentationId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(segmentationId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SegmentationId) {
- final SegmentationId that = (SegmentationId) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.segmentationId, that.segmentationId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return segmentationId;
- }
-
-}
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a Segmentation identifier.
+ */
+public final class SegmentationId {
+
+ private final String segmentationId;
+
+ // Public construction is prohibited
+ private SegmentationId(String segmentationId) {
+ checkNotNull(segmentationId, "SegmentationId cannot be null");
+ this.segmentationId = segmentationId;
+ }
+
+ /**
+ * Creates a SegmentationId object.
+ *
+ * @param segmentationId segmentation identifier
+ * @return SegmentationId
+ */
+ public static SegmentationId segmentationId(String segmentationId) {
+ return new SegmentationId(segmentationId);
+ }
+
+ /**
+ * Returns the segmentation identifier.
+ *
+ * @return segmentationId
+ */
+ public String segmentationId() {
+ return segmentationId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(segmentationId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SegmentationId) {
+ final SegmentationId that = (SegmentationId) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.segmentationId, that.segmentationId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return segmentationId;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
index 1104d7ee..f563a78f 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
@@ -1,129 +1,129 @@
-/*
- *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;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-
-/**
- * Representation of a subnet.
- */
-public interface Subnet {
-
- /**
- * Coarse classification of the type of the ipV6Mode.
- */
- public enum Mode {
- DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
- }
-
- /**
- * Returns the subnet identifier.
- *
- * @return identifier
- */
- SubnetId id();
-
- /**
- * Returns the name of the subnet.
- *
- * @return subnetName
- */
- String subnetName();
-
- /**
- * Returns the network identifier.
- *
- * @return the network identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns tenant identifier.
- *
- * @return the tenant identifier
- */
- TenantId tenantId();
-
- /**
- * Returns the IP version, which is 4 or 6.
- *
- * @return ipVersion
- */
- Version ipVersion();
-
- /**
- * Returns the cidr.
- *
- * @return cidr
- */
- IpPrefix cidr();
-
- /**
- * Returns the gateway IP address.
- *
- * @return gatewayIp
- */
- IpAddress gatewayIp();
-
- /**
- * Returns true if DHCP is enabled and return false if DHCP is disabled.
- *
- * @return true or false
- */
- boolean dhcpEnabled();
-
- /**
- * Indicates whether this tenantNetwork is shared across all tenants. By
- * default, only administrative user can change this value.
- *
- * @return true or false
- */
- boolean shared();
-
- /**
- * Returns a collection of hostRoutes.
- *
- * @return a collection of hostRoutes
- */
- Iterable<HostRoute> hostRoutes();
-
- /**
- * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
- * dhcpv6-stateless, or slaac.
- *
- * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless
- * or slaac
- */
- Mode ipV6AddressMode();
-
- /**
- * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
- * dhcpv6-stateless, or slaac.
- *
- * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or
- * slaac
- */
- Mode ipV6RaMode();
-
- /**
- * Returns a collection of allocation_pools.
- *
- * @return a collection of allocationPools
- */
- Iterable<AllocationPool> allocationPools();
-}
+/*
+ * 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;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpAddress.Version;
+import org.onlab.packet.IpPrefix;
+
+/**
+ * Representation of a subnet.
+ */
+public interface Subnet {
+
+ /**
+ * Coarse classification of the type of the ipV6Mode.
+ */
+ enum Mode {
+ DHCPV6_STATEFUL, DHCPV6_STATELESS, SLAAC
+ }
+
+ /**
+ * Returns the subnet identifier.
+ *
+ * @return identifier
+ */
+ SubnetId id();
+
+ /**
+ * Returns the name of the subnet.
+ *
+ * @return subnetName
+ */
+ String subnetName();
+
+ /**
+ * Returns the network identifier.
+ *
+ * @return the network identifier
+ */
+ TenantNetworkId networkId();
+
+ /**
+ * Returns tenant identifier.
+ *
+ * @return the tenant identifier
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the IP version, which is 4 or 6.
+ *
+ * @return ipVersion
+ */
+ Version ipVersion();
+
+ /**
+ * Returns the cidr.
+ *
+ * @return cidr
+ */
+ IpPrefix cidr();
+
+ /**
+ * Returns the gateway IP address.
+ *
+ * @return gatewayIp
+ */
+ IpAddress gatewayIp();
+
+ /**
+ * Returns true if DHCP is enabled and return false if DHCP is disabled.
+ *
+ * @return true or false
+ */
+ boolean dhcpEnabled();
+
+ /**
+ * Indicates whether this tenantNetwork is shared across all tenants. By
+ * default, only administrative user can change this value.
+ *
+ * @return true or false
+ */
+ boolean shared();
+
+ /**
+ * Returns a collection of hostRoutes.
+ *
+ * @return a collection of hostRoutes
+ */
+ Iterable<HostRoute> hostRoutes();
+
+ /**
+ * Returns the ipV6AddressMode. A valid value is dhcpv6-stateful,
+ * dhcpv6-stateless, or slaac.
+ *
+ * @return ipV6AddressMode whose value is dhcpv6-stateful, dhcpv6-stateless
+ * or slaac
+ */
+ Mode ipV6AddressMode();
+
+ /**
+ * Returns the ipV6RaMode.A valid value is dhcpv6-stateful,
+ * dhcpv6-stateless, or slaac.
+ *
+ * @return ipV6RaMode whose value is dhcpv6-stateful, dhcpv6-stateless or
+ * slaac
+ */
+ Mode ipV6RaMode();
+
+ /**
+ * Returns a collection of allocation_pools.
+ *
+ * @return a collection of allocationPools
+ */
+ Iterable<AllocationPool> allocationPools();
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
index e0c1aee9..4bcc3329 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
@@ -1,76 +1,76 @@
-/*
- * 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;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-/**
- * Immutable representation of a subnet identifier.
- */
-public final class SubnetId {
-
- private final String subnetId;
-
- // Public construction is prohibited
- private SubnetId(String subnetId) {
- checkNotNull(subnetId, "SubnetId cannot be null");
- this.subnetId = subnetId;
- }
-
- /**
- * Creates a Subnet identifier.
- *
- * @param subnetId the subnet identifier
- * @return the subnet identifier
- */
- public static SubnetId subnetId(String subnetId) {
- return new SubnetId(subnetId);
- }
-
- /**
- * Returns the subnet identifier.
- *
- * @return the subnet identifier
- */
- public String subnetId() {
- return subnetId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(subnetId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof SubnetId) {
- final SubnetId that = (SubnetId) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.subnetId, that.subnetId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return subnetId;
- }
-}
+/*
+ * 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;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Immutable representation of a subnet identifier.
+ */
+public final class SubnetId {
+
+ private final String subnetId;
+
+ // Public construction is prohibited
+ private SubnetId(String subnetId) {
+ checkNotNull(subnetId, "SubnetId cannot be null");
+ this.subnetId = subnetId;
+ }
+
+ /**
+ * Creates a Subnet identifier.
+ *
+ * @param subnetId the subnet identifier
+ * @return the subnet identifier
+ */
+ public static SubnetId subnetId(String subnetId) {
+ return new SubnetId(subnetId);
+ }
+
+ /**
+ * Returns the subnet identifier.
+ *
+ * @return the subnet identifier
+ */
+ public String subnetId() {
+ return subnetId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(subnetId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof SubnetId) {
+ final SubnetId that = (SubnetId) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.subnetId, that.subnetId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return subnetId;
+ }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
index 9d44c469..c4d99e49 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
@@ -1,77 +1,77 @@
-/*
- * 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;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a tenant identifier.
- */
-public final class TenantId {
-
- private final String tenantId;
-
- // Public construction is prohibited
- private TenantId(String tenantId) {
- this.tenantId = tenantId;
- }
-
- /**
- * Creates a network id using the tenantid.
- *
- * @param tenantid network String
- * @return TenantId
- */
- public static TenantId tenantId(String tenantid) {
- checkNotNull(tenantid, "Tenantid can not be null");
- return new TenantId(tenantid);
- }
-
- /**
- * Returns the tenant identifier.
- *
- * @return the tenant identifier
- */
- public String tenantId() {
- return tenantId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(tenantId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TenantId) {
- final TenantId that = (TenantId) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.tenantId, that.tenantId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return tenantId;
- }
-
-}
+/*
+ * 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;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a tenant identifier.
+ */
+public final class TenantId {
+
+ private final String tenantId;
+
+ // Public construction is prohibited
+ private TenantId(String tenantId) {
+ this.tenantId = tenantId;
+ }
+
+ /**
+ * Creates a network id using the tenantid.
+ *
+ * @param tenantid network String
+ * @return TenantId
+ */
+ public static TenantId tenantId(String tenantid) {
+ checkNotNull(tenantid, "Tenantid can not be null");
+ return new TenantId(tenantid);
+ }
+
+ /**
+ * Returns the tenant identifier.
+ *
+ * @return the tenant identifier
+ */
+ public String tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(tenantId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TenantId) {
+ final TenantId that = (TenantId) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.tenantId, that.tenantId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return tenantId;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
index d9238f92..256352f4 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
@@ -1,130 +1,130 @@
-/*
- * 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;
-
-/**
- * Representation of the tenantNetwork.
- */
-public interface TenantNetwork {
-
- /**
- * Coarse classification of the state of the tenantNetwork.
- */
- public enum State {
- /**
- * Signifies that a tenantNetwork is currently active.This state means
- * that this network is available.
- */
- ACTIVE,
- /**
- * Signifies that a tenantNetwork is currently built.
- */
- BUILD,
- /**
- * Signifies that a tenantNetwork is currently unavailable.
- */
- DOWN,
- /**
- * Signifies that a tenantNetwork is currently error.
- */
- ERROR
- }
-
- /**
- * Coarse classification of the type of the tenantNetwork.
- */
- public enum Type {
- /**
- * Signifies that a tenantNetwork is local.
- */
- LOCAL
- }
-
- /**
- * Returns the tenantNetwork identifier.
- *
- * @return tenantNetwork identifier
- */
- TenantNetworkId id();
-
- /**
- * Returns the tenantNetwork name.
- *
- * @return tenantNetwork name
- */
- String name();
-
- /**
- * Returns the administrative state of the tenantNetwork,which is up(true)
- * or down(false).
- *
- * @return true or false
- */
- boolean adminStateUp();
-
- /**
- * Returns the tenantNetwork state.
- *
- * @return tenant network state
- */
- State state();
-
- /**
- * Indicates whether this tenantNetwork is shared across all tenants. By
- * default,only administrative user can change this value.
- *
- * @return true or false
- */
- boolean shared();
-
- /**
- * Returns the UUID of the tenant that will own the tenantNetwork. This
- * tenant can be different from the tenant that makes the create
- * tenantNetwork request.
- *
- * @return the tenant identifier
- */
- TenantId tenantId();
-
- /**
- * Returns the routerExternal.Indicates whether this network is externally
- * accessible.
- *
- * @return true or false
- */
- boolean routerExternal();
-
- /**
- * Returns the tenantNetwork Type.
- *
- * @return tenantNetwork Type
- */
- Type type();
-
- /**
- * Returns the tenantNetwork physical network.
- *
- * @return tenantNetwork physical network
- */
- PhysicalNetwork physicalNetwork();
-
- /**
- * Returns the tenantNetwork segmentation id.
- *
- * @return tenantNetwork segmentation id
- */
- SegmentationId segmentationId();
-}
+/*
+ * 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;
+
+/**
+ * Representation of the tenantNetwork.
+ */
+public interface TenantNetwork {
+
+ /**
+ * Coarse classification of the state of the tenantNetwork.
+ */
+ enum State {
+ /**
+ * Signifies that a tenantNetwork is currently active.This state means
+ * that this network is available.
+ */
+ ACTIVE,
+ /**
+ * Signifies that a tenantNetwork is currently built.
+ */
+ BUILD,
+ /**
+ * Signifies that a tenantNetwork is currently unavailable.
+ */
+ DOWN,
+ /**
+ * Signifies that a tenantNetwork is currently error.
+ */
+ ERROR
+ }
+
+ /**
+ * Coarse classification of the type of the tenantNetwork.
+ */
+ enum Type {
+ /**
+ * Signifies that a tenantNetwork is local.
+ */
+ LOCAL
+ }
+
+ /**
+ * Returns the tenantNetwork identifier.
+ *
+ * @return tenantNetwork identifier
+ */
+ TenantNetworkId id();
+
+ /**
+ * Returns the tenantNetwork name.
+ *
+ * @return tenantNetwork name
+ */
+ String name();
+
+ /**
+ * Returns the administrative state of the tenantNetwork,which is up(true)
+ * or down(false).
+ *
+ * @return true or false
+ */
+ boolean adminStateUp();
+
+ /**
+ * Returns the tenantNetwork state.
+ *
+ * @return tenant network state
+ */
+ State state();
+
+ /**
+ * Indicates whether this tenantNetwork is shared across all tenants. By
+ * default,only administrative user can change this value.
+ *
+ * @return true or false
+ */
+ boolean shared();
+
+ /**
+ * Returns the UUID of the tenant that will own the tenantNetwork. This
+ * tenant can be different from the tenant that makes the create
+ * tenantNetwork request.
+ *
+ * @return the tenant identifier
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the routerExternal.Indicates whether this network is externally
+ * accessible.
+ *
+ * @return true or false
+ */
+ boolean routerExternal();
+
+ /**
+ * Returns the tenantNetwork Type.
+ *
+ * @return tenantNetwork Type
+ */
+ Type type();
+
+ /**
+ * Returns the tenantNetwork physical network.
+ *
+ * @return tenantNetwork physical network
+ */
+ PhysicalNetwork physicalNetwork();
+
+ /**
+ * Returns the tenantNetwork segmentation id.
+ *
+ * @return tenantNetwork segmentation id
+ */
+ SegmentationId segmentationId();
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
index 81c9962f..fbb9e480 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
@@ -1,76 +1,76 @@
-/*
- * 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;
-
-import java.util.Objects;
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Immutable representation of a tenantNetwork identity.
- */
-public final class TenantNetworkId {
-
- private final String networkId;
-
- // Public construction is prohibited
- private TenantNetworkId(String networkId) {
- this.networkId = networkId;
- }
-
- /**
- * Creates a TenantNetwork identifier.
- *
- * @param networkId tenantNetwork identify string
- * @return the attached tenantNetwork identifier
- */
- public static TenantNetworkId networkId(String networkId) {
- checkNotNull(networkId, "Networkid cannot be null");
- return new TenantNetworkId(networkId);
- }
-
- /**
- * Returns tenantNetwork identifier.
- *
- * @return the tenantNetwork identifier
- */
- public String networkId() {
- return networkId;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(networkId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof TenantNetworkId) {
- final TenantNetworkId that = (TenantNetworkId) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.networkId, that.networkId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return networkId;
- }
-
-}
+/*
+ * 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;
+
+import java.util.Objects;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Immutable representation of a tenantNetwork identity.
+ */
+public final class TenantNetworkId {
+
+ private final String networkId;
+
+ // Public construction is prohibited
+ private TenantNetworkId(String networkId) {
+ this.networkId = networkId;
+ }
+
+ /**
+ * Creates a TenantNetwork identifier.
+ *
+ * @param networkId tenantNetwork identify string
+ * @return the attached tenantNetwork identifier
+ */
+ public static TenantNetworkId networkId(String networkId) {
+ checkNotNull(networkId, "Networkid cannot be null");
+ return new TenantNetworkId(networkId);
+ }
+
+ /**
+ * Returns tenantNetwork identifier.
+ *
+ * @return the tenantNetwork identifier
+ */
+ public String networkId() {
+ return networkId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(networkId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof TenantNetworkId) {
+ final TenantNetworkId that = (TenantNetworkId) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.networkId, that.networkId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return networkId;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
index a6071094..d2d7c146 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
@@ -1,156 +1,156 @@
-/*
- * 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;
-
-import java.util.Collection;
-import java.util.Set;
-
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-
-/**
- * Representation of the VirtualPort.
- */
-public interface VirtualPort {
- /**
- * Coarse classification of the type of the virtual port.
- */
- public enum State {
- /**
- * Signifies that a virtualPort is currently active,This state mean that
- * this virtualPort is available.
- */
- ACTIVE,
- /**
- * Signifies that a virtualPort is currently unavailable.
- */
- DOWN;
- }
-
- /**
- * Returns the virtualPort identifier.
- *
- * @return virtualPort identifier
- */
- VirtualPortId portId();
-
- /**
- * Returns the network identifier.
- *
- * @return tenantNetwork identifier
- */
- TenantNetworkId networkId();
-
- /**
- * Returns the symbolic name for the virtualPort.
- *
- * @return virtualPort name
- */
- String name();
-
- /**
- * Returns the administrative status of the port,which is up(true) or
- * down(false).
- *
- * @return true if the administrative status of the port is up
- */
- boolean adminStateUp();
-
- /**
- * Returns the state.
- *
- * @return state
- */
- State state();
-
- /**
- * Returns the MAC address.
- *
- * @return MAC Address
- */
- MacAddress macAddress();
-
- /**
- * Returns the port tenantId.
- *
- * @return port tenantId
- */
- TenantId tenantId();
-
- /**
- * Returns the device identifier.
- *
- * @return deviceId
- */
- DeviceId deviceId();
-
- /**
- * Returns the identifier of the entity that uses this port.
- *
- * @return deviceOwner
- */
- String deviceOwner();
-
- /**
- * Returns the virtualPort allowedAddressPairs.
- *
- * @return virtualPort allowedAddressPairs
- */
- Collection<AllowedAddressPair> allowedAddressPairs();
-
- /**
- * Returns set of IP addresses for the port, include the IP addresses and subnet
- * identity.
- *
- * @return FixedIps Set of fixedIp
- */
- Set<FixedIp> fixedIps();
-
- /**
- * Returns the virtualPort bindinghostId.
- *
- * @return virtualPort bindinghostId
- */
- BindingHostId bindingHostId();
-
- /**
- * Returns the virtualPort bindingVnicType.
- *
- * @return virtualPort bindingVnicType
- */
- String bindingVnicType();
-
- /**
- * Returns the virtualPort bindingVifType.
- *
- * @return virtualPort bindingVifType
- */
- String bindingVifType();
-
- /**
- * Returns the virtualPort bindingvifDetail.
- *
- * @return virtualPort bindingvifDetail
- */
- String bindingVifDetails();
-
- /**
- * Returns the security groups.
- *
- * @return port security groups
- */
- Iterable<SecurityGroup> securityGroups();
-}
+/*
+ * 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;
+
+import java.util.Collection;
+import java.util.Set;
+
+import org.onlab.packet.MacAddress;
+import org.onosproject.net.DeviceId;
+
+/**
+ * Representation of the VirtualPort.
+ */
+public interface VirtualPort {
+ /**
+ * Coarse classification of the type of the virtual port.
+ */
+ enum State {
+ /**
+ * Signifies that a virtualPort is currently active,This state mean that
+ * this virtualPort is available.
+ */
+ ACTIVE,
+ /**
+ * Signifies that a virtualPort is currently unavailable.
+ */
+ DOWN;
+ }
+
+ /**
+ * Returns the virtualPort identifier.
+ *
+ * @return virtualPort identifier
+ */
+ VirtualPortId portId();
+
+ /**
+ * Returns the network identifier.
+ *
+ * @return tenantNetwork identifier
+ */
+ TenantNetworkId networkId();
+
+ /**
+ * Returns the symbolic name for the virtualPort.
+ *
+ * @return virtualPort name
+ */
+ String name();
+
+ /**
+ * Returns the administrative status of the port,which is up(true) or
+ * down(false).
+ *
+ * @return true if the administrative status of the port is up
+ */
+ boolean adminStateUp();
+
+ /**
+ * Returns the state.
+ *
+ * @return state
+ */
+ State state();
+
+ /**
+ * Returns the MAC address.
+ *
+ * @return MAC Address
+ */
+ MacAddress macAddress();
+
+ /**
+ * Returns the port tenantId.
+ *
+ * @return port tenantId
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the device identifier.
+ *
+ * @return deviceId
+ */
+ DeviceId deviceId();
+
+ /**
+ * Returns the identifier of the entity that uses this port.
+ *
+ * @return deviceOwner
+ */
+ String deviceOwner();
+
+ /**
+ * Returns the virtualPort allowedAddressPairs.
+ *
+ * @return virtualPort allowedAddressPairs
+ */
+ Collection<AllowedAddressPair> allowedAddressPairs();
+
+ /**
+ * Returns set of IP addresses for the port, include the IP addresses and subnet
+ * identity.
+ *
+ * @return FixedIps Set of fixedIp
+ */
+ Set<FixedIp> fixedIps();
+
+ /**
+ * Returns the virtualPort bindinghostId.
+ *
+ * @return virtualPort bindinghostId
+ */
+ BindingHostId bindingHostId();
+
+ /**
+ * Returns the virtualPort bindingVnicType.
+ *
+ * @return virtualPort bindingVnicType
+ */
+ String bindingVnicType();
+
+ /**
+ * Returns the virtualPort bindingVifType.
+ *
+ * @return virtualPort bindingVifType
+ */
+ String bindingVifType();
+
+ /**
+ * Returns the virtualPort bindingvifDetail.
+ *
+ * @return virtualPort bindingvifDetail
+ */
+ String bindingVifDetails();
+
+ /**
+ * Returns the security groups.
+ *
+ * @return port security groups
+ */
+ Iterable<SecurityGroup> securityGroups();
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
index 0969ce10..3038bdff 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
@@ -1,70 +1,70 @@
-/*
- * 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;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import java.util.Objects;
-
-/**
- * Immutable representation of a virtual port identifier.
- */
-public final class VirtualPortId {
- private final String portId;
- // Public construction is prohibited
- private VirtualPortId(String virtualPortId) {
- checkNotNull(virtualPortId, "VirtualPortId cannot be null");
- this.portId = virtualPortId;
- }
-
- public String portId() {
- return portId;
- }
-
- /**
- * Creates a virtualPort id using the supplied portId.
- *
- * @param portId virtualport identifier
- * @return VirtualPortId
- */
- public static VirtualPortId portId(String portId) {
- return new VirtualPortId(portId);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(portId);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof VirtualPortId) {
- final VirtualPortId that = (VirtualPortId) obj;
- return this.getClass() == that.getClass()
- && Objects.equals(this.portId, that.portId);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return portId;
- }
-
-}
+/*
+ * 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;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Immutable representation of a virtual port identifier.
+ */
+public final class VirtualPortId {
+ private final String portId;
+ // Public construction is prohibited
+ private VirtualPortId(String virtualPortId) {
+ checkNotNull(virtualPortId, "VirtualPortId cannot be null");
+ this.portId = virtualPortId;
+ }
+
+ public String portId() {
+ return portId;
+ }
+
+ /**
+ * Creates a virtualPort id using the supplied portId.
+ *
+ * @param portId virtualport identifier
+ * @return VirtualPortId
+ */
+ public static VirtualPortId portId(String portId) {
+ return new VirtualPortId(portId);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(portId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof VirtualPortId) {
+ final VirtualPortId that = (VirtualPortId) obj;
+ return this.getClass() == that.getClass()
+ && Objects.equals(this.portId, that.portId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return portId;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
new file mode 100644
index 00000000..1622c800
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Command line interface for tenant networks.
+ */
+package org.onosproject.vtnrsc.cli.network;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
index f8ee6b97..b0578a1e 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
@@ -92,7 +92,7 @@ public class SubnetUpdateCommand extends AbstractShellCommand {
@Option(name = "-a", aliases = "--allocationPools",
description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();;
+ Set<AllocationPool> allocationPools = Sets.newHashSet();
@Override
protected void execute() {
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
new file mode 100644
index 00000000..b3a2ff51
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Command line interface for subnets.
+ */
+package org.onosproject.vtnrsc.cli.subnet;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
new file mode 100644
index 00000000..fac214a1
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Command line interface for virtual ports.
+ */
+package org.onosproject.vtnrsc.cli.virtualport;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
index 71ea9ba3..82eb9611 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
@@ -1,72 +1,72 @@
-/*
- * 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 org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-
-
-/**
- * Service for interacting with the inventory of subnets.
- */
-public interface SubnetService {
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return true or false
- */
- boolean exists(SubnetId subnetId);
- /**
- * Returns a collection of the currently known subnets.
- *
- * @return iterable collection of subnets
- */
- Iterable<Subnet> getSubnets();
-
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return subnet or null if one with the given identifier is not known
- */
- Subnet getSubnet(SubnetId subnetId);
- /**
- * Creates new subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if the identifier subnet has been created right
- */
- boolean createSubnets(Iterable<Subnet> subnets);
-
- /**
- * Updates existing subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if all subnets were updated successfully
- */
- boolean updateSubnets(Iterable<Subnet> subnets);
-
- /**
- * Administratively removes the specified subnets from the store.
- *
- * @param subnetIds the iterable collection of subnets identifier
- * @return true if remove identifier subnets successfully
- */
- boolean removeSubnets(Iterable<SubnetId> subnetIds);
-
-
-}
+/*
+ * 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 org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+
+
+/**
+ * Service for interacting with the inventory of subnets.
+ */
+public interface SubnetService {
+ /**
+ * Returns the subnet with the specified identifier.
+ *
+ * @param subnetId subnet identifier
+ * @return true or false
+ */
+ boolean exists(SubnetId subnetId);
+ /**
+ * Returns a collection of the currently known subnets.
+ *
+ * @return iterable collection of subnets
+ */
+ Iterable<Subnet> getSubnets();
+
+ /**
+ * Returns the subnet with the specified identifier.
+ *
+ * @param subnetId subnet identifier
+ * @return subnet or null if one with the given identifier is not known
+ */
+ Subnet getSubnet(SubnetId subnetId);
+ /**
+ * Creates new subnets.
+ *
+ * @param subnets the iterable collection of subnets
+ * @return true if the identifier subnet has been created right
+ */
+ boolean createSubnets(Iterable<Subnet> subnets);
+
+ /**
+ * Updates existing subnets.
+ *
+ * @param subnets the iterable collection of subnets
+ * @return true if all subnets were updated successfully
+ */
+ boolean updateSubnets(Iterable<Subnet> subnets);
+
+ /**
+ * Administratively removes the specified subnets from the store.
+ *
+ * @param subnetIds the iterable collection of subnets identifier
+ * @return true if remove identifier subnets successfully
+ */
+ boolean removeSubnets(Iterable<SubnetId> subnetIds);
+
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
index ab810a80..890beb29 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
@@ -1,179 +1,183 @@
-/*
- * 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.impl;
-
-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.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the Subnet service.
- */
-@Component(immediate = true)
-@Service
-public class SubnetManager implements SubnetService {
-
- private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
- private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
- private static final String SUBNET = "vtn-subnet-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
-
- private final Logger log = getLogger(getClass());
-
- protected Map<SubnetId, Subnet> subnetStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService tenantNetworkService;
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
- .withName(SUBNET)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- Subnet.class,
- SubnetId.class,
- TenantNetworkId.class,
- TenantId.class,
- HostRoute.class,
- Subnet.Mode.class,
- AllocationPool.class,
- DefaultSubnet.class,
- IpAddress.Version.class))
- .build().asJavaMap();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public Iterable<Subnet> getSubnets() {
- return Collections.unmodifiableCollection(subnetStore.values());
- }
-
- @Override
- public Subnet getSubnet(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return subnetStore.get(subnetId);
- }
-
- @Override
- public boolean exists(SubnetId subnetId) {
- checkNotNull(subnetId, SUBNET_ID_NULL);
- return subnetStore.containsKey(subnetId);
- }
-
- @Override
- public boolean createSubnets(Iterable<Subnet> subnets) {
- checkNotNull(subnets, SUBNET_NOT_NULL);
- for (Subnet subnet : subnets) {
- if (!tenantNetworkService.exists(subnet.networkId())) {
- log.debug("The network identifier that the subnet {} belong to is not exist",
- subnet.networkId().toString(), subnet.id().toString());
- return false;
- }
- subnetStore.put(subnet.id(), subnet);
- if (!subnetStore.containsKey(subnet.id())) {
- log.debug("The identified subnet whose identifier is {} create failed",
- subnet.id().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateSubnets(Iterable<Subnet> subnets) {
- checkNotNull(subnets, SUBNET_NOT_NULL);
- if (subnets != null) {
- for (Subnet subnet : subnets) {
- if (!subnetStore.containsKey(subnet.id())) {
- log.debug("The subnet is not exist whose identifier is {}",
- subnet.id().toString());
- return false;
- }
-
- subnetStore.put(subnet.id(), subnet);
-
- if (!subnet.equals(subnetStore.get(subnet.id()))) {
- log.debug("The subnet is updated failed whose identifier is {}",
- subnet.id().toString());
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
- checkNotNull(subnetIds, SUBNET_ID_NULL);
- if (subnetIds != null) {
- for (SubnetId subnetId : subnetIds) {
- subnetStore.remove(subnetId);
- if (subnetStore.containsKey(subnetId)) {
- log.debug("The subnet created is failed whose identifier is {}",
- subnetId.toString());
- return false;
- }
- }
- }
- return true;
- }
-
-}
+/*
+ * 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.impl;
+
+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.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.vtnrsc.AllocationPool;
+import org.onosproject.vtnrsc.DefaultAllocationPool;
+import org.onosproject.vtnrsc.DefaultHostRoute;
+import org.onosproject.vtnrsc.DefaultSubnet;
+import org.onosproject.vtnrsc.HostRoute;
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.subnet.SubnetService;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.slf4j.Logger;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provides implementation of the Subnet service.
+ */
+@Component(immediate = true)
+@Service
+public class SubnetManager implements SubnetService {
+
+ private static final String SUBNET_ID_NULL = "Subnet ID cannot be null";
+ private static final String SUBNET_NOT_NULL = "Subnet cannot be null";
+ private static final String SUBNET = "vtn-subnet-store";
+ private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
+
+
+ private final Logger log = getLogger(getClass());
+
+ protected Map<SubnetId, Subnet> subnetStore;
+ protected ApplicationId appId;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected TenantNetworkService tenantNetworkService;
+
+ @Activate
+ public void activate() {
+
+ appId = coreService.registerApplication(VTNRSC_APP);
+
+ subnetStore = storageService.<SubnetId, Subnet>consistentMapBuilder()
+ .withName(SUBNET)
+ .withApplicationId(appId)
+ .withPurgeOnUninstall()
+ .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
+ Subnet.class,
+ SubnetId.class,
+ TenantNetworkId.class,
+ TenantId.class,
+ HostRoute.class,
+ DefaultHostRoute.class,
+ Subnet.Mode.class,
+ AllocationPool.class,
+ DefaultAllocationPool.class,
+ DefaultSubnet.class,
+ IpAddress.Version.class))
+ .build().asJavaMap();
+
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public Iterable<Subnet> getSubnets() {
+ return Collections.unmodifiableCollection(subnetStore.values());
+ }
+
+ @Override
+ public Subnet getSubnet(SubnetId subnetId) {
+ checkNotNull(subnetId, SUBNET_ID_NULL);
+ return subnetStore.get(subnetId);
+ }
+
+ @Override
+ public boolean exists(SubnetId subnetId) {
+ checkNotNull(subnetId, SUBNET_ID_NULL);
+ return subnetStore.containsKey(subnetId);
+ }
+
+ @Override
+ public boolean createSubnets(Iterable<Subnet> subnets) {
+ checkNotNull(subnets, SUBNET_NOT_NULL);
+ for (Subnet subnet : subnets) {
+ if (!tenantNetworkService.exists(subnet.networkId())) {
+ log.debug("The network identifier that the subnet {} belong to is not exist",
+ subnet.networkId().toString(), subnet.id().toString());
+ return false;
+ }
+ subnetStore.put(subnet.id(), subnet);
+ if (!subnetStore.containsKey(subnet.id())) {
+ log.debug("The identified subnet whose identifier is {} create failed",
+ subnet.id().toString());
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateSubnets(Iterable<Subnet> subnets) {
+ checkNotNull(subnets, SUBNET_NOT_NULL);
+ if (subnets != null) {
+ for (Subnet subnet : subnets) {
+ if (!subnetStore.containsKey(subnet.id())) {
+ log.debug("The subnet is not exist whose identifier is {}",
+ subnet.id().toString());
+ return false;
+ }
+
+ subnetStore.put(subnet.id(), subnet);
+
+ if (!subnet.equals(subnetStore.get(subnet.id()))) {
+ log.debug("The subnet is updated failed whose identifier is {}",
+ subnet.id().toString());
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean removeSubnets(Iterable<SubnetId> subnetIds) {
+ checkNotNull(subnetIds, SUBNET_ID_NULL);
+ if (subnetIds != null) {
+ for (SubnetId subnetId : subnetIds) {
+ subnetStore.remove(subnetId);
+ if (subnetStore.containsKey(subnetId)) {
+ log.debug("The subnet created is failed whose identifier is {}",
+ subnetId.toString());
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
new file mode 100644
index 00000000..79040d8d
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Provides implementation of the Subnet service.
+ */
+package org.onosproject.vtnrsc.subnet.impl;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
new file mode 100644
index 00000000..7b2bdb90
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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 the inventory of subnets.
+ */
+package org.onosproject.vtnrsc.subnet;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
index 56e8bcee..e246cc4e 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
@@ -1,80 +1,80 @@
-/*
- * 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 org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-
-/**
- * Service for interacting with the inventory of tenantNetwork.
- */
-public interface TenantNetworkService {
-
- /**
- * Returns if the tenantNetwork is existed.
- *
- * @param networkId tenantNetwork identifier
- * @return true or false if one with the given identifier exists.
- */
- boolean exists(TenantNetworkId networkId);
-
- /**
- * Returns the number of tenantNetwork known to the system.
- *
- * @return number of tenantNetwork.
- */
- int getNetworkCount();
-
- /**
- * Returns an iterable collection of the currently known tenantNetwork.
- *
- * @return collection of tenantNetwork.
- */
- Iterable<TenantNetwork> getNetworks();
-
- /**
- * Returns the tenantNetwork with the identifier.
- *
- * @param networkId TenantNetwork identifier
- * @return TenantNetwork or null if one with the given identifier is not
- * known.
- */
- TenantNetwork getNetwork(TenantNetworkId networkId);
-
- /**
- * Creates tenantNetworks by networks.
- *
- * @param networks the collection of tenantNetworks
- * @return true if all given identifiers created successfully.
- */
- boolean createNetworks(Iterable<TenantNetwork> networks);
-
- /**
- * Updates tenantNetworks by tenantNetworks.
- *
- * @param networks the collection of tenantNetworks
- * @return true if all given identifiers updated successfully.
- */
- boolean updateNetworks(Iterable<TenantNetwork> networks);
-
- /**
- * Deletes tenantNetwork by tenantNetworkIds.
- *
- * @param networksIds the collection of tenantNetworkIds
- * @return true if the specified tenantNetworks deleted successfully.
- */
- boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
-}
+/*
+ * 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 org.onosproject.vtnrsc.TenantNetwork;
+import org.onosproject.vtnrsc.TenantNetworkId;
+
+/**
+ * Service for interacting with the inventory of tenantNetwork.
+ */
+public interface TenantNetworkService {
+
+ /**
+ * Returns if the tenantNetwork is existed.
+ *
+ * @param networkId tenantNetwork identifier
+ * @return true or false if one with the given identifier exists.
+ */
+ boolean exists(TenantNetworkId networkId);
+
+ /**
+ * Returns the number of tenantNetwork known to the system.
+ *
+ * @return number of tenantNetwork.
+ */
+ int getNetworkCount();
+
+ /**
+ * Returns an iterable collection of the currently known tenantNetwork.
+ *
+ * @return collection of tenantNetwork.
+ */
+ Iterable<TenantNetwork> getNetworks();
+
+ /**
+ * Returns the tenantNetwork with the identifier.
+ *
+ * @param networkId TenantNetwork identifier
+ * @return TenantNetwork or null if one with the given identifier is not
+ * known.
+ */
+ TenantNetwork getNetwork(TenantNetworkId networkId);
+
+ /**
+ * Creates tenantNetworks by networks.
+ *
+ * @param networks the collection of tenantNetworks
+ * @return true if all given identifiers created successfully.
+ */
+ boolean createNetworks(Iterable<TenantNetwork> networks);
+
+ /**
+ * Updates tenantNetworks by tenantNetworks.
+ *
+ * @param networks the collection of tenantNetworks
+ * @return true if all given identifiers updated successfully.
+ */
+ boolean updateNetworks(Iterable<TenantNetwork> networks);
+
+ /**
+ * Deletes tenantNetwork by tenantNetworkIds.
+ *
+ * @param networksIds the collection of tenantNetworkIds
+ * @return true if the specified tenantNetworks deleted successfully.
+ */
+ boolean removeNetworks(Iterable<TenantNetworkId> networksIds);
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
index c5290ad2..0dfc99e2 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
@@ -1,167 +1,167 @@
-/*
- * 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.impl;
-
-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.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.slf4j.Logger;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides implementation of the tenantNetworkService.
- */
-@Component(immediate = true)
-@Service
-public class TenantNetworkManager implements TenantNetworkService {
-
- private static final String NETWORK_ID_NULL = "Network ID cannot be null";
- private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
- private static final String TENANTNETWORK = "vtn-tenant-network-store";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
- protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
- protected ApplicationId appId;
-
- private final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()
- .withName(TENANTNETWORK)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- TenantNetworkId.class,
- DefaultTenantNetwork.class,
- TenantNetwork.State.class,
- TenantId.class,
- TenantNetwork.Type.class,
- PhysicalNetwork.class,
- SegmentationId.class))
- .build().asJavaMap();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- log.info("Stopped");
- }
-
- @Override
- public boolean exists(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORK_ID_NULL);
- return networkIdAsKeyStore.containsKey(networkId);
- }
-
- @Override
- public int getNetworkCount() {
- return networkIdAsKeyStore.size();
- }
-
- @Override
- public Iterable<TenantNetwork> getNetworks() {
- return Collections.unmodifiableCollection(networkIdAsKeyStore.values());
- }
-
- @Override
- public TenantNetwork getNetwork(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORK_ID_NULL);
- return networkIdAsKeyStore.get(networkId);
- }
-
- @Override
- public boolean createNetworks(Iterable<TenantNetwork> networks) {
- checkNotNull(networks, NETWORK_NOT_NULL);
- for (TenantNetwork network : networks) {
- networkIdAsKeyStore.put(network.id(), network);
- if (!networkIdAsKeyStore.containsKey(network.id())) {
- log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
- .toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updateNetworks(Iterable<TenantNetwork> networks) {
- checkNotNull(networks, NETWORK_NOT_NULL);
- for (TenantNetwork network : networks) {
- if (!networkIdAsKeyStore.containsKey(network.id())) {
- log.debug("The tenantNetwork is not exist whose identifier was {} ",
- network.id().toString());
- return false;
- }
-
- networkIdAsKeyStore.put(network.id(), network);
-
- if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
- log.debug("The tenantNetwork is updated failed whose identifier was {} ",
- network.id().toString());
- return false;
- }
-
- }
- return true;
- }
-
- @Override
- public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {
- checkNotNull(networkIds, NETWORK_NOT_NULL);
- for (TenantNetworkId networkId : networkIds) {
- networkIdAsKeyStore.remove(networkId);
- if (networkIdAsKeyStore.containsKey(networkId)) {
- log.debug("The tenantNetwork is removed failed whose identifier was {}",
- networkId.toString());
- return false;
- }
- }
- return true;
- }
-}
+/*
+ * 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.impl;
+
+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.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.vtnrsc.DefaultTenantNetwork;
+import org.onosproject.vtnrsc.PhysicalNetwork;
+import org.onosproject.vtnrsc.SegmentationId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetwork;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.slf4j.Logger;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * Provides implementation of the tenantNetworkService.
+ */
+@Component(immediate = true)
+@Service
+public class TenantNetworkManager implements TenantNetworkService {
+
+ private static final String NETWORK_ID_NULL = "Network ID cannot be null";
+ private static final String NETWORK_NOT_NULL = "Network ID cannot be null";
+ private static final String TENANTNETWORK = "vtn-tenant-network-store";
+ private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
+
+ protected Map<TenantNetworkId, TenantNetwork> networkIdAsKeyStore;
+ protected ApplicationId appId;
+
+ private final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+
+ @Activate
+ public void activate() {
+
+ appId = coreService.registerApplication(VTNRSC_APP);
+
+ networkIdAsKeyStore = storageService.<TenantNetworkId, TenantNetwork>consistentMapBuilder()
+ .withName(TENANTNETWORK)
+ .withApplicationId(appId)
+ .withPurgeOnUninstall()
+ .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
+ TenantNetworkId.class,
+ DefaultTenantNetwork.class,
+ TenantNetwork.State.class,
+ TenantId.class,
+ TenantNetwork.Type.class,
+ PhysicalNetwork.class,
+ SegmentationId.class))
+ .build().asJavaMap();
+
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ log.info("Stopped");
+ }
+
+ @Override
+ public boolean exists(TenantNetworkId networkId) {
+ checkNotNull(networkId, NETWORK_ID_NULL);
+ return networkIdAsKeyStore.containsKey(networkId);
+ }
+
+ @Override
+ public int getNetworkCount() {
+ return networkIdAsKeyStore.size();
+ }
+
+ @Override
+ public Iterable<TenantNetwork> getNetworks() {
+ return Collections.unmodifiableCollection(networkIdAsKeyStore.values());
+ }
+
+ @Override
+ public TenantNetwork getNetwork(TenantNetworkId networkId) {
+ checkNotNull(networkId, NETWORK_ID_NULL);
+ return networkIdAsKeyStore.get(networkId);
+ }
+
+ @Override
+ public boolean createNetworks(Iterable<TenantNetwork> networks) {
+ checkNotNull(networks, NETWORK_NOT_NULL);
+ for (TenantNetwork network : networks) {
+ networkIdAsKeyStore.put(network.id(), network);
+ if (!networkIdAsKeyStore.containsKey(network.id())) {
+ log.debug("The tenantNetwork is created failed which identifier was {}", network.id()
+ .toString());
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updateNetworks(Iterable<TenantNetwork> networks) {
+ checkNotNull(networks, NETWORK_NOT_NULL);
+ for (TenantNetwork network : networks) {
+ if (!networkIdAsKeyStore.containsKey(network.id())) {
+ log.debug("The tenantNetwork is not exist whose identifier was {} ",
+ network.id().toString());
+ return false;
+ }
+
+ networkIdAsKeyStore.put(network.id(), network);
+
+ if (!network.equals(networkIdAsKeyStore.get(network.id()))) {
+ log.debug("The tenantNetwork is updated failed whose identifier was {} ",
+ network.id().toString());
+ return false;
+ }
+
+ }
+ return true;
+ }
+
+ @Override
+ public boolean removeNetworks(Iterable<TenantNetworkId> networkIds) {
+ checkNotNull(networkIds, NETWORK_NOT_NULL);
+ for (TenantNetworkId networkId : networkIds) {
+ networkIdAsKeyStore.remove(networkId);
+ if (networkIdAsKeyStore.containsKey(networkId)) {
+ log.debug("The tenantNetwork is removed failed whose identifier was {}",
+ networkId.toString());
+ return false;
+ }
+ }
+ return true;
+ }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
new file mode 100644
index 00000000..f381fda6
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of service for interacting with the inventory of tenant networks.
+ */
+package org.onosproject.vtnrsc.tenantnetwork.impl;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
new file mode 100644
index 00000000..1489c973
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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 the inventory of tenant networks.
+ */
+package org.onosproject.vtnrsc.tenantnetwork;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
index f09caf29..6f3cf653 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
@@ -1,72 +1,72 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tunnel;
-
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-
-
-/**
- * Service for interacting with the inventory of subnets.
- */
-public interface TunnelConfigService {
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return true or false
- */
- boolean exists(SubnetId subnetId);
- /**
- * Returns a collection of the currently known subnets.
- *
- * @return iterable collection of subnets
- */
- Iterable<Subnet> getSubnets();
-
- /**
- * Returns the subnet with the specified identifier.
- *
- * @param subnetId subnet identifier
- * @return subnet or null if one with the given identifier is not known
- */
- Subnet getSubnet(SubnetId subnetId);
- /**
- * Creates new subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if the identifier subnet has been created right
- */
- boolean createSubnets(Iterable<Subnet> subnets);
-
- /**
- * Updates existing subnets.
- *
- * @param subnets the iterable collection of subnets
- * @return true if all subnets were updated successfully
- */
- boolean updateSubnets(Iterable<Subnet> subnets);
-
- /**
- * Administratively removes the specified subnets from the store.
- *
- * @param subnetIds the iterable collection of subnets identifier
- * @return true if remove identifier subnets successfully
- */
- boolean removeSubnets(Iterable<SubnetId> subnetIds);
-
-
-}
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc.tunnel;
+
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+
+
+/**
+ * Service for interacting with the inventory of subnets.
+ */
+public interface TunnelConfigService {
+ /**
+ * Returns the subnet with the specified identifier.
+ *
+ * @param subnetId subnet identifier
+ * @return true or false
+ */
+ boolean exists(SubnetId subnetId);
+ /**
+ * Returns a collection of the currently known subnets.
+ *
+ * @return iterable collection of subnets
+ */
+ Iterable<Subnet> getSubnets();
+
+ /**
+ * Returns the subnet with the specified identifier.
+ *
+ * @param subnetId subnet identifier
+ * @return subnet or null if one with the given identifier is not known
+ */
+ Subnet getSubnet(SubnetId subnetId);
+ /**
+ * Creates new subnets.
+ *
+ * @param subnets the iterable collection of subnets
+ * @return true if the identifier subnet has been created right
+ */
+ boolean createSubnets(Iterable<Subnet> subnets);
+
+ /**
+ * Updates existing subnets.
+ *
+ * @param subnets the iterable collection of subnets
+ * @return true if all subnets were updated successfully
+ */
+ boolean updateSubnets(Iterable<Subnet> subnets);
+
+ /**
+ * Administratively removes the specified subnets from the store.
+ *
+ * @param subnetIds the iterable collection of subnets identifier
+ * @return true if remove identifier subnets successfully
+ */
+ boolean removeSubnets(Iterable<SubnetId> subnetIds);
+
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
new file mode 100644
index 00000000..3a84e6e3
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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 the inventory of subnets.
+ */
+package org.onosproject.vtnrsc.tunnel;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
index 24ddb9f1..05ebccf9 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
@@ -1,100 +1,100 @@
-/*
- * Copyright 2015 Open Porting 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 java.util.Collection;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-
-/**
- * Service for interacting with the inventory of virtualPort.
- */
-public interface VirtualPortService {
- /**
- * Returns if the virtualPort is existed.
- *
- * @param virtualPortId virtualPort identifier
- * @return true or false if one with the given identifier is not existed.
- */
- boolean exists(VirtualPortId virtualPortId);
-
- /**
- * Returns the virtualPort with the identifier.
- *
- * @param virtualPortId virtualPort ID
- * @return VirtualPort or null if one with the given ID is not know.
- */
- VirtualPort getPort(VirtualPortId virtualPortId);
-
- /**
- * Returns the collection of the currently known virtualPort.
- * @return collection of VirtualPort.
- */
- Collection<VirtualPort> getPorts();
-
- /**
- * Returns the collection of the virtualPorts associated with the networkId.
- *
- * @param networkId the network identifer
- * @return collection of virtualPort.
- */
- Collection<VirtualPort> getPorts(TenantNetworkId networkId);
-
- /**
- * Returns the collection of the virtualPorts associated with the tenantId.
- *
- * @param tenantId the tenant identifier
- * @return collection of virtualPorts.
- */
- Collection<VirtualPort> getPorts(TenantId tenantId);
-
- /**
- * Returns the collection of the virtualPorts associated with the deviceId.
- *
- * @param deviceId the device identifier
- * @return collection of virtualPort.
- */
- Collection<VirtualPort> getPorts(DeviceId deviceId);
-
- /**
- * Creates virtualPorts by virtualPorts.
- *
- * @param virtualPorts the iterable collection of virtualPorts
- * @return true if all given identifiers created successfully.
- */
- boolean createPorts(Iterable<VirtualPort> virtualPorts);
-
- /**
- * Updates virtualPorts by virtualPorts.
- *
- * @param virtualPorts the iterable collection of virtualPorts
- * @return true if all given identifiers updated successfully.
- */
- boolean updatePorts(Iterable<VirtualPort> virtualPorts);
-
- /**
- * Deletes virtualPortIds by virtualPortIds.
- *
- * @param virtualPortIds the iterable collection of virtualPort identifiers
- * @return true or false if one with the given identifier to delete is
- * successfully.
- */
- boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
-}
+/*
+ * 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 java.util.Collection;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.VirtualPort;
+import org.onosproject.vtnrsc.VirtualPortId;
+
+/**
+ * Service for interacting with the inventory of virtualPort.
+ */
+public interface VirtualPortService {
+ /**
+ * Returns if the virtualPort is existed.
+ *
+ * @param virtualPortId virtualPort identifier
+ * @return true or false if one with the given identifier is not existed.
+ */
+ boolean exists(VirtualPortId virtualPortId);
+
+ /**
+ * Returns the virtualPort with the identifier.
+ *
+ * @param virtualPortId virtualPort ID
+ * @return VirtualPort or null if one with the given ID is not know.
+ */
+ VirtualPort getPort(VirtualPortId virtualPortId);
+
+ /**
+ * Returns the collection of the currently known virtualPort.
+ * @return collection of VirtualPort.
+ */
+ Collection<VirtualPort> getPorts();
+
+ /**
+ * Returns the collection of the virtualPorts associated with the networkId.
+ *
+ * @param networkId the network identifer
+ * @return collection of virtualPort.
+ */
+ Collection<VirtualPort> getPorts(TenantNetworkId networkId);
+
+ /**
+ * Returns the collection of the virtualPorts associated with the tenantId.
+ *
+ * @param tenantId the tenant identifier
+ * @return collection of virtualPorts.
+ */
+ Collection<VirtualPort> getPorts(TenantId tenantId);
+
+ /**
+ * Returns the collection of the virtualPorts associated with the deviceId.
+ *
+ * @param deviceId the device identifier
+ * @return collection of virtualPort.
+ */
+ Collection<VirtualPort> getPorts(DeviceId deviceId);
+
+ /**
+ * Creates virtualPorts by virtualPorts.
+ *
+ * @param virtualPorts the iterable collection of virtualPorts
+ * @return true if all given identifiers created successfully.
+ */
+ boolean createPorts(Iterable<VirtualPort> virtualPorts);
+
+ /**
+ * Updates virtualPorts by virtualPorts.
+ *
+ * @param virtualPorts the iterable collection of virtualPorts
+ * @return true if all given identifiers updated successfully.
+ */
+ boolean updatePorts(Iterable<VirtualPort> virtualPorts);
+
+ /**
+ * Deletes virtualPortIds by virtualPortIds.
+ *
+ * @param virtualPortIds the iterable collection of virtualPort identifiers
+ * @return true or false if one with the given identifier to delete is
+ * successfully.
+ */
+ boolean removePorts(Iterable<VirtualPortId> virtualPortIds);
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
index e0c49f5b..bea0fd55 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
@@ -1,222 +1,222 @@
-/*
- * 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.impl;
-
-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.packet.IpAddress;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Map;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Provides implementation of the VirtualPort APIs.
- */
-@Component(immediate = true)
-@Service
-public class VirtualPortManager implements VirtualPortService {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- private static final String VIRTUALPORT = "vtn-virtual-port";
- private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
-
- private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
- private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null";
- private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
- private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
- private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
-
- protected Map<VirtualPortId, VirtualPort> vPortStore;
- protected ApplicationId appId;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService networkService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
-
- appId = coreService.registerApplication(VTNRSC_APP);
-
- vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder()
- .withName(VIRTUALPORT)
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
- VirtualPortId.class,
- TenantNetworkId.class,
- VirtualPort.State.class,
- TenantId.class,
- AllowedAddressPair.class,
- FixedIp.class,
- BindingHostId.class,
- SecurityGroup.class,
- SubnetId.class,
- IpAddress.class,
- DefaultVirtualPort.class))
- .build().asJavaMap();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- vPortStore.clear();
- log.info("Stoppped");
- }
-
- @Override
- public boolean exists(VirtualPortId vPortId) {
- checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
- return vPortStore.containsKey(vPortId);
- }
-
- @Override
- public VirtualPort getPort(VirtualPortId vPortId) {
- checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
- return vPortStore.get(vPortId);
- }
-
- @Override
- public Collection<VirtualPort> getPorts() {
- return Collections.unmodifiableCollection(vPortStore.values());
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
- checkNotNull(networkId, NETWORKID_NOT_NULL);
- Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithNetworkIds) {
- if (!vPort.networkId().equals(networkId)) {
- vPortWithNetworkIds.remove(vPort);
- }
- }
- return vPortWithNetworkIds;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(TenantId tenantId) {
- checkNotNull(tenantId, TENANTID_NOT_NULL);
- Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithTenantIds) {
- if (!vPort.tenantId().equals(tenantId)) {
- vPortWithTenantIds.remove(vPort);
- }
- }
- return vPortWithTenantIds;
- }
-
- @Override
- public Collection<VirtualPort> getPorts(DeviceId deviceId) {
- checkNotNull(deviceId, DEVICEID_NOT_NULL);
- Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();
- for (VirtualPort vPort : vPortWithDeviceIds) {
- if (!vPort.deviceId().equals(deviceId)) {
- vPortWithDeviceIds.remove(vPort);
- }
- }
- return vPortWithDeviceIds;
- }
-
- @Override
- public boolean createPorts(Iterable<VirtualPort> vPorts) {
- checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
- for (VirtualPort vPort : vPorts) {
- log.debug("vPortId is {} ", vPort.portId().toString());
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.debug("The virtualPort is created failed whose identifier is {} ",
- vPort.portId().toString());
- return false;
- }
- }
- return true;
- }
-
- @Override
- public boolean updatePorts(Iterable<VirtualPort> vPorts) {
- checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
- if (vPorts != null) {
- for (VirtualPort vPort : vPorts) {
- vPortStore.put(vPort.portId(), vPort);
- if (!vPortStore.containsKey(vPort.portId())) {
- log.debug("The virtualPort is not exist whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
-
- vPortStore.put(vPort.portId(), vPort);
-
- if (!vPort.equals(vPortStore.get(vPort.portId()))) {
- log.debug("The virtualPort is updated failed whose identifier is {}",
- vPort.portId().toString());
- return false;
- }
- }
- }
- return true;
- }
-
- @Override
- public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
- checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);
- if (vPortIds != null) {
- for (VirtualPortId vPortId : vPortIds) {
- vPortStore.remove(vPortId);
- if (vPortStore.containsKey(vPortId)) {
- log.debug("The virtualPort is removed failed whose identifier is {}",
- vPortId.toString());
- return false;
- }
- }
- }
- return true;
- }
-
-}
+/*
+ * 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.impl;
+
+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.packet.IpAddress;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.DeviceId;
+import org.onosproject.store.serializers.KryoNamespaces;
+import org.onosproject.store.service.Serializer;
+import org.onosproject.store.service.StorageService;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+import org.onosproject.vtnrsc.BindingHostId;
+import org.onosproject.vtnrsc.DefaultVirtualPort;
+import org.onosproject.vtnrsc.FixedIp;
+import org.onosproject.vtnrsc.SecurityGroup;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.VirtualPort;
+import org.onosproject.vtnrsc.VirtualPortId;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.onosproject.vtnrsc.virtualport.VirtualPortService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Provides implementation of the VirtualPort APIs.
+ */
+@Component(immediate = true)
+@Service
+public class VirtualPortManager implements VirtualPortService {
+
+ private final Logger log = LoggerFactory.getLogger(getClass());
+
+ private static final String VIRTUALPORT = "vtn-virtual-port";
+ private static final String VTNRSC_APP = "org.onosproject.vtnrsc";
+
+ private static final String VIRTUALPORT_ID_NULL = "VirtualPort ID cannot be null";
+ private static final String VIRTUALPORT_NOT_NULL = "VirtualPort cannot be null";
+ private static final String TENANTID_NOT_NULL = "TenantId cannot be null";
+ private static final String NETWORKID_NOT_NULL = "NetworkId cannot be null";
+ private static final String DEVICEID_NOT_NULL = "DeviceId cannot be null";
+
+ protected Map<VirtualPortId, VirtualPort> vPortStore;
+ protected ApplicationId appId;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected StorageService storageService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected TenantNetworkService networkService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Activate
+ public void activate() {
+
+ appId = coreService.registerApplication(VTNRSC_APP);
+
+ vPortStore = storageService.<VirtualPortId, VirtualPort>consistentMapBuilder()
+ .withName(VIRTUALPORT)
+ .withApplicationId(appId)
+ .withPurgeOnUninstall()
+ .withSerializer(Serializer.using(Arrays.asList(KryoNamespaces.API),
+ VirtualPortId.class,
+ TenantNetworkId.class,
+ VirtualPort.State.class,
+ TenantId.class,
+ AllowedAddressPair.class,
+ FixedIp.class,
+ BindingHostId.class,
+ SecurityGroup.class,
+ SubnetId.class,
+ IpAddress.class,
+ DefaultVirtualPort.class))
+ .build().asJavaMap();
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ vPortStore.clear();
+ log.info("Stoppped");
+ }
+
+ @Override
+ public boolean exists(VirtualPortId vPortId) {
+ checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
+ return vPortStore.containsKey(vPortId);
+ }
+
+ @Override
+ public VirtualPort getPort(VirtualPortId vPortId) {
+ checkNotNull(vPortId, VIRTUALPORT_ID_NULL);
+ return vPortStore.get(vPortId);
+ }
+
+ @Override
+ public Collection<VirtualPort> getPorts() {
+ return Collections.unmodifiableCollection(vPortStore.values());
+ }
+
+ @Override
+ public Collection<VirtualPort> getPorts(TenantNetworkId networkId) {
+ checkNotNull(networkId, NETWORKID_NOT_NULL);
+ Collection<VirtualPort> vPortWithNetworkIds = vPortStore.values();
+ for (VirtualPort vPort : vPortWithNetworkIds) {
+ if (!vPort.networkId().equals(networkId)) {
+ vPortWithNetworkIds.remove(vPort);
+ }
+ }
+ return vPortWithNetworkIds;
+ }
+
+ @Override
+ public Collection<VirtualPort> getPorts(TenantId tenantId) {
+ checkNotNull(tenantId, TENANTID_NOT_NULL);
+ Collection<VirtualPort> vPortWithTenantIds = vPortStore.values();
+ for (VirtualPort vPort : vPortWithTenantIds) {
+ if (!vPort.tenantId().equals(tenantId)) {
+ vPortWithTenantIds.remove(vPort);
+ }
+ }
+ return vPortWithTenantIds;
+ }
+
+ @Override
+ public Collection<VirtualPort> getPorts(DeviceId deviceId) {
+ checkNotNull(deviceId, DEVICEID_NOT_NULL);
+ Collection<VirtualPort> vPortWithDeviceIds = vPortStore.values();
+ for (VirtualPort vPort : vPortWithDeviceIds) {
+ if (!vPort.deviceId().equals(deviceId)) {
+ vPortWithDeviceIds.remove(vPort);
+ }
+ }
+ return vPortWithDeviceIds;
+ }
+
+ @Override
+ public boolean createPorts(Iterable<VirtualPort> vPorts) {
+ checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
+ for (VirtualPort vPort : vPorts) {
+ log.debug("vPortId is {} ", vPort.portId().toString());
+ vPortStore.put(vPort.portId(), vPort);
+ if (!vPortStore.containsKey(vPort.portId())) {
+ log.debug("The virtualPort is created failed whose identifier is {} ",
+ vPort.portId().toString());
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean updatePorts(Iterable<VirtualPort> vPorts) {
+ checkNotNull(vPorts, VIRTUALPORT_NOT_NULL);
+ if (vPorts != null) {
+ for (VirtualPort vPort : vPorts) {
+ vPortStore.put(vPort.portId(), vPort);
+ if (!vPortStore.containsKey(vPort.portId())) {
+ log.debug("The virtualPort is not exist whose identifier is {}",
+ vPort.portId().toString());
+ return false;
+ }
+
+ vPortStore.put(vPort.portId(), vPort);
+
+ if (!vPort.equals(vPortStore.get(vPort.portId()))) {
+ log.debug("The virtualPort is updated failed whose identifier is {}",
+ vPort.portId().toString());
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean removePorts(Iterable<VirtualPortId> vPortIds) {
+ checkNotNull(vPortIds, VIRTUALPORT_ID_NULL);
+ if (vPortIds != null) {
+ for (VirtualPortId vPortId : vPortIds) {
+ vPortStore.remove(vPortId);
+ if (vPortStore.containsKey(vPortId)) {
+ log.debug("The virtualPort is removed failed whose identifier is {}",
+ vPortId.toString());
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
new file mode 100644
index 00000000..24eb0d3f
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Implementation of service for interacting with the inventory of virtual ports.
+ */
+package org.onosproject.vtnrsc.virtualport.impl;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
new file mode 100644
index 00000000..06a01a04
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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 the inventory of virtual ports.
+ */
+package org.onosproject.vtnrsc.virtualport;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
index 4a6c3210..57c97c1c 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
@@ -1,40 +1,40 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.AllocationPool;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet AllocationPool codec.
- */
-public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {
-
- @Override
- public ObjectNode encode(AllocationPool alocPool, CodecContext context) {
- checkNotNull(alocPool, "AllocationPools cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("start", alocPool.startIp().toString())
- .put("end", alocPool.endIp().toString());
- return result;
- }
-
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.AllocationPool;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Subnet AllocationPool codec.
+ */
+public final class AllocationPoolsCodec extends JsonCodec<AllocationPool> {
+
+ @Override
+ public ObjectNode encode(AllocationPool alocPool, CodecContext context) {
+ checkNotNull(alocPool, "AllocationPools cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("start", alocPool.startIp().toString())
+ .put("end", alocPool.endIp().toString());
+ return result;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
index 6c5cc2e8..7960808f 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
@@ -1,40 +1,40 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort AllowedAddressPair codec.
- */
-public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
-
- @Override
- public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
- checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("ip_address", alocAddPair.ip().toString())
- .put("mac_address", alocAddPair.mac().toString());
- return result;
- }
-
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.AllowedAddressPair;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * VirtualPort AllowedAddressPair codec.
+ */
+public final class AllowedAddressPairCodec extends JsonCodec<AllowedAddressPair> {
+
+ @Override
+ public ObjectNode encode(AllowedAddressPair alocAddPair, CodecContext context) {
+ checkNotNull(alocAddPair, "AllowedAddressPair cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("ip_address", alocAddPair.ip().toString())
+ .put("mac_address", alocAddPair.mac().toString());
+ return result;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
index a69b8213..96c9bb4e 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
@@ -1,40 +1,40 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.FixedIp;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort FixedIp codec.
- */
-public final class FixedIpCodec extends JsonCodec<FixedIp> {
-
- @Override
- public ObjectNode encode(FixedIp fixIp, CodecContext context) {
- checkNotNull(fixIp, "FixedIp cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("subnet_id", fixIp.subnetId().toString())
- .put("ip_address", fixIp.ip().toString());
- return result;
- }
-
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.FixedIp;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * VirtualPort FixedIp codec.
+ */
+public final class FixedIpCodec extends JsonCodec<FixedIp> {
+
+ @Override
+ public ObjectNode encode(FixedIp fixIp, CodecContext context) {
+ checkNotNull(fixIp, "FixedIp cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("subnet_id", fixIp.subnetId().toString())
+ .put("ip_address", fixIp.ip().toString());
+ return result;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
index ba977a0b..69ca6b3f 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
@@ -1,40 +1,40 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.HostRoute;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet HostRoute codec.
- */
-public final class HostRoutesCodec extends JsonCodec<HostRoute> {
-
- @Override
- public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
- checkNotNull(hostRoute, "HostRoute cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("nexthop", hostRoute.nexthop().toString())
- .put("destination", hostRoute.destination().toString());
- return result;
- }
-
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.HostRoute;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Subnet HostRoute codec.
+ */
+public final class HostRoutesCodec extends JsonCodec<HostRoute> {
+
+ @Override
+ public ObjectNode encode(HostRoute hostRoute, CodecContext context) {
+ checkNotNull(hostRoute, "HostRoute cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("nexthop", hostRoute.nexthop().toString())
+ .put("destination", hostRoute.destination().toString());
+ return result;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
index 83bab6b1..c2ded196 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
@@ -1,39 +1,39 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.SecurityGroup;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Virtualport SecurityGroup codec.
- */
-public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {
-
- @Override
- public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {
- checkNotNull(securGroup, "SecurityGroup cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("security_group", securGroup.securityGroup());
- return result;
- }
-
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.SecurityGroup;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Virtualport SecurityGroup codec.
+ */
+public final class SecurityGroupCodec extends JsonCodec<SecurityGroup> {
+
+ @Override
+ public ObjectNode encode(SecurityGroup securGroup, CodecContext context) {
+ checkNotNull(securGroup, "SecurityGroup cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("security_group", securGroup.securityGroup());
+ return result;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
index afd561fe..122b75a9 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
@@ -1,53 +1,53 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.Subnet;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * Subnet JSON codec.
- */
-public final class SubnetCodec extends JsonCodec<Subnet> {
- @Override
- public ObjectNode encode(Subnet subnet, CodecContext context) {
- checkNotNull(subnet, "Subnet cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("id", subnet.id().toString())
- .put("gateway_ip", subnet.gatewayIp().toString())
- .put("network_id", subnet.networkId().toString())
- .put("name", subnet.subnetName().toString())
- .put("ip_version", subnet.ipVersion().toString())
- .put("cidr", subnet.cidr().toString())
- .put("shared", subnet.shared())
- .put("enabled_dchp", subnet.dhcpEnabled())
- .put("tenant_id", subnet.tenantId().toString())
- .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null
- : subnet.ipV6AddressMode().toString())
- .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null
- : subnet.ipV6RaMode().toString());
- result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet
- .allocationPools(), context));
- result.set("host_routes",
- new HostRoutesCodec().encode(subnet.hostRoutes(), context));
- return result;
- }
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.Subnet;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Subnet JSON codec.
+ */
+public final class SubnetCodec extends JsonCodec<Subnet> {
+ @Override
+ public ObjectNode encode(Subnet subnet, CodecContext context) {
+ checkNotNull(subnet, "Subnet cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("id", subnet.id().toString())
+ .put("gateway_ip", subnet.gatewayIp().toString())
+ .put("network_id", subnet.networkId().toString())
+ .put("name", subnet.subnetName())
+ .put("ip_version", subnet.ipVersion().toString())
+ .put("cidr", subnet.cidr().toString())
+ .put("shared", subnet.shared())
+ .put("enabled_dchp", subnet.dhcpEnabled())
+ .put("tenant_id", subnet.tenantId().toString())
+ .put("ipv6_address_mode", subnet.ipV6AddressMode() == null ? null
+ : subnet.ipV6AddressMode().toString())
+ .put("ipv6_ra_mode", subnet.ipV6RaMode() == null ? null
+ : subnet.ipV6RaMode().toString());
+ result.set("allocation_pools", new AllocationPoolsCodec().encode(subnet
+ .allocationPools(), context));
+ result.set("host_routes",
+ new HostRoutesCodec().encode(subnet.hostRoutes(), context));
+ return result;
+ }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
index 07ae9f8e..48ba3b97 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
@@ -1,47 +1,47 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.TenantNetwork;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * TenantNetwork JSON codec.
- */
-public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {
-
- @Override
- public ObjectNode encode(TenantNetwork network, CodecContext context) {
- checkNotNull(network, "Network cannot be null");
- ObjectNode result = context.mapper().createObjectNode()
- .put("id", network.id().toString())
- .put("name", network.name().toString())
- .put("admin_state_up", network.adminStateUp())
- .put("status", "" + network.state())
- .put("shared", network.shared())
- .put("tenant_id", network.tenantId().toString())
- .put("router:external", network.routerExternal())
- .put("provider:network_type", "" + network.type())
- .put("provider:physical_network", network.physicalNetwork().toString())
- .put("provider:segmentation_id", network.segmentationId().toString());
- return result;
- }
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.TenantNetwork;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * TenantNetwork JSON codec.
+ */
+public final class TenantNetworkCodec extends JsonCodec<TenantNetwork> {
+
+ @Override
+ public ObjectNode encode(TenantNetwork network, CodecContext context) {
+ checkNotNull(network, "Network cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("id", network.id().toString())
+ .put("name", network.name())
+ .put("admin_state_up", network.adminStateUp())
+ .put("status", "" + network.state())
+ .put("shared", network.shared())
+ .put("tenant_id", network.tenantId().toString())
+ .put("router:external", network.routerExternal())
+ .put("provider:network_type", "" + network.type())
+ .put("provider:physical_network", network.physicalNetwork().toString())
+ .put("provider:segmentation_id", network.segmentationId().toString());
+ return result;
+ }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
index aa3c0c73..e57d56bc 100644
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
@@ -1,57 +1,57 @@
-/*
- * 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.web;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-import org.onosproject.codec.CodecContext;
-import org.onosproject.codec.JsonCodec;
-import org.onosproject.vtnrsc.VirtualPort;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-
-/**
- * VirtualPort JSON codec.
- */
-public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
- @Override
- public ObjectNode encode(VirtualPort vPort, CodecContext context) {
- checkNotNull(vPort, "VPort cannot be null");
- ObjectNode result = context
- .mapper()
- .createObjectNode()
- .put("id", vPort.portId().toString())
- .put("network_id", vPort.networkId().toString())
- .put("admin_state_up", vPort.adminStateUp())
- .put("name", vPort.name().toString())
- .put("status", vPort.state().toString())
- .put("mac_address", vPort.macAddress().toString())
- .put("tenant_id", vPort.tenantId().toString())
- .put("device_id", vPort.deviceId().toString())
- .put("device_owner", vPort.deviceOwner().toString())
- .put("binding:vnic_type", vPort.bindingVnicType().toString())
- .put("binding:Vif_type", vPort.bindingVifType().toString())
- .put("binding:host_id", vPort.bindingHostId().toString())
- .put("binding:vif_details", vPort.bindingVifDetails().toString());
- result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
- vPort.allowedAddressPairs(), context));
- result.set("fixed_ips", new FixedIpCodec().encode(
- vPort.fixedIps(), context));
- result.set("security_groups", new SecurityGroupCodec().encode(
- vPort.securityGroups(), context));
- return result;
- }
-}
+/*
+ * 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.web;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.VirtualPort;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * VirtualPort JSON codec.
+ */
+public final class VirtualPortCodec extends JsonCodec<VirtualPort> {
+ @Override
+ public ObjectNode encode(VirtualPort vPort, CodecContext context) {
+ checkNotNull(vPort, "VPort cannot be null");
+ ObjectNode result = context
+ .mapper()
+ .createObjectNode()
+ .put("id", vPort.portId().toString())
+ .put("network_id", vPort.networkId().toString())
+ .put("admin_state_up", vPort.adminStateUp())
+ .put("name", vPort.name())
+ .put("status", vPort.state().toString())
+ .put("mac_address", vPort.macAddress().toString())
+ .put("tenant_id", vPort.tenantId().toString())
+ .put("device_id", vPort.deviceId().toString())
+ .put("device_owner", vPort.deviceOwner())
+ .put("binding:vnic_type", vPort.bindingVnicType())
+ .put("binding:Vif_type", vPort.bindingVifType())
+ .put("binding:host_id", vPort.bindingHostId().toString())
+ .put("binding:vif_details", vPort.bindingVifDetails());
+ result.set("allowed_address_pairs", new AllowedAddressPairCodec().encode(
+ vPort.allowedAddressPairs(), context));
+ result.set("fixed_ips", new FixedIpCodec().encode(
+ vPort.fixedIps(), context));
+ result.set("security_groups", new SecurityGroupCodec().encode(
+ vPort.securityGroups(), context));
+ return result;
+ }
+}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java
new file mode 100644
index 00000000..34636a9f
--- /dev/null
+++ b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * Codecs for virtual tenant objects.
+ */
+package org.onosproject.vtnrsc.web;
diff --git a/framework/src/onos/apps/vtnweb/pom.xml b/framework/src/onos/apps/vtnweb/pom.xml
index 974d3bf1..543bcfbb 100644
--- a/framework/src/onos/apps/vtnweb/pom.xml
+++ b/framework/src/onos/apps/vtnweb/pom.xml
@@ -1,76 +1,88 @@
<?xml version="1.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.
+ -->
<project
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
- xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
- <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
+ xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
- <artifactId>onos-app-vtnweb</artifactId>
- <packaging>bundle</packaging>
- <properties>
- <onos.app.name>org.onosproject.vtnweb</onos.app.name>
- <web.context>/onos/vtn</web.context>
- </properties>
+ <artifactId>onos-app-vtnweb</artifactId>
+ <packaging>bundle</packaging>
+ <properties>
+ <onos.app.name>org.onosproject.vtnweb</onos.app.name>
+ <web.context>/onos/vtn</web.context>
+ </properties>
- <dependencies>
- <dependency>
- <groupId>javax.ws.rs</groupId>
- <artifactId>jsr311-api</artifactId>
- <version>1.1.1</version>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-api</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onos-app-vtnrsc</artifactId>
- <version>${project.version}</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <_wab>src/main/webapp/</_wab>
- <Bundle-SymbolicName>
- ${project.groupId}.${project.artifactId}
- </Bundle-SymbolicName>
- <Import-Package>
- org.slf4j,
- org.osgi.framework,
- javax.ws.rs,
- javax.ws.rs.core,
- com.sun.jersey.api.core,
- com.sun.jersey.spi.container.servlet,
- com.sun.jersey.server.impl.container.servlet,
- com.fasterxml.jackson.databind,
- com.fasterxml.jackson.databind.node,
- com.fasterxml.jackson.core,
- org.apache.karaf.shell.commands,
- org.apache.commons.lang.math.*,
- com.google.common.*,
- org.onlab.packet.*,
- org.onlab.rest.*,
- org.onosproject.*,
- org.onlab.util.*,
- org.jboss.netty.util.*
- </Import-Package>
- <Web-ContextPath>${web.context}</Web-ContextPath>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <dependencies>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-app-vtnrsc</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <_wab>src/main/webapp/</_wab>
+ <Bundle-SymbolicName>
+ ${project.groupId}.${project.artifactId}
+ </Bundle-SymbolicName>
+ <Import-Package>
+ org.slf4j,
+ org.osgi.framework,
+ javax.ws.rs,
+ javax.ws.rs.core,
+ com.sun.jersey.api.core,
+ com.sun.jersey.spi.container.servlet,
+ com.sun.jersey.server.impl.container.servlet,
+ com.fasterxml.jackson.databind,
+ com.fasterxml.jackson.databind.node,
+ com.fasterxml.jackson.core,
+ org.apache.karaf.shell.commands,
+ org.apache.commons.lang.math.*,
+ com.google.common.*,
+ org.onlab.packet.*,
+ org.onlab.rest.*,
+ org.onosproject.*,
+ org.onlab.util.*,
+ org.jboss.netty.util.*
+ </Import-Package>
+ <Web-ContextPath>${web.context}</Web-ContextPath>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
</project> \ No newline at end of file
diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
index c46af6ef..3979e1e3 100644
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
+++ b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
@@ -1,365 +1,365 @@
-/*
- * 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.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultAllocationPool;
-import org.onosproject.vtnrsc.DefaultHostRoute;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-import org.onosproject.vtnrsc.web.SubnetCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-@Path("subnets")
-public class SubnetWebResource extends AbstractWebResource {
- private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);
- public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!";
- public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- @GET
- @Produces(MediaType.APPLICATION_JSON)
- public Response listSubnets() {
- Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("subnets", new SubnetCodec().encode(subnets, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- public Response getSubnet(@PathParam("subnetUUID") String id) {
-
- if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
- return ok("The subnet does not exists").build();
- }
- Subnet sub = nullIsNotFound(get(SubnetService.class)
- .getSubnet(SubnetId.subnetId(id)),
- SUBNET_NOT_FOUND);
-
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("subnet", new SubnetCodec().encode(sub, this));
- return ok(result.toString()).build();
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createSubnet(final InputStream input) {
-
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = mapper.readTree(input);
- Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound((get(SubnetService.class)
- .createSubnets(subnets)),
- SUBNET_NOT_CREATE);
-
- if (!result) {
- return Response.status(204).entity(SUBNET_NOT_CREATE).build();
- }
- return Response.status(202).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{subnetUUID}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateSubnet(@PathParam("id") String id,
- final InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode subnode = mapper.readTree(input);
- Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
- Boolean result = nullIsNotFound(get(SubnetService.class)
- .updateSubnets(subnets), SUBNET_NOT_FOUND);
- if (!result) {
- return Response.status(204).entity(SUBNET_NOT_FOUND).build();
- }
- return Response.status(203).entity(result.toString()).build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @Path("{subnetUUID}")
- @DELETE
- public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
- throws IOException {
- try {
- SubnetId subId = SubnetId.subnetId(id);
- Set<SubnetId> subIds = new HashSet<SubnetId>();
- subIds.add(subId);
- get(SubnetService.class).removeSubnets(subIds);
- return Response.status(201).entity("SUCCESS").build();
- } catch (Exception e) {
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {
- checkNotNull(subnode, JSON_NOT_NULL);
- Iterable<Subnet> subnets = null;
- JsonNode subnetNodes = subnode.get("subnets");
- if (subnetNodes == null) {
- subnetNodes = subnode.get("subnet");
- }
- log.debug("subnetNodes is {}", subnetNodes.toString());
- if (subnetNodes.isArray()) {
- subnets = changeJsonToSubs(subnetNodes);
- } else {
- subnets = changeJsonToSub(subnetNodes);
- }
- return subnets;
- }
-
- /**
- * Returns a collection of subnets from subnetNodes.
- *
- * @param subnetNodes the subnet json node
- * @return subnets a collection of subnets
- */
- public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
- checkNotNull(subnetNodes, JSON_NOT_NULL);
- Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
- for (JsonNode subnetNode : subnetNodes) {
- if (!subnetNode.hasNonNull("id")) {
- return null;
- }
- SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
- String subnetName = subnetNode.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(subnetNode.get("tenant_id").asText());
- TenantNetworkId networkId = TenantNetworkId
- .networkId(subnetNode.get("network_id").asText());
- Version ipVersion = Version
- .valueOf(subnetNode.get("ip_version").asText());
- IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
- IpAddress gatewayIp = IpAddress
- .valueOf(subnetNode.get("gateway_ip").asText());
- Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
- Boolean shared = subnetNode.get("shared").asBoolean();
- JsonNode hostRoutes = subnetNode.get("host_routes");
- Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
- JsonNode allocationPools = subnetNode.get("allocation_pools");
- Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
- Mode ipV6AddressMode = Mode
- .valueOf(subnetNode.get("ipv6_address_mode").asText());
- Mode ipV6RaMode = Mode
- .valueOf(subnetNode.get("ipv6_ra_mode").asText());
- Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
- tenantId, ipVersion, cidr,
- gatewayIp, dhcpEnabled, shared,
- Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
- ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
- subMap.put(id, subnet);
- }
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Returns a collection of subnets from subnetNodes.
- *
- * @param subnetNodes the subnet json node
- * @return subnets a collection of subnets
- */
- public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
- checkNotNull(subnetNodes, JSON_NOT_NULL);
- checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
- checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
- Map<SubnetId, Subnet> subMap = new HashMap<SubnetId, Subnet>();
- if (!subnetNodes.hasNonNull("id")) {
- return null;
- }
- SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
- String subnetName = subnetNodes.get("name").asText();
- TenantId tenantId = TenantId
- .tenantId(subnetNodes.get("tenant_id").asText());
- TenantNetworkId networkId = TenantNetworkId
- .networkId(subnetNodes.get("network_id").asText());
- String version = subnetNodes.get("ip_version").asText();
- Version ipVersion;
- switch (version) {
- case "4":
- ipVersion = Version.INET;
- break;
- case "6":
- ipVersion = Version.INET;
- break;
- default:
- throw new IllegalArgumentException("ipVersion should be 4 or 6.");
- }
-
- IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
- IpAddress gatewayIp = IpAddress
- .valueOf(subnetNodes.get("gateway_ip").asText());
- Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
- Boolean shared = subnetNodes.get("shared").asBoolean();
- JsonNode hostRoutes = subnetNodes.get("host_routes");
- Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
- JsonNode allocationPools = subnetNodes.get("allocation_pools");
- Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
-
- Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
- .asText());
- Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
-
- Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
- ipVersion, cidr, gatewayIp,
- dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
- ipV6AddressMode, ipV6RaMode,
- Sets.newHashSet(allocationPoolsIt));
- subMap.put(id, subnet);
- return Collections.unmodifiableCollection(subMap.values());
- }
-
- /**
- * Gets ipv6_address_mode or ipv6_ra_mode type.
- *
- * @param mode the String value in JsonNode
- * @return ipV6Mode Mode of the ipV6Mode
- */
- private Mode getMode(String mode) {
- Mode ipV6Mode;
- if (mode == null) {
- return null;
- }
- switch (mode) {
- case "dhcpv6-stateful":
- ipV6Mode = Mode.DHCPV6_STATEFUL;
- break;
- case "dhcpv6-stateless":
- ipV6Mode = Mode.DHCPV6_STATELESS;
- break;
- case "slaac":
- ipV6Mode = Mode.SLAAC;
- break;
- default:
- ipV6Mode = null;
- }
- return ipV6Mode;
- }
-
- /**
- * Changes JsonNode alocPools to a collection of the alocPools.
- *
- * @param allocationPools the allocationPools JsonNode
- * @return a collection of allocationPools
- */
- public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
- checkNotNull(allocationPools, JSON_NOT_NULL);
- ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
- .newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : allocationPools) {
- IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
- IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
- AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
- alocplMaps.putIfAbsent(i, alocPls);
- i++;
- }
- return Collections.unmodifiableCollection(alocplMaps.values());
- }
-
- /**
- * Changes hostRoutes JsonNode to a collection of the hostRoutes.
- *
- * @param hostRoutes the hostRoutes json node
- * @return a collection of hostRoutes
- */
- public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
- checkNotNull(hostRoutes, JSON_NOT_NULL);
- ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
- .newConcurrentMap();
- Integer i = 0;
- for (JsonNode node : hostRoutes) {
- IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
- IpPrefix destination = IpPrefix.valueOf(node.get("destination")
- .asText());
- HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
- hostRouteMaps.putIfAbsent(i, hostRoute);
- i++;
- }
- return Collections.unmodifiableCollection(hostRouteMaps.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-
-}
+/*
+ * 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.vtnweb.resources;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.IpAddress.Version;
+import org.onlab.packet.IpPrefix;
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.vtnrsc.AllocationPool;
+import org.onosproject.vtnrsc.DefaultAllocationPool;
+import org.onosproject.vtnrsc.DefaultHostRoute;
+import org.onosproject.vtnrsc.DefaultSubnet;
+import org.onosproject.vtnrsc.HostRoute;
+import org.onosproject.vtnrsc.Subnet;
+import org.onosproject.vtnrsc.SubnetId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.Subnet.Mode;
+import org.onosproject.vtnrsc.subnet.SubnetService;
+import org.onosproject.vtnrsc.web.SubnetCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+@Path("subnets")
+public class SubnetWebResource extends AbstractWebResource {
+ private final Logger log = LoggerFactory.getLogger(SubnetWebResource.class);
+ public static final String SUBNET_NOT_CREATE = "Subnets is failed to create!";
+ public static final String SUBNET_NOT_FOUND = "Subnets is failed to update!";
+ public static final String JSON_NOT_NULL = "JsonNode can not be null";
+
+ @GET
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response listSubnets() {
+ Iterable<Subnet> subnets = get(SubnetService.class).getSubnets();
+ ObjectNode result = new ObjectMapper().createObjectNode();
+ result.set("subnets", new SubnetCodec().encode(subnets, this));
+ return ok(result.toString()).build();
+ }
+
+ @GET
+ @Path("{subnetUUID}")
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response getSubnet(@PathParam("subnetUUID") String id) {
+
+ if (!get(SubnetService.class).exists(SubnetId.subnetId(id))) {
+ return ok("The subnet does not exists").build();
+ }
+ Subnet sub = nullIsNotFound(get(SubnetService.class)
+ .getSubnet(SubnetId.subnetId(id)),
+ SUBNET_NOT_FOUND);
+
+ ObjectNode result = new ObjectMapper().createObjectNode();
+ result.set("subnet", new SubnetCodec().encode(sub, this));
+ return ok(result.toString()).build();
+ }
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response createSubnet(final InputStream input) {
+
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode subnode = mapper.readTree(input);
+ Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
+ Boolean result = nullIsNotFound((get(SubnetService.class)
+ .createSubnets(subnets)),
+ SUBNET_NOT_CREATE);
+
+ if (!result) {
+ return Response.status(204).entity(SUBNET_NOT_CREATE).build();
+ }
+ return Response.status(202).entity(result.toString()).build();
+ } catch (Exception e) {
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ @PUT
+ @Path("{subnetUUID}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response updateSubnet(@PathParam("id") String id,
+ final InputStream input) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode subnode = mapper.readTree(input);
+ Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
+ Boolean result = nullIsNotFound(get(SubnetService.class)
+ .updateSubnets(subnets), SUBNET_NOT_FOUND);
+ if (!result) {
+ return Response.status(204).entity(SUBNET_NOT_FOUND).build();
+ }
+ return Response.status(203).entity(result.toString()).build();
+ } catch (Exception e) {
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ @Path("{subnetUUID}")
+ @DELETE
+ public Response deleteSingleSubnet(@PathParam("subnetUUID") String id)
+ throws IOException {
+ try {
+ SubnetId subId = SubnetId.subnetId(id);
+ Set<SubnetId> subIds = new HashSet<>();
+ subIds.add(subId);
+ get(SubnetService.class).removeSubnets(subIds);
+ return Response.status(201).entity("SUCCESS").build();
+ } catch (Exception e) {
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ private Iterable<Subnet> createOrUpdateByInputStream(JsonNode subnode) {
+ checkNotNull(subnode, JSON_NOT_NULL);
+ Iterable<Subnet> subnets = null;
+ JsonNode subnetNodes = subnode.get("subnets");
+ if (subnetNodes == null) {
+ subnetNodes = subnode.get("subnet");
+ }
+ log.debug("subnetNodes is {}", subnetNodes.toString());
+ if (subnetNodes.isArray()) {
+ subnets = changeJsonToSubs(subnetNodes);
+ } else {
+ subnets = changeJsonToSub(subnetNodes);
+ }
+ return subnets;
+ }
+
+ /**
+ * Returns a collection of subnets from subnetNodes.
+ *
+ * @param subnetNodes the subnet json node
+ * @return subnets a collection of subnets
+ */
+ public Iterable<Subnet> changeJsonToSubs(JsonNode subnetNodes) {
+ checkNotNull(subnetNodes, JSON_NOT_NULL);
+ Map<SubnetId, Subnet> subMap = new HashMap<>();
+ for (JsonNode subnetNode : subnetNodes) {
+ if (!subnetNode.hasNonNull("id")) {
+ return null;
+ }
+ SubnetId id = SubnetId.subnetId(subnetNode.get("id").asText());
+ String subnetName = subnetNode.get("name").asText();
+ TenantId tenantId = TenantId
+ .tenantId(subnetNode.get("tenant_id").asText());
+ TenantNetworkId networkId = TenantNetworkId
+ .networkId(subnetNode.get("network_id").asText());
+ Version ipVersion = Version
+ .valueOf(subnetNode.get("ip_version").asText());
+ IpPrefix cidr = IpPrefix.valueOf(subnetNode.get("cidr").asText());
+ IpAddress gatewayIp = IpAddress
+ .valueOf(subnetNode.get("gateway_ip").asText());
+ Boolean dhcpEnabled = subnetNode.get("enable_dhcp").asBoolean();
+ Boolean shared = subnetNode.get("shared").asBoolean();
+ JsonNode hostRoutes = subnetNode.get("host_routes");
+ Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
+ JsonNode allocationPools = subnetNode.get("allocation_pools");
+ Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
+ Mode ipV6AddressMode = Mode
+ .valueOf(subnetNode.get("ipv6_address_mode").asText());
+ Mode ipV6RaMode = Mode
+ .valueOf(subnetNode.get("ipv6_ra_mode").asText());
+ Subnet subnet = new DefaultSubnet(id, subnetName, networkId,
+ tenantId, ipVersion, cidr,
+ gatewayIp, dhcpEnabled, shared,
+ Sets.newHashSet(hostRoutesIt), ipV6AddressMode,
+ ipV6RaMode, Sets.newHashSet(allocationPoolsIt));
+ subMap.put(id, subnet);
+ }
+ return Collections.unmodifiableCollection(subMap.values());
+ }
+
+ /**
+ * Returns a collection of subnets from subnetNodes.
+ *
+ * @param subnetNodes the subnet json node
+ * @return subnets a collection of subnets
+ */
+ public Iterable<Subnet> changeJsonToSub(JsonNode subnetNodes) {
+ checkNotNull(subnetNodes, JSON_NOT_NULL);
+ checkArgument(subnetNodes.get("enable_dhcp").isBoolean(), "enable_dhcp should be boolean");
+ checkArgument(subnetNodes.get("shared").isBoolean(), "shared should be boolean");
+ Map<SubnetId, Subnet> subMap = new HashMap<>();
+ if (!subnetNodes.hasNonNull("id")) {
+ return null;
+ }
+ SubnetId id = SubnetId.subnetId(subnetNodes.get("id").asText());
+ String subnetName = subnetNodes.get("name").asText();
+ TenantId tenantId = TenantId
+ .tenantId(subnetNodes.get("tenant_id").asText());
+ TenantNetworkId networkId = TenantNetworkId
+ .networkId(subnetNodes.get("network_id").asText());
+ String version = subnetNodes.get("ip_version").asText();
+ Version ipVersion;
+ switch (version) {
+ case "4":
+ ipVersion = Version.INET;
+ break;
+ case "6":
+ ipVersion = Version.INET;
+ break;
+ default:
+ throw new IllegalArgumentException("ipVersion should be 4 or 6.");
+ }
+
+ IpPrefix cidr = IpPrefix.valueOf(subnetNodes.get("cidr").asText());
+ IpAddress gatewayIp = IpAddress
+ .valueOf(subnetNodes.get("gateway_ip").asText());
+ Boolean dhcpEnabled = subnetNodes.get("enable_dhcp").asBoolean();
+ Boolean shared = subnetNodes.get("shared").asBoolean();
+ JsonNode hostRoutes = subnetNodes.get("host_routes");
+ Iterable<HostRoute> hostRoutesIt = jsonNodeToHostRoutes(hostRoutes);
+ JsonNode allocationPools = subnetNodes.get("allocation_pools");
+ Iterable<AllocationPool> allocationPoolsIt = jsonNodeToAllocationPools(allocationPools);
+
+ Mode ipV6AddressMode = getMode(subnetNodes.get("ipv6_address_mode")
+ .asText());
+ Mode ipV6RaMode = getMode(subnetNodes.get("ipv6_ra_mode").asText());
+
+ Subnet subnet = new DefaultSubnet(id, subnetName, networkId, tenantId,
+ ipVersion, cidr, gatewayIp,
+ dhcpEnabled, shared, Sets.newHashSet(hostRoutesIt),
+ ipV6AddressMode, ipV6RaMode,
+ Sets.newHashSet(allocationPoolsIt));
+ subMap.put(id, subnet);
+ return Collections.unmodifiableCollection(subMap.values());
+ }
+
+ /**
+ * Gets ipv6_address_mode or ipv6_ra_mode type.
+ *
+ * @param mode the String value in JsonNode
+ * @return ipV6Mode Mode of the ipV6Mode
+ */
+ private Mode getMode(String mode) {
+ Mode ipV6Mode;
+ if (mode == null) {
+ return null;
+ }
+ switch (mode) {
+ case "dhcpv6-stateful":
+ ipV6Mode = Mode.DHCPV6_STATEFUL;
+ break;
+ case "dhcpv6-stateless":
+ ipV6Mode = Mode.DHCPV6_STATELESS;
+ break;
+ case "slaac":
+ ipV6Mode = Mode.SLAAC;
+ break;
+ default:
+ ipV6Mode = null;
+ }
+ return ipV6Mode;
+ }
+
+ /**
+ * Changes JsonNode alocPools to a collection of the alocPools.
+ *
+ * @param allocationPools the allocationPools JsonNode
+ * @return a collection of allocationPools
+ */
+ public Iterable<AllocationPool> jsonNodeToAllocationPools(JsonNode allocationPools) {
+ checkNotNull(allocationPools, JSON_NOT_NULL);
+ ConcurrentMap<Integer, AllocationPool> alocplMaps = Maps
+ .newConcurrentMap();
+ Integer i = 0;
+ for (JsonNode node : allocationPools) {
+ IpAddress startIp = IpAddress.valueOf(node.get("start").asText());
+ IpAddress endIp = IpAddress.valueOf(node.get("end").asText());
+ AllocationPool alocPls = new DefaultAllocationPool(startIp, endIp);
+ alocplMaps.putIfAbsent(i, alocPls);
+ i++;
+ }
+ return Collections.unmodifiableCollection(alocplMaps.values());
+ }
+
+ /**
+ * Changes hostRoutes JsonNode to a collection of the hostRoutes.
+ *
+ * @param hostRoutes the hostRoutes json node
+ * @return a collection of hostRoutes
+ */
+ public Iterable<HostRoute> jsonNodeToHostRoutes(JsonNode hostRoutes) {
+ checkNotNull(hostRoutes, JSON_NOT_NULL);
+ ConcurrentMap<Integer, HostRoute> hostRouteMaps = Maps
+ .newConcurrentMap();
+ Integer i = 0;
+ for (JsonNode node : hostRoutes) {
+ IpAddress nexthop = IpAddress.valueOf(node.get("nexthop").asText());
+ IpPrefix destination = IpPrefix.valueOf(node.get("destination")
+ .asText());
+ HostRoute hostRoute = new DefaultHostRoute(nexthop, destination);
+ hostRouteMaps.putIfAbsent(i, hostRoute);
+ i++;
+ }
+ return Collections.unmodifiableCollection(hostRouteMaps.values());
+ }
+
+ /**
+ * Returns the specified item if that items is null; otherwise throws not
+ * found exception.
+ *
+ * @param item item to check
+ * @param <T> item type
+ * @param message not found message
+ * @return item if not null
+ * @throws org.onlab.util.ItemNotFoundException if item is null
+ */
+ protected <T> T nullIsNotFound(T item, String message) {
+ if (item == null) {
+ throw new ItemNotFoundException(message);
+ }
+ return item;
+ }
+
+}
diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
index 7a0d43d2..b3888db1 100644
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
+++ b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
@@ -1,372 +1,371 @@
-/*
- * 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.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkArgument;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.OK;
-
-import java.io.InputStream;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.rest.AbstractWebResource;
-import org.onosproject.vtnrsc.DefaultTenantNetwork;
-import org.onosproject.vtnrsc.PhysicalNetwork;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.TenantNetwork.State;
-import org.onosproject.vtnrsc.TenantNetwork.Type;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.web.TenantNetworkCodec;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.Maps;
-
-/**
- * REST resource for interacting with the inventory of networks.
- */
-@Path("networks")
-public class TenantNetworkWebResource extends AbstractWebResource {
- public static final String NETWORK_NOT_FOUND = "Network is not found";
- public static final String NETWORK_ID_EXIST = "Network id is existed";
- public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";
- public static final String CREATE_NETWORK = "create network";
- public static final String UPDATE_NETWORK = "update network";
- public static final String DELETE_NETWORK = "delete network";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
-
- protected static final Logger log = LoggerFactory
- .getLogger(TenantNetworkWebResource.class);
- private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getNetworks(@QueryParam("id") String queryId,
- @QueryParam("name") String queryName,
- @QueryParam("admin_state_up") String queryadminStateUp,
- @QueryParam("status") String querystate,
- @QueryParam("shared") String queryshared,
- @QueryParam("tenant_id") String querytenantId,
- @QueryParam("router:external") String routerExternal,
- @QueryParam("provider:network_type") String type,
- @QueryParam("provider:physical_network") String physicalNetwork,
- @QueryParam("provider:segmentation_id") String segmentationId) {
- Iterable<TenantNetwork> networks = get(TenantNetworkService.class)
- .getNetworks();
- Iterator<TenantNetwork> networkors = networks.iterator();
- while (networkors.hasNext()) {
- TenantNetwork network = networkors.next();
- if ((queryId == null || queryId.equals(network.id().toString()))
- && (queryName == null || queryName.equals(network.name()
- .toString()))
- && (queryadminStateUp == null || queryadminStateUp
- .equals(network.adminStateUp()))
- && (querystate == null || querystate.equals(network.state()
- .toString()))
- && (queryshared == null || queryshared.equals(network
- .shared()))
- && (querytenantId == null || querytenantId.equals(network
- .tenantId().toString()))
- && (routerExternal == null || routerExternal.equals(network
- .routerExternal()))
- && (type == null || type.equals(network.type()))
- && (physicalNetwork == null || physicalNetwork
- .equals(network.physicalNetwork()))
- && (segmentationId == null || segmentationId.equals(network
- .segmentationId()))) {
- networksMap.putIfAbsent(network.id(), network);
- }
- }
- networks = Collections.unmodifiableCollection(networksMap.values());
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("networks", new TenantNetworkCodec().encode(networks, this));
-
- return ok(result.toString()).build();
- }
-
- private State isState(String state) {
- if (state.equals("ACTIVE")) {
- return TenantNetwork.State.ACTIVE;
- } else if (state.equals("BUILD")) {
- return TenantNetwork.State.BUILD;
- } else if (state.equals("DOWN")) {
- return TenantNetwork.State.DOWN;
- } else if (state.equals("ERROR")) {
- return TenantNetwork.State.ERROR;
- } else {
- return null;
- }
- }
-
- private Type isType(String type) {
- if (type.equals("LOCAL")) {
- return TenantNetwork.Type.LOCAL;
- } else {
- return null;
- }
- }
-
- @GET
- @Path("{id}")
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getNetwork(@PathParam("id") String id) {
-
- if (!get(TenantNetworkService.class).exists(TenantNetworkId
- .networkId(id))) {
- return ok("The tenantNetwork does not exists").build();
- }
- TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)
- .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("network", new TenantNetworkCodec().encode(network, this));
-
- return ok(result.toString()).build();
-
- }
-
- @POST
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response createNetworks(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- JsonNode nodes = null;
- Iterable<TenantNetwork> networks = null;
- if (cfg.get("network") != null) {
- nodes = cfg.get("network");
- if (nodes.isArray()) {
- networks = changeJson2objs(nodes);
- } else {
- networks = changeJson2obj(CREATE_NETWORK, null, nodes);
- }
- } else if (cfg.get("networks") != null) {
- nodes = cfg.get("networks");
- networks = changeJson2objs(nodes);
- }
- Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
- .createNetworks(networks)),
- NETWORK_NOT_FOUND);
-
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Creates tenantNetwork exception {}.", e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{id}")
- @Produces(MediaType.APPLICATION_JSON)
- @Consumes(MediaType.APPLICATION_JSON)
- public Response updateNetworks(@PathParam("id") String id, InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- JsonNode nodes = null;
- Iterable<TenantNetwork> networks = null;
- if (cfg.get("network") != null) {
- nodes = cfg.get("network");
- if (nodes.isArray()) {
- networks = changeJson2objs(nodes);
- } else {
- networks = changeJson2obj(UPDATE_NETWORK,
- TenantNetworkId.networkId(id),
- nodes);
- }
- } else if (cfg.get("networks") != null) {
- nodes = cfg.get("networks");
- networks = changeJson2objs(nodes);
- }
- Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
- .updateNetworks(networks)),
- NETWORK_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Updates tenantNetwork failed because of exception {}.",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @DELETE
- @Path("{id}")
- public Response deleteNetworks(@PathParam("id") String id) {
- log.debug("Deletes network by identifier {}.", id);
- Set<TenantNetworkId> networkSet = new HashSet<TenantNetworkId>();
- networkSet.add(TenantNetworkId.networkId(id));
- Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
- .removeNetworks(networkSet), NETWORK_NOT_FOUND);
- if (!issuccess) {
- log.debug("Network identifier {} is not existed", id);
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(NETWORK_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- }
-
- /**
- * Returns a collection of tenantNetworks.
- *
- * @param flag the flag
- * @param networkId network identifier
- * @param node the network json node
- * @return a collection of tenantNetworks
- */
- public Iterable<TenantNetwork> changeJson2obj(String flag,
- TenantNetworkId networkId,
- JsonNode node) {
- checkNotNull(node, JSON_NOT_NULL);
- TenantNetwork network = null;
- ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
- if (node != null) {
- checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
- checkArgument(node.get("shared").isBoolean(), "shared should be boolean");
- checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");
- String name = node.get("name").asText();
- boolean adminStateUp = node.get("admin_state_up").asBoolean();
- String state = node.get("status").asText();
- boolean shared = node.get("shared").asBoolean();
- String tenantId = node.get("tenant_id").asText();
- boolean routerExternal = node.get("router:external").asBoolean();
- String type = node.get("provider:network_type").asText();
- String physicalNetwork = node.get("provider:physical_network")
- .asText();
- String segmentationId = node.get("provider:segmentation_id")
- .asText();
- TenantNetworkId id = null;
- if (flag == CREATE_NETWORK) {
- id = TenantNetworkId.networkId(node.get("id").asText());
- } else if (flag == UPDATE_NETWORK) {
- id = networkId;
- }
- network = new DefaultTenantNetwork(
- id,
- name,
- adminStateUp,
- isState(state),
- shared,
- TenantId.tenantId(tenantId),
- routerExternal,
- isType(type),
- PhysicalNetwork
- .physicalNetwork(physicalNetwork),
- SegmentationId
- .segmentationId(segmentationId));
- networksMap.putIfAbsent(id, network);
- }
- return Collections.unmodifiableCollection(networksMap.values());
- }
-
- /**
- * Returns a collection of tenantNetworks.
- *
- * @param nodes the network jsonnodes
- * @return a collection of tenantNetworks
- */
- public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {
- checkNotNull(nodes, JSON_NOT_NULL);
- TenantNetwork network = null;
- ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
- .newConcurrentMap();
- if (nodes != null) {
- for (JsonNode node : nodes) {
- String id = node.get("id").asText();
- String name = node.get("name").asText();
- boolean adminStateUp = node.get("admin_state_up").asBoolean();
- String state = node.get("status").asText();
- boolean shared = node.get("shared").asBoolean();
- String tenantId = node.get("tenant_id").asText();
- boolean routerExternal = node.get("router:external")
- .asBoolean();
- String type = node.get("provider:network_type").asText();
- String physicalNetwork = node.get("provider:physical_network")
- .asText();
- String segmentationId = node.get("provider:segmentation_id")
- .asText();
- network = new DefaultTenantNetwork(
- TenantNetworkId
- .networkId(id),
- name,
- adminStateUp,
- isState(state),
- shared,
- TenantId.tenantId(tenantId),
- routerExternal,
- isType(type),
- PhysicalNetwork
- .physicalNetwork(physicalNetwork),
- SegmentationId
- .segmentationId(segmentationId));
- networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);
- }
- }
- return Collections.unmodifiableCollection(networksMap.values());
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
+/*
+ * 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.vtnweb.resources;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkArgument;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+import static javax.ws.rs.core.Response.Status.OK;
+
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.rest.AbstractWebResource;
+import org.onosproject.vtnrsc.DefaultTenantNetwork;
+import org.onosproject.vtnrsc.PhysicalNetwork;
+import org.onosproject.vtnrsc.SegmentationId;
+import org.onosproject.vtnrsc.TenantId;
+import org.onosproject.vtnrsc.TenantNetwork;
+import org.onosproject.vtnrsc.TenantNetworkId;
+import org.onosproject.vtnrsc.TenantNetwork.State;
+import org.onosproject.vtnrsc.TenantNetwork.Type;
+import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
+import org.onosproject.vtnrsc.web.TenantNetworkCodec;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.collect.Maps;
+
+/**
+ * REST resource for interacting with the inventory of networks.
+ */
+@Path("networks")
+public class TenantNetworkWebResource extends AbstractWebResource {
+ public static final String NETWORK_NOT_FOUND = "Network is not found";
+ public static final String NETWORK_ID_EXIST = "Network id is existed";
+ public static final String NETWORK_ID_NOT_EXIST = "Network id is not existed";
+ public static final String CREATE_NETWORK = "create network";
+ public static final String UPDATE_NETWORK = "update network";
+ public static final String DELETE_NETWORK = "delete network";
+ public static final String JSON_NOT_NULL = "JsonNode can not be null";
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(TenantNetworkWebResource.class);
+ private final ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
+ .newConcurrentMap();
+
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON })
+ public Response getNetworks(@QueryParam("id") String queryId,
+ @QueryParam("name") String queryName,
+ @QueryParam("admin_state_up") String queryadminStateUp,
+ @QueryParam("status") String querystate,
+ @QueryParam("shared") String queryshared,
+ @QueryParam("tenant_id") String querytenantId,
+ @QueryParam("router:external") String routerExternal,
+ @QueryParam("provider:network_type") String type,
+ @QueryParam("provider:physical_network") String physicalNetwork,
+ @QueryParam("provider:segmentation_id") String segmentationId) {
+ Iterable<TenantNetwork> networks = get(TenantNetworkService.class)
+ .getNetworks();
+ Iterator<TenantNetwork> networkors = networks.iterator();
+ while (networkors.hasNext()) {
+ TenantNetwork network = networkors.next();
+ if ((queryId == null || queryId.equals(network.id().toString()))
+ && (queryName == null || queryName.equals(network.name()))
+ && (queryadminStateUp == null || queryadminStateUp
+ .equals(network.adminStateUp()))
+ && (querystate == null || querystate.equals(network.state()
+ .toString()))
+ && (queryshared == null || queryshared.equals(network
+ .shared()))
+ && (querytenantId == null || querytenantId.equals(network
+ .tenantId().toString()))
+ && (routerExternal == null || routerExternal.equals(network
+ .routerExternal()))
+ && (type == null || type.equals(network.type()))
+ && (physicalNetwork == null || physicalNetwork
+ .equals(network.physicalNetwork()))
+ && (segmentationId == null || segmentationId.equals(network
+ .segmentationId()))) {
+ networksMap.putIfAbsent(network.id(), network);
+ }
+ }
+ networks = Collections.unmodifiableCollection(networksMap.values());
+ ObjectNode result = new ObjectMapper().createObjectNode();
+ result.set("networks", new TenantNetworkCodec().encode(networks, this));
+
+ return ok(result.toString()).build();
+ }
+
+ private State isState(String state) {
+ if (state.equals("ACTIVE")) {
+ return TenantNetwork.State.ACTIVE;
+ } else if (state.equals("BUILD")) {
+ return TenantNetwork.State.BUILD;
+ } else if (state.equals("DOWN")) {
+ return TenantNetwork.State.DOWN;
+ } else if (state.equals("ERROR")) {
+ return TenantNetwork.State.ERROR;
+ } else {
+ return null;
+ }
+ }
+
+ private Type isType(String type) {
+ if (type.equals("LOCAL")) {
+ return TenantNetwork.Type.LOCAL;
+ } else {
+ return null;
+ }
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({ MediaType.APPLICATION_JSON })
+ public Response getNetwork(@PathParam("id") String id) {
+
+ if (!get(TenantNetworkService.class).exists(TenantNetworkId
+ .networkId(id))) {
+ return ok("The tenantNetwork does not exists").build();
+ }
+ TenantNetwork network = nullIsNotFound(get(TenantNetworkService.class)
+ .getNetwork(TenantNetworkId.networkId(id)), NETWORK_NOT_FOUND);
+ ObjectNode result = new ObjectMapper().createObjectNode();
+ result.set("network", new TenantNetworkCodec().encode(network, this));
+
+ return ok(result.toString()).build();
+
+ }
+
+ @POST
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response createNetworks(InputStream input) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode cfg = mapper.readTree(input);
+ JsonNode nodes = null;
+ Iterable<TenantNetwork> networks = null;
+ if (cfg.get("network") != null) {
+ nodes = cfg.get("network");
+ if (nodes.isArray()) {
+ networks = changeJson2objs(nodes);
+ } else {
+ networks = changeJson2obj(CREATE_NETWORK, null, nodes);
+ }
+ } else if (cfg.get("networks") != null) {
+ nodes = cfg.get("networks");
+ networks = changeJson2objs(nodes);
+ }
+ Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
+ .createNetworks(networks)),
+ NETWORK_NOT_FOUND);
+
+ if (!issuccess) {
+ return Response.status(INTERNAL_SERVER_ERROR)
+ .entity(NETWORK_ID_EXIST).build();
+ }
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (Exception e) {
+ log.error("Creates tenantNetwork exception {}.", e.toString());
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ @PUT
+ @Path("{id}")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Consumes(MediaType.APPLICATION_JSON)
+ public Response updateNetworks(@PathParam("id") String id, InputStream input) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode cfg = mapper.readTree(input);
+ JsonNode nodes = null;
+ Iterable<TenantNetwork> networks = null;
+ if (cfg.get("network") != null) {
+ nodes = cfg.get("network");
+ if (nodes.isArray()) {
+ networks = changeJson2objs(nodes);
+ } else {
+ networks = changeJson2obj(UPDATE_NETWORK,
+ TenantNetworkId.networkId(id),
+ nodes);
+ }
+ } else if (cfg.get("networks") != null) {
+ nodes = cfg.get("networks");
+ networks = changeJson2objs(nodes);
+ }
+ Boolean issuccess = nullIsNotFound((get(TenantNetworkService.class)
+ .updateNetworks(networks)),
+ NETWORK_NOT_FOUND);
+ if (!issuccess) {
+ return Response.status(INTERNAL_SERVER_ERROR)
+ .entity(NETWORK_ID_NOT_EXIST).build();
+ }
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (Exception e) {
+ log.error("Updates tenantNetwork failed because of exception {}.",
+ e.toString());
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ @DELETE
+ @Path("{id}")
+ public Response deleteNetworks(@PathParam("id") String id) {
+ log.debug("Deletes network by identifier {}.", id);
+ Set<TenantNetworkId> networkSet = new HashSet<>();
+ networkSet.add(TenantNetworkId.networkId(id));
+ Boolean issuccess = nullIsNotFound(get(TenantNetworkService.class)
+ .removeNetworks(networkSet), NETWORK_NOT_FOUND);
+ if (!issuccess) {
+ log.debug("Network identifier {} is not existed", id);
+ return Response.status(INTERNAL_SERVER_ERROR)
+ .entity(NETWORK_ID_NOT_EXIST).build();
+ }
+ return Response.status(OK).entity(issuccess.toString()).build();
+ }
+
+ /**
+ * Returns a collection of tenantNetworks.
+ *
+ * @param flag the flag
+ * @param networkId network identifier
+ * @param node the network json node
+ * @return a collection of tenantNetworks
+ */
+ public Iterable<TenantNetwork> changeJson2obj(String flag,
+ TenantNetworkId networkId,
+ JsonNode node) {
+ checkNotNull(node, JSON_NOT_NULL);
+ TenantNetwork network = null;
+ ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
+ .newConcurrentMap();
+ if (node != null) {
+ checkArgument(node.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
+ checkArgument(node.get("shared").isBoolean(), "shared should be boolean");
+ checkArgument(node.get("router:external").isBoolean(), "router:external should be boolean");
+ String name = node.get("name").asText();
+ boolean adminStateUp = node.get("admin_state_up").asBoolean();
+ String state = node.get("status").asText();
+ boolean shared = node.get("shared").asBoolean();
+ String tenantId = node.get("tenant_id").asText();
+ boolean routerExternal = node.get("router:external").asBoolean();
+ String type = node.get("provider:network_type").asText();
+ String physicalNetwork = node.get("provider:physical_network")
+ .asText();
+ String segmentationId = node.get("provider:segmentation_id")
+ .asText();
+ TenantNetworkId id = null;
+ if (flag == CREATE_NETWORK) {
+ id = TenantNetworkId.networkId(node.get("id").asText());
+ } else if (flag == UPDATE_NETWORK) {
+ id = networkId;
+ }
+ network = new DefaultTenantNetwork(
+ id,
+ name,
+ adminStateUp,
+ isState(state),
+ shared,
+ TenantId.tenantId(tenantId),
+ routerExternal,
+ isType(type),
+ PhysicalNetwork
+ .physicalNetwork(physicalNetwork),
+ SegmentationId
+ .segmentationId(segmentationId));
+ networksMap.putIfAbsent(id, network);
+ }
+ return Collections.unmodifiableCollection(networksMap.values());
+ }
+
+ /**
+ * Returns a collection of tenantNetworks.
+ *
+ * @param nodes the network jsonnodes
+ * @return a collection of tenantNetworks
+ */
+ public Iterable<TenantNetwork> changeJson2objs(JsonNode nodes) {
+ checkNotNull(nodes, JSON_NOT_NULL);
+ TenantNetwork network = null;
+ ConcurrentMap<TenantNetworkId, TenantNetwork> networksMap = Maps
+ .newConcurrentMap();
+ if (nodes != null) {
+ for (JsonNode node : nodes) {
+ String id = node.get("id").asText();
+ String name = node.get("name").asText();
+ boolean adminStateUp = node.get("admin_state_up").asBoolean();
+ String state = node.get("status").asText();
+ boolean shared = node.get("shared").asBoolean();
+ String tenantId = node.get("tenant_id").asText();
+ boolean routerExternal = node.get("router:external")
+ .asBoolean();
+ String type = node.get("provider:network_type").asText();
+ String physicalNetwork = node.get("provider:physical_network")
+ .asText();
+ String segmentationId = node.get("provider:segmentation_id")
+ .asText();
+ network = new DefaultTenantNetwork(
+ TenantNetworkId
+ .networkId(id),
+ name,
+ adminStateUp,
+ isState(state),
+ shared,
+ TenantId.tenantId(tenantId),
+ routerExternal,
+ isType(type),
+ PhysicalNetwork
+ .physicalNetwork(physicalNetwork),
+ SegmentationId
+ .segmentationId(segmentationId));
+ networksMap.putIfAbsent(TenantNetworkId.networkId(id), network);
+ }
+ }
+ return Collections.unmodifiableCollection(networksMap.values());
+ }
+
+ /**
+ * Returns the specified item if that items is null; otherwise throws not
+ * found exception.
+ *
+ * @param item item to check
+ * @param <T> item type
+ * @param message not found message
+ * @return item if not null
+ * @throws org.onlab.util.ItemNotFoundException if item is null
+ */
+ protected <T> T nullIsNotFound(T item, String message) {
+ if (item == null) {
+ throw new ItemNotFoundException(message);
+ }
+ return item;
+ }
+}
diff --git a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
index 0a427bba..d0b7ed2d 100644
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
+++ b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
@@ -1,410 +1,410 @@
-/*
- * 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.vtnweb.resources;
-
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
-import static javax.ws.rs.core.Response.Status.OK;
-
-import java.io.InputStream;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.PUT;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.ItemNotFoundException;
-import org.onosproject.net.DeviceId;
-import org.onosproject.rest.AbstractWebResource;
-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.VirtualPort.State;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.onosproject.vtnrsc.web.VirtualPortCodec;
-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.ObjectNode;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * REST resource for interacting with the inventory of infrastructure
- * virtualPort.
- */
-@Path("ports")
-public class VirtualPortWebResource extends AbstractWebResource {
- public static final String VPORT_NOT_FOUND = "VirtualPort is not found";
- public static final String VPORT_ID_EXIST = "VirtualPort id is exist";
- public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";
- public static final String JSON_NOT_NULL = "JsonNode can not be null";
- protected static final Logger log = LoggerFactory
- .getLogger(VirtualPortService.class);
-
- @GET
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getPorts() {
- Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
- .getPorts();
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));
- return ok(result.toString()).build();
- }
-
- @GET
- @Path("{id}")
- @Produces({ MediaType.APPLICATION_JSON })
- public Response getportsById(@PathParam("id") String id) {
-
- if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
- return ok("The virtualPort does not exists").build();
- }
- VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
- .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
- ObjectNode result = new ObjectMapper().createObjectNode();
- result.set("port", new VirtualPortCodec().encode(virtualPort, this));
- return ok(result.toString()).build();
- }
-
- @POST
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response createPorts(InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .createPorts(vPorts), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Creates VirtualPort failed because of exception {}",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @Path("{portUUID}")
- @DELETE
- public Response deletePorts(@PathParam("portUUID") String id) {
- Set<VirtualPortId> vPortIds = new HashSet<VirtualPortId>();
- try {
- if (id != null) {
- vPortIds.add(VirtualPortId.portId(id));
- }
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .removePorts(vPortIds), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Deletes VirtualPort failed because of exception {}",
- e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- @PUT
- @Path("{id}")
- @Consumes(MediaType.APPLICATION_JSON)
- @Produces(MediaType.APPLICATION_JSON)
- public Response updatePorts(@PathParam("id") String id, InputStream input) {
- try {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode cfg = mapper.readTree(input);
- Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
- Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
- .updatePorts(vPorts), VPORT_NOT_FOUND);
- if (!issuccess) {
- return Response.status(INTERNAL_SERVER_ERROR)
- .entity(VPORT_ID_NOT_EXIST).build();
- }
- return Response.status(OK).entity(issuccess.toString()).build();
- } catch (Exception e) {
- log.error("Updates failed because of exception {}", e.toString());
- return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
- .build();
- }
- }
-
- /**
- * Returns a Object of the currently known infrastructure virtualPort.
- *
- * @param vPortNode the virtualPort json node
- * @return a collection of virtualPorts
- */
- public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {
- checkNotNull(vPortNode, JSON_NOT_NULL);
- JsonNode vPortNodes = vPortNode.get("ports");
- if (vPortNodes == null) {
- vPortNodes = vPortNode.get("port");
- }
- if (vPortNodes.isArray()) {
- return changeJsonToPorts(vPortNodes);
- } else {
- return changeJsonToPort(vPortNodes);
- }
- }
-
- /**
- * Returns the iterable collection of virtualports from subnetNodes.
- *
- * @param vPortNodes the virtualPort json node
- * @return virtualPorts a collection of virtualPorts
- */
- public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Map<VirtualPortId, VirtualPort> portMap = new HashMap<VirtualPortId, VirtualPort>();
- Map<String, String> strMap = new HashMap<String, String>();
- for (JsonNode vPortnode : vPortNodes) {
- VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
- .asText());
- String name = vPortnode.get("name").asText();
- TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")
- .asText());
- TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
- .get("network_id").asText());
- checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
- Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
- String state = vPortnode.get("status").asText();
- MacAddress macAddress = MacAddress.valueOf(vPortnode
- .get("mac_address").asText());
- DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
- .asText());
- String deviceOwner = vPortnode.get("device_owner").asText();
- JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
- Set<FixedIp> fixedIps = new HashSet<FixedIp>();
- for (JsonNode fixedIpNode : fixedIpNodes) {
- FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
- fixedIps.add(fixedIp);
- }
-
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortnode.get("binding:host_id").asText());
- String bindingVnicType = vPortnode.get("binding:vnic_type")
- .asText();
- String bindingVifType = vPortnode.get("binding:vif_type").asText();
- String bindingVifDetails = vPortnode.get("binding:vif_details")
- .asText();
- JsonNode allowedAddressPairJsonNode = vPortnode
- .get("allowed_address_pairs");
- Collection<AllowedAddressPair> allowedAddressPairs =
- jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
- JsonNode securityGroupNode = vPortnode.get("security_groups");
- Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- VirtualPort vPort = new DefaultVirtualPort(id, networkId,
- adminStateUp, strMap,
- isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- Sets.newHashSet(allowedAddressPairs),
- Sets.newHashSet(securityGroups));
- portMap.put(id, vPort);
- }
- return Collections.unmodifiableCollection(portMap.values());
- }
-
- /**
- * Returns a collection of virtualPorts from subnetNodes.
- *
- * @param vPortNodes the virtualPort json node
- * @return virtualPorts a collection of virtualPorts
- */
- public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
- checkNotNull(vPortNodes, JSON_NOT_NULL);
- Map<VirtualPortId, VirtualPort> vportMap = new HashMap<VirtualPortId, VirtualPort>();
- Map<String, String> strMap = new HashMap<String, String>();
- VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
- String name = vPortNodes.get("name").asText();
- TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
- .asText());
- TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes
- .get("network_id").asText());
- Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
- String state = vPortNodes.get("status").asText();
- MacAddress macAddress = MacAddress.valueOf(vPortNodes
- .get("mac_address").asText());
- DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
- .asText());
- String deviceOwner = vPortNodes.get("device_owner").asText();
- JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
- Set<FixedIp> fixedIps = new HashSet<FixedIp>();
- for (JsonNode fixedIpNode : fixedIpNodes) {
- FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
- fixedIps.add(fixedIp);
- }
-
- BindingHostId bindingHostId = BindingHostId
- .bindingHostId(vPortNodes.get("binding:host_id").asText());
- String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
- String bindingVifType = vPortNodes.get("binding:vif_type").asText();
- String bindingVifDetails = vPortNodes.get("binding:vif_details")
- .asText();
- JsonNode allowedAddressPairJsonNode = vPortNodes
- .get("allowed_address_pairs");
- Collection<AllowedAddressPair> allowedAddressPairs =
- jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
- JsonNode securityGroupNode = vPortNodes.get("security_groups");
- Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
- strMap.put("name", name);
- strMap.put("deviceOwner", deviceOwner);
- strMap.put("bindingVnicType", bindingVnicType);
- strMap.put("bindingVifType", bindingVifType);
- strMap.put("bindingVifDetails", bindingVifDetails);
- VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
- strMap, isState(state),
- macAddress, tenantId,
- deviceId, fixedIps,
- bindingHostId,
- Sets.newHashSet(allowedAddressPairs),
- Sets.newHashSet(securityGroups));
- vportMap.put(id, vPort);
-
- return Collections.unmodifiableCollection(vportMap.values());
- }
-
- /**
- * Returns a Object of the currently known infrastructure virtualPort.
- *
- * @param allowedAddressPairs the allowedAddressPairs json node
- * @return a collection of allowedAddressPair
- */
- public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
- checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
- ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
- .newConcurrentMap();
- int i = 0;
- for (JsonNode node : allowedAddressPairs) {
- IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
- MacAddress mac = MacAddress.valueOf(node.get("mac_address")
- .asText());
- AllowedAddressPair allows = AllowedAddressPair
- .allowedAddressPair(ip, mac);
- allowMaps.put(i, allows);
- i++;
- }
- log.debug("The jsonNode of allowedAddressPairallow is {}"
- + allowedAddressPairs.toString());
- return Collections.unmodifiableCollection(allowMaps.values());
- }
-
- /**
- * Returns a collection of virtualPorts.
- *
- * @param securityGroups the virtualPort jsonnode
- * @return a collection of securityGroups
- */
- public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
- checkNotNull(securityGroups, JSON_NOT_NULL);
- ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
- .newConcurrentMap();
- int i = 0;
- for (JsonNode node : securityGroups) {
- SecurityGroup securityGroup = SecurityGroup
- .securityGroup(node.asText());
- securMaps.put(i, securityGroup);
- i++;
- }
- return Collections.unmodifiableCollection(securMaps.values());
- }
-
- /**
- * Returns a collection of fixedIps.
- *
- * @param fixedIpNode the fixedIp jsonnode
- * @return a collection of SecurityGroup
- */
- public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
- SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
- .asText());
- IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
- .asText());
- FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
- return fixedIps;
- }
-
- /**
- * Returns VirtualPort State.
- *
- * @param state the virtualport state
- * @return the virtualPort state
- */
- private State isState(String state) {
- if (state.equals("ACTIVE")) {
- return VirtualPort.State.ACTIVE;
- } else {
- return VirtualPort.State.DOWN;
- }
-
- }
-
- /**
- * Returns the specified item if that items is null; otherwise throws not
- * found exception.
- *
- * @param item item to check
- * @param <T> item type
- * @param message not found message
- * @return item if not null
- * @throws org.onlab.util.ItemNotFoundException if item is null
- */
- protected <T> T nullIsNotFound(T item, String message) {
- if (item == null) {
- throw new ItemNotFoundException(message);
- }
- return item;
- }
-}
+/*
+ * 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.vtnweb.resources;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static javax.ws.rs.core.Response.Status.INTERNAL_SERVER_ERROR;
+import static javax.ws.rs.core.Response.Status.OK;
+
+import java.io.InputStream;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.DELETE;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.onlab.packet.IpAddress;
+import org.onlab.packet.MacAddress;
+import org.onlab.util.ItemNotFoundException;
+import org.onosproject.net.DeviceId;
+import org.onosproject.rest.AbstractWebResource;
+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.VirtualPort.State;
+import org.onosproject.vtnrsc.VirtualPortId;
+import org.onosproject.vtnrsc.virtualport.VirtualPortService;
+import org.onosproject.vtnrsc.web.VirtualPortCodec;
+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.ObjectNode;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+
+/**
+ * REST resource for interacting with the inventory of infrastructure
+ * virtualPort.
+ */
+@Path("ports")
+public class VirtualPortWebResource extends AbstractWebResource {
+ public static final String VPORT_NOT_FOUND = "VirtualPort is not found";
+ public static final String VPORT_ID_EXIST = "VirtualPort id is exist";
+ public static final String VPORT_ID_NOT_EXIST = "VirtualPort id is not exist";
+ public static final String JSON_NOT_NULL = "JsonNode can not be null";
+ protected static final Logger log = LoggerFactory
+ .getLogger(VirtualPortService.class);
+
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON })
+ public Response getPorts() {
+ Iterable<VirtualPort> virtualPorts = get(VirtualPortService.class)
+ .getPorts();
+ ObjectNode result = new ObjectMapper().createObjectNode();
+ result.set("ports", new VirtualPortCodec().encode(virtualPorts, this));
+ return ok(result.toString()).build();
+ }
+
+ @GET
+ @Path("{id}")
+ @Produces({ MediaType.APPLICATION_JSON })
+ public Response getportsById(@PathParam("id") String id) {
+
+ if (!get(VirtualPortService.class).exists(VirtualPortId.portId(id))) {
+ return ok("The virtualPort does not exists").build();
+ }
+ VirtualPort virtualPort = nullIsNotFound(get(VirtualPortService.class)
+ .getPort(VirtualPortId.portId(id)), VPORT_NOT_FOUND);
+ ObjectNode result = new ObjectMapper().createObjectNode();
+ result.set("port", new VirtualPortCodec().encode(virtualPort, this));
+ return ok(result.toString()).build();
+ }
+
+ @POST
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response createPorts(InputStream input) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode cfg = mapper.readTree(input);
+ Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
+ Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
+ .createPorts(vPorts), VPORT_NOT_FOUND);
+ if (!issuccess) {
+ return Response.status(INTERNAL_SERVER_ERROR)
+ .entity(VPORT_ID_NOT_EXIST).build();
+ }
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (Exception e) {
+ log.error("Creates VirtualPort failed because of exception {}",
+ e.toString());
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ @Path("{portUUID}")
+ @DELETE
+ public Response deletePorts(@PathParam("portUUID") String id) {
+ Set<VirtualPortId> vPortIds = new HashSet<>();
+ try {
+ if (id != null) {
+ vPortIds.add(VirtualPortId.portId(id));
+ }
+ Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
+ .removePorts(vPortIds), VPORT_NOT_FOUND);
+ if (!issuccess) {
+ return Response.status(INTERNAL_SERVER_ERROR)
+ .entity(VPORT_ID_NOT_EXIST).build();
+ }
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (Exception e) {
+ log.error("Deletes VirtualPort failed because of exception {}",
+ e.toString());
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ @PUT
+ @Path("{id}")
+ @Consumes(MediaType.APPLICATION_JSON)
+ @Produces(MediaType.APPLICATION_JSON)
+ public Response updatePorts(@PathParam("id") String id, InputStream input) {
+ try {
+ ObjectMapper mapper = new ObjectMapper();
+ JsonNode cfg = mapper.readTree(input);
+ Iterable<VirtualPort> vPorts = createOrUpdateByInputStream(cfg);
+ Boolean issuccess = nullIsNotFound(get(VirtualPortService.class)
+ .updatePorts(vPorts), VPORT_NOT_FOUND);
+ if (!issuccess) {
+ return Response.status(INTERNAL_SERVER_ERROR)
+ .entity(VPORT_ID_NOT_EXIST).build();
+ }
+ return Response.status(OK).entity(issuccess.toString()).build();
+ } catch (Exception e) {
+ log.error("Updates failed because of exception {}", e.toString());
+ return Response.status(INTERNAL_SERVER_ERROR).entity(e.toString())
+ .build();
+ }
+ }
+
+ /**
+ * Returns a Object of the currently known infrastructure virtualPort.
+ *
+ * @param vPortNode the virtualPort json node
+ * @return a collection of virtualPorts
+ */
+ public Iterable<VirtualPort> createOrUpdateByInputStream(JsonNode vPortNode) {
+ checkNotNull(vPortNode, JSON_NOT_NULL);
+ JsonNode vPortNodes = vPortNode.get("ports");
+ if (vPortNodes == null) {
+ vPortNodes = vPortNode.get("port");
+ }
+ if (vPortNodes.isArray()) {
+ return changeJsonToPorts(vPortNodes);
+ } else {
+ return changeJsonToPort(vPortNodes);
+ }
+ }
+
+ /**
+ * Returns the iterable collection of virtualports from subnetNodes.
+ *
+ * @param vPortNodes the virtualPort json node
+ * @return virtualPorts a collection of virtualPorts
+ */
+ public Iterable<VirtualPort> changeJsonToPorts(JsonNode vPortNodes) {
+ checkNotNull(vPortNodes, JSON_NOT_NULL);
+ Map<VirtualPortId, VirtualPort> portMap = new HashMap<>();
+ Map<String, String> strMap = new HashMap<>();
+ for (JsonNode vPortnode : vPortNodes) {
+ VirtualPortId id = VirtualPortId.portId(vPortnode.get("id")
+ .asText());
+ String name = vPortnode.get("name").asText();
+ TenantId tenantId = TenantId.tenantId(vPortnode.get("tenant_id")
+ .asText());
+ TenantNetworkId networkId = TenantNetworkId.networkId(vPortnode
+ .get("network_id").asText());
+ checkArgument(vPortnode.get("admin_state_up").isBoolean(), "admin_state_up should be boolean");
+ Boolean adminStateUp = vPortnode.get("admin_state_up").asBoolean();
+ String state = vPortnode.get("status").asText();
+ MacAddress macAddress = MacAddress.valueOf(vPortnode
+ .get("mac_address").asText());
+ DeviceId deviceId = DeviceId.deviceId(vPortnode.get("device_id")
+ .asText());
+ String deviceOwner = vPortnode.get("device_owner").asText();
+ JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
+ Set<FixedIp> fixedIps = new HashSet<>();
+ for (JsonNode fixedIpNode : fixedIpNodes) {
+ FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
+ fixedIps.add(fixedIp);
+ }
+
+ BindingHostId bindingHostId = BindingHostId
+ .bindingHostId(vPortnode.get("binding:host_id").asText());
+ String bindingVnicType = vPortnode.get("binding:vnic_type")
+ .asText();
+ String bindingVifType = vPortnode.get("binding:vif_type").asText();
+ String bindingVifDetails = vPortnode.get("binding:vif_details")
+ .asText();
+ JsonNode allowedAddressPairJsonNode = vPortnode
+ .get("allowed_address_pairs");
+ Collection<AllowedAddressPair> allowedAddressPairs =
+ jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
+ JsonNode securityGroupNode = vPortnode.get("security_groups");
+ Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
+ strMap.put("name", name);
+ strMap.put("deviceOwner", deviceOwner);
+ strMap.put("bindingVnicType", bindingVnicType);
+ strMap.put("bindingVifType", bindingVifType);
+ strMap.put("bindingVifDetails", bindingVifDetails);
+ VirtualPort vPort = new DefaultVirtualPort(id, networkId,
+ adminStateUp, strMap,
+ isState(state),
+ macAddress, tenantId,
+ deviceId, fixedIps,
+ bindingHostId,
+ Sets.newHashSet(allowedAddressPairs),
+ Sets.newHashSet(securityGroups));
+ portMap.put(id, vPort);
+ }
+ return Collections.unmodifiableCollection(portMap.values());
+ }
+
+ /**
+ * Returns a collection of virtualPorts from subnetNodes.
+ *
+ * @param vPortNodes the virtualPort json node
+ * @return virtualPorts a collection of virtualPorts
+ */
+ public Iterable<VirtualPort> changeJsonToPort(JsonNode vPortNodes) {
+ checkNotNull(vPortNodes, JSON_NOT_NULL);
+ Map<VirtualPortId, VirtualPort> vportMap = new HashMap<>();
+ Map<String, String> strMap = new HashMap<>();
+ VirtualPortId id = VirtualPortId.portId(vPortNodes.get("id").asText());
+ String name = vPortNodes.get("name").asText();
+ TenantId tenantId = TenantId.tenantId(vPortNodes.get("tenant_id")
+ .asText());
+ TenantNetworkId networkId = TenantNetworkId.networkId(vPortNodes
+ .get("network_id").asText());
+ Boolean adminStateUp = vPortNodes.get("admin_state_up").asBoolean();
+ String state = vPortNodes.get("status").asText();
+ MacAddress macAddress = MacAddress.valueOf(vPortNodes
+ .get("mac_address").asText());
+ DeviceId deviceId = DeviceId.deviceId(vPortNodes.get("device_id")
+ .asText());
+ String deviceOwner = vPortNodes.get("device_owner").asText();
+ JsonNode fixedIpNodes = vPortNodes.get("fixed_ips");
+ Set<FixedIp> fixedIps = new HashSet<>();
+ for (JsonNode fixedIpNode : fixedIpNodes) {
+ FixedIp fixedIp = jsonNodeToFixedIps(fixedIpNode);
+ fixedIps.add(fixedIp);
+ }
+
+ BindingHostId bindingHostId = BindingHostId
+ .bindingHostId(vPortNodes.get("binding:host_id").asText());
+ String bindingVnicType = vPortNodes.get("binding:vnic_type").asText();
+ String bindingVifType = vPortNodes.get("binding:vif_type").asText();
+ String bindingVifDetails = vPortNodes.get("binding:vif_details")
+ .asText();
+ JsonNode allowedAddressPairJsonNode = vPortNodes
+ .get("allowed_address_pairs");
+ Collection<AllowedAddressPair> allowedAddressPairs =
+ jsonNodeToAllowedAddressPair(allowedAddressPairJsonNode);
+ JsonNode securityGroupNode = vPortNodes.get("security_groups");
+ Collection<SecurityGroup> securityGroups = jsonNodeToSecurityGroup(securityGroupNode);
+ strMap.put("name", name);
+ strMap.put("deviceOwner", deviceOwner);
+ strMap.put("bindingVnicType", bindingVnicType);
+ strMap.put("bindingVifType", bindingVifType);
+ strMap.put("bindingVifDetails", bindingVifDetails);
+ VirtualPort vPort = new DefaultVirtualPort(id, networkId, adminStateUp,
+ strMap, isState(state),
+ macAddress, tenantId,
+ deviceId, fixedIps,
+ bindingHostId,
+ Sets.newHashSet(allowedAddressPairs),
+ Sets.newHashSet(securityGroups));
+ vportMap.put(id, vPort);
+
+ return Collections.unmodifiableCollection(vportMap.values());
+ }
+
+ /**
+ * Returns a Object of the currently known infrastructure virtualPort.
+ *
+ * @param allowedAddressPairs the allowedAddressPairs json node
+ * @return a collection of allowedAddressPair
+ */
+ public Collection<AllowedAddressPair> jsonNodeToAllowedAddressPair(JsonNode allowedAddressPairs) {
+ checkNotNull(allowedAddressPairs, JSON_NOT_NULL);
+ ConcurrentMap<Integer, AllowedAddressPair> allowMaps = Maps
+ .newConcurrentMap();
+ int i = 0;
+ for (JsonNode node : allowedAddressPairs) {
+ IpAddress ip = IpAddress.valueOf(node.get("ip_address").asText());
+ MacAddress mac = MacAddress.valueOf(node.get("mac_address")
+ .asText());
+ AllowedAddressPair allows = AllowedAddressPair
+ .allowedAddressPair(ip, mac);
+ allowMaps.put(i, allows);
+ i++;
+ }
+ log.debug("The jsonNode of allowedAddressPairallow is {}"
+ + allowedAddressPairs.toString());
+ return Collections.unmodifiableCollection(allowMaps.values());
+ }
+
+ /**
+ * Returns a collection of virtualPorts.
+ *
+ * @param securityGroups the virtualPort jsonnode
+ * @return a collection of securityGroups
+ */
+ public Collection<SecurityGroup> jsonNodeToSecurityGroup(JsonNode securityGroups) {
+ checkNotNull(securityGroups, JSON_NOT_NULL);
+ ConcurrentMap<Integer, SecurityGroup> securMaps = Maps
+ .newConcurrentMap();
+ int i = 0;
+ for (JsonNode node : securityGroups) {
+ SecurityGroup securityGroup = SecurityGroup
+ .securityGroup(node.asText());
+ securMaps.put(i, securityGroup);
+ i++;
+ }
+ return Collections.unmodifiableCollection(securMaps.values());
+ }
+
+ /**
+ * Returns a collection of fixedIps.
+ *
+ * @param fixedIpNode the fixedIp jsonnode
+ * @return a collection of SecurityGroup
+ */
+ public FixedIp jsonNodeToFixedIps(JsonNode fixedIpNode) {
+ SubnetId subnetId = SubnetId.subnetId(fixedIpNode.get("subnet_id")
+ .asText());
+ IpAddress ipAddress = IpAddress.valueOf(fixedIpNode.get("ip_address")
+ .asText());
+ FixedIp fixedIps = FixedIp.fixedIp(subnetId, ipAddress);
+ return fixedIps;
+ }
+
+ /**
+ * Returns VirtualPort State.
+ *
+ * @param state the virtualport state
+ * @return the virtualPort state
+ */
+ private State isState(String state) {
+ if (state.equals("ACTIVE")) {
+ return VirtualPort.State.ACTIVE;
+ } else {
+ return VirtualPort.State.DOWN;
+ }
+
+ }
+
+ /**
+ * Returns the specified item if that items is null; otherwise throws not
+ * found exception.
+ *
+ * @param item item to check
+ * @param <T> item type
+ * @param message not found message
+ * @return item if not null
+ * @throws org.onlab.util.ItemNotFoundException if item is null
+ */
+ protected <T> T nullIsNotFound(T item, String message) {
+ if (item == null) {
+ throw new ItemNotFoundException(message);
+ }
+ return item;
+ }
+}
diff --git a/framework/src/onos/apps/xos-integration/pom.xml b/framework/src/onos/apps/xos-integration/pom.xml
index 0dc2300e..68eafd16 100644
--- a/framework/src/onos/apps/xos-integration/pom.xml
+++ b/framework/src/onos/apps/xos-integration/pom.xml
@@ -22,7 +22,7 @@
<parent>
<groupId>org.onosproject</groupId>
<artifactId>onos-apps</artifactId>
- <version>1.3.0-SNAPSHOT</version>
+ <version>1.4.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>