aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-10-19 10:14:31 -0700
committerAshlee Young <ashlee@onosfw.com>2015-10-19 10:14:31 -0700
commite9bb60be43af477f17b30ee1f2ba205565b7fa15 (patch)
tree981fd759a44b751fc45cde774f46fda37c11c257 /framework/src/onos/apps
parent74f3941756a1386cbc1fa99ee73fdc8376a0b6a0 (diff)
Updated onos src tree to commit id 1e60f97ae50c05b94fcb6a10520738bfb5efdfd1
Diffstat (limited to 'framework/src/onos/apps')
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java302
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java53
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java132
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java216
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java85
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java337
-rw-r--r--framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java251
-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/acl/src/main/java/org/onosproject/acl/AclWebResource.java1
-rw-r--r--framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java133
-rw-r--r--framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java58
-rw-r--r--framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java51
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java49
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java76
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java166
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java25
-rw-r--r--framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java21
-rw-r--r--framework/src/onos/apps/config/src/main/resources/addresses.json36
-rw-r--r--framework/src/onos/apps/cordvtn/pom.xml5
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtn.java194
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfig.java13
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java46
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnService.java32
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/DefaultOvsdbNode.java20
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java165
-rw-r--r--framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/OvsdbNode.java13
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/DhcpStore.java1
-rw-r--r--framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java107
-rw-r--r--framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java2
-rw-r--r--framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java6
-rw-r--r--framework/src/onos/apps/metrics/src/main/java/org/onosproject/metrics/topology/TopologyMetrics.java4
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java27
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java22
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java15
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java32
-rw-r--r--framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java25
-rw-r--r--framework/src/onos/apps/mlb/pom.xml (renamed from framework/src/onos/apps/config/pom.xml)22
-rw-r--r--framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java165
-rw-r--r--framework/src/onos/apps/pom.xml1
-rw-r--r--framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java94
-rw-r--r--framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java210
-rw-r--r--framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java31
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java19
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/DeviceConfiguration.java22
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java157
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java56
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java351
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java215
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java338
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java271
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java159
-rw-r--r--framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java445
-rw-r--r--framework/src/onos/apps/vtn/features.xml27
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java68
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java665
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java8
-rw-r--r--framework/src/onos/apps/vtnrsc/pom.xml71
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java38
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java94
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java72
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java81
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java79
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java183
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java160
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java229
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java93
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java39
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java78
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java77
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java77
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java129
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java76
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java77
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java130
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java76
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java156
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java70
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java97
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java60
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java45
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java99
-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/SubnetCreateCommand.java118
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java61
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java46
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java118
-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/VirtualPortCreateCommand.java134
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java94
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java45
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java135
-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/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java72
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java183
-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.java80
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java167
-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.java72
-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.java100
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java222
-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.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java40
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java39
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java53
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java47
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java57
-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/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml56
-rw-r--r--framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml45
-rw-r--r--framework/src/onos/apps/vtnweb/pom.xml88
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java365
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java371
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java410
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java20
-rw-r--r--framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml45
127 files changed, 547 insertions, 11607 deletions
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java
deleted file mode 100644
index edfa9355..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclRule.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl;
-
-import com.google.common.base.MoreObjects;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.Ip4Prefix;
-import org.onosproject.core.IdGenerator;
-
-import java.util.Objects;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-
-/**
- * ACL rule class.
- */
-public final class AclRule {
-
- private final RuleId id;
-
- private final Ip4Prefix srcIp;
- private final Ip4Prefix dstIp;
- private final byte ipProto;
- private final short dstTpPort;
- private final Action action;
-
- private static IdGenerator idGenerator;
-
- /**
- * Enum type for ACL rule's action.
- */
- public enum Action {
- DENY, ALLOW
- }
-
- /**
- * Constructor for serializer.
- */
- private AclRule() {
- this.id = null;
- this.srcIp = null;
- this.dstIp = null;
- this.ipProto = 0;
- this.dstTpPort = 0;
- this.action = null;
- }
-
- /**
- * Create a new ACL rule.
- *
- * @param srcIp source IP address
- * @param dstIp destination IP address
- * @param ipProto IP protocol
- * @param dstTpPort destination transport layer port
- * @param action ACL rule's action
- */
- private AclRule(Ip4Prefix srcIp,
- Ip4Prefix dstIp,
- byte ipProto,
- short dstTpPort,
- Action action) {
- checkState(idGenerator != null, "Id generator is not bound.");
- this.id = RuleId.valueOf(idGenerator.getNewId());
- this.srcIp = srcIp;
- this.dstIp = dstIp;
- this.ipProto = ipProto;
- this.dstTpPort = dstTpPort;
- this.action = action;
- }
-
- /**
- * Check if the first CIDR address is in (or the same as) the second CIDR address.
- */
- private boolean checkCIDRinCIDR(Ip4Prefix cidrAddr1, Ip4Prefix cidrAddr2) {
- if (cidrAddr2 == null) {
- return true;
- } else if (cidrAddr1 == null) {
- return false;
- }
- if (cidrAddr1.prefixLength() < cidrAddr2.prefixLength()) {
- return false;
- }
- int offset = 32 - cidrAddr2.prefixLength();
-
- int cidr1Prefix = cidrAddr1.address().toInt();
- int cidr2Prefix = cidrAddr2.address().toInt();
- cidr1Prefix = cidr1Prefix >> offset;
- cidr2Prefix = cidr2Prefix >> offset;
- cidr1Prefix = cidr1Prefix << offset;
- cidr2Prefix = cidr2Prefix << offset;
-
- return (cidr1Prefix == cidr2Prefix);
- }
-
- /**
- * Check if this ACL rule match the given ACL rule.
- * @param r ACL rule to check against
- * @return true if this ACL rule matches the given ACL ruleule.
- */
- public boolean checkMatch(AclRule r) {
- return (this.dstTpPort == r.dstTpPort || r.dstTpPort == 0)
- && (this.ipProto == r.ipProto || r.ipProto == 0)
- && (checkCIDRinCIDR(this.srcIp(), r.srcIp()))
- && (checkCIDRinCIDR(this.dstIp(), r.dstIp()));
- }
-
- /**
- * Returns a new ACL rule builder.
- *
- * @return ACL rule builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder of an ACL rule.
- */
- public static final class Builder {
-
- private Ip4Prefix srcIp = null;
- private Ip4Prefix dstIp = null;
- private byte ipProto = 0;
- private short dstTpPort = 0;
- private Action action = Action.DENY;
-
- private Builder() {
- // Hide constructor
- }
-
- /**
- * Sets the source IP address for the ACL rule that will be built.
- *
- * @param srcIp source IP address to use for built ACL rule
- * @return this builder
- */
- public Builder srcIp(String srcIp) {
- this.srcIp = Ip4Prefix.valueOf(srcIp);
- return this;
- }
-
- /**
- * Sets the destination IP address for the ACL rule that will be built.
- *
- * @param dstIp destination IP address to use for built ACL rule
- * @return this builder
- */
- public Builder dstIp(String dstIp) {
- this.dstIp = Ip4Prefix.valueOf(dstIp);
- return this;
- }
-
- /**
- * Sets the IP protocol for the ACL rule that will be built.
- *
- * @param ipProto IP protocol to use for built ACL rule
- * @return this builder
- */
- public Builder ipProto(byte ipProto) {
- this.ipProto = ipProto;
- return this;
- }
-
- /**
- * Sets the destination transport layer port for the ACL rule that will be built.
- *
- * @param dstTpPort destination transport layer port to use for built ACL rule
- * @return this builder
- */
- public Builder dstTpPort(short dstTpPort) {
- if ((ipProto == IPv4.PROTOCOL_TCP || ipProto == IPv4.PROTOCOL_UDP)) {
- this.dstTpPort = dstTpPort;
- }
- return this;
- }
-
- /**
- * Sets the action for the ACL rule that will be built.
- *
- * @param action action to use for built ACL rule
- * @return this builder
- */
- public Builder action(Action action) {
- this.action = action;
- return this;
- }
-
- /**
- * Builds an ACL rule from the accumulated parameters.
- * @return ACL rule instance
- */
- public AclRule build() {
- checkState(srcIp != null && dstIp != null, "Either srcIp or dstIp must be assigned.");
- checkState(ipProto == 0 || ipProto == IPv4.PROTOCOL_ICMP
- || ipProto == IPv4.PROTOCOL_TCP || ipProto == IPv4.PROTOCOL_UDP,
- "ipProto must be assigned to TCP, UDP, or ICMP.");
- return new AclRule(
- srcIp,
- dstIp,
- ipProto,
- dstTpPort,
- action
- );
- }
-
- }
-
- /**
- * Binds an id generator for unique ACL rule id generation.
- *
- * Note: A generator cannot be bound if there is already a generator bound.
- *
- * @param newIdGenerator id generator
- */
- public static void bindIdGenerator(IdGenerator newIdGenerator) {
- checkState(idGenerator == null, "Id generator is already bound.");
- idGenerator = checkNotNull(newIdGenerator);
- }
-
- public RuleId id() {
- return id;
- }
-
- public Ip4Prefix srcIp() {
- return srcIp;
- }
-
- public Ip4Prefix dstIp() {
- return this.dstIp;
- }
-
- public byte ipProto() {
- return ipProto;
- }
-
- public short dstTpPort() {
- return dstTpPort;
- }
-
- public Action action() {
- return action;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(action,
- id.fingerprint(),
- ipProto,
- srcIp,
- dstIp,
- dstTpPort);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof AclRule) {
- AclRule that = (AclRule) obj;
- return Objects.equals(id, that.id) &&
- Objects.equals(srcIp, that.srcIp) &&
- Objects.equals(dstIp, that.dstIp) &&
- Objects.equals(ipProto, that.ipProto) &&
- Objects.equals(dstTpPort, that.dstTpPort) &&
- Objects.equals(action, that.action);
- }
- return false;
- }
-
- @Override
- public String toString() {
- return MoreObjects.toStringHelper(this)
- .omitNullValues()
- .add("id", id)
- .add("srcIp", srcIp)
- .add("dstIp", dstIp)
- .add("ipProto", ipProto)
- .add("dstTpPort", dstTpPort)
- .add("action", action)
- .toString();
- }
-
-}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java
deleted file mode 100644
index afa561e4..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclService.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl;
-
-import java.util.List;
-
-/**
- * Service interface exported by ACL application.
- */
-public interface AclService {
-
- /**
- * Gets a list containing all ACL rules.
- * @return a list containing all ACL rules
- */
- List<AclRule> getAclRules();
-
- /**
- * Adds a new ACL rule.
- * @param rule ACL rule
- * @return true if successfully added, otherwise false
- */
- boolean addAclRule(AclRule rule);
-
- /**
- * Removes an exsiting ACL rule by rule id.
- * @param ruleId ACL rule identifier
- */
- void removeAclRule(RuleId ruleId);
-
- /**
- * Clears ACL and resets all.
- */
- void clearAcl();
-
-} \ No newline at end of file
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java
deleted file mode 100644
index 88e49a73..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclStore.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.store.Store;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * Service interface exported by ACL distributed store.
- */
-public interface AclStore extends Store {
-
- /**
- * Gets a list containing all ACL rules.
- * @return a list containing all ACL rules
- */
- List<AclRule> getAclRules();
-
- /**
- * Adds a new ACL rule.
- * @param rule new ACL rule
- */
- void addAclRule(AclRule rule);
-
- /**
- * Gets an existing ACL rule.
- * @param ruleId ACL rule id
- * @return ACL rule with the given id
- */
- AclRule getAclRule(RuleId ruleId);
-
- /**
- * Removes an existing ACL rule by rule id.
- * @param ruleId ACL rule id
- */
- void removeAclRule(RuleId ruleId);
-
- /**
- * Clears ACL and reset all.
- */
- void clearAcl();
-
- /**
- * Gets the current priority for new ACL flow rule by device id.
- * @param deviceId device id
- * @return new ACL flow rule's priority in the given device
- */
- int getPriorityByDevice(DeviceId deviceId);
-
- /**
- * Gets a set containing all ACL flow rules belonging to a given ACL rule.
- * @param ruleId ACL rule id
- * @return a set containing all ACL flow rules belonging to the given ACL rule
- */
- Set<FlowRule> getFlowByRule(RuleId ruleId);
-
- /**
- * Adds a new mapping from ACL rule to ACL flow rule.
- * @param ruleId ACL rule id
- * @param flowRule ACL flow rule
- */
- void addRuleToFlowMapping(RuleId ruleId, FlowRule flowRule);
-
- /**
- * Removes an existing mapping from ACL rule to ACL flow rule.
- * @param ruleId ACL rule id
- */
- void removeRuleToFlowMapping(RuleId ruleId);
-
- /**
- * Gets a list containing all allowing ACL rules matching a given denying ACL rule.
- * @param denyingRuleId denying ACL rule id
- * @return a list containing all allowing ACL rules matching the given denying ACL rule
- */
- List<RuleId> getAllowingRuleByDenyingRule(RuleId denyingRuleId);
-
- /**
- * Adds a new mapping from denying ACL rule to allowing ACL rule.
- * @param denyingRuleId denying ACL rule id
- * @param allowingRuleId allowing ACL rule id
- */
- void addDenyToAllowMapping(RuleId denyingRuleId, RuleId allowingRuleId);
-
- /**
- * Removes an exsiting mapping from denying ACL rule to allowing ACL rule.
- * @param denyingRuleId denying ACL rule id
- */
- void removeDenyToAllowMapping(RuleId denyingRuleId);
-
- /**
- * Checks if an existing ACL rule already works in a given device.
- * @param ruleId ACL rule id
- * @param deviceId devide id
- * @return true if the given ACL rule works in the given device
- */
- boolean checkIfRuleWorksInDevice(RuleId ruleId, DeviceId deviceId);
-
- /**
- * Adds a new mapping from ACL rule to device.
- * @param ruleId ACL rule id
- * @param deviceId device id
- */
- void addRuleToDeviceMapping(RuleId ruleId, DeviceId deviceId);
-
- /**
- * Removes an existing mapping from ACL rule to device.
- * @param ruleId ACL rule id
- */
- void removeRuleToDeviceMapping(RuleId ruleId);
-
-}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java
deleted file mode 100644
index 3f4dc769..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/AclWebResource.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl;
-
-import com.fasterxml.jackson.core.JsonParser;
-import com.fasterxml.jackson.core.JsonToken;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import org.onlab.packet.IPv4;
-import org.onosproject.rest.AbstractWebResource;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-// FIXME: This does now follow REST-full principles and should be refactored.
-/**
- * Manage ACL rules.
- */
-@Path("")
-public class AclWebResource extends AbstractWebResource {
-
- private final Logger log = LoggerFactory.getLogger(getClass());
-
- /**
- * Processes user's GET HTTP request for querying ACL rules.
- * @return response to the request
- */
- @GET
- public Response queryAclRule() {
- List<AclRule> rules = get(AclService.class).getAclRules();
- ObjectMapper mapper = new ObjectMapper();
- ObjectNode root = mapper.createObjectNode();
- ArrayNode arrayNode = mapper.createArrayNode();
- for (AclRule rule : rules) {
- ObjectNode node = mapper.createObjectNode();
- node.put("id", rule.id().toString());
- if (rule.srcIp() != null) {
- node.put("srcIp", rule.srcIp().toString());
- }
- if (rule.dstIp() != null) {
- node.put("dstIp", rule.dstIp().toString());
- }
- if (rule.ipProto() != 0) {
- switch (rule.ipProto()) {
- case IPv4.PROTOCOL_ICMP:
- node.put("ipProto", "ICMP");
- break;
- case IPv4.PROTOCOL_TCP:
- node.put("ipProto", "TCP");
- break;
- case IPv4.PROTOCOL_UDP:
- node.put("ipProto", "UDP");
- break;
- default:
- break;
- }
- }
- if (rule.dstTpPort() != 0) {
- node.put("dstTpPort", rule.dstTpPort());
- }
- node.put("action", rule.action().toString());
- arrayNode.add(node);
- }
- root.set("ACL rules", arrayNode);
- return Response.ok(root.toString(), MediaType.APPLICATION_JSON_TYPE).build();
- }
-
- /**
- * Processes user's POST HTTP request for add ACL rules.
- * @param stream input stream
- * @return response to the request
- */
- @POST
- @Path("add")
- public Response addAclRule(InputStream stream) {
- AclRule newRule;
- try {
- newRule = jsonToRule(stream);
- } catch (Exception e) {
- return Response.ok("{\"status\" : \"Failed! " + e.getMessage() + "\"}").build();
- }
-
- String status;
- if (get(AclService.class).addAclRule(newRule)) {
- status = "Success! New ACL rule is added.";
- } else {
- status = "Failed! New ACL rule matches an existing rule.";
- }
- return Response.ok("{\"status\" : \"" + status + "\"}").build();
- }
-
- /**
- * Processes user's GET HTTP request for removing ACL rule.
- * @param id ACL rule id (in hex string format)
- * @return response to the request
- */
- @GET
- @Path("remove/{id}")
- public Response removeAclRule(@PathParam("id") String id) {
- String status;
- RuleId ruleId = new RuleId(Long.parseLong(id.substring(2), 16));
- if (get(AclStore.class).getAclRule(ruleId) == null) {
- status = "Failed! There is no ACL rule with this id.";
- } else {
- get(AclService.class).removeAclRule(ruleId);
- status = "Success! ACL rule(id:" + id + ") is removed.";
- }
- return Response.ok("{\"status\" : \"" + status + "\"}").build();
- }
-
- /**
- * Processes user's GET HTTP request for clearing ACL.
- * @return response to the request
- */
- @GET
- @Path("clear")
- public Response clearACL() {
- get(AclService.class).clearAcl();
- return Response.ok("{\"status\" : \"ACL is cleared.\"}").build();
- }
-
- /**
- * Exception class for parsing a invalid ACL rule.
- */
- private class AclRuleParseException extends Exception {
- public AclRuleParseException(String message) {
- super(message);
- }
- }
-
- /**
- * Turns a JSON string into an ACL rule instance.
- */
- private AclRule jsonToRule(InputStream stream) throws AclRuleParseException, IOException {
- ObjectMapper mapper = new ObjectMapper();
- JsonNode jsonNode = mapper.readTree(stream);
- JsonParser jp = jsonNode.traverse();
- AclRule.Builder rule = AclRule.builder();
- jp.nextToken();
- if (jp.getCurrentToken() != JsonToken.START_OBJECT) {
- throw new AclRuleParseException("Expected START_OBJECT");
- }
-
- while (jp.nextToken() != JsonToken.END_OBJECT) {
- if (jp.getCurrentToken() != JsonToken.FIELD_NAME) {
- throw new AclRuleParseException("Expected FIELD_NAME");
- }
-
- String key = jp.getCurrentName();
- jp.nextToken();
- String value = jp.getText();
- if ("".equals(value)) {
- continue;
- }
-
- if ("srcIp".equals(key)) {
- rule.srcIp(value);
- } else if ("dstIp".equals(key)) {
- rule.dstIp(value);
- } else if ("ipProto".equals(key)) {
- if ("TCP".equalsIgnoreCase(value)) {
- rule.ipProto(IPv4.PROTOCOL_TCP);
- } else if ("UDP".equalsIgnoreCase(value)) {
- rule.ipProto(IPv4.PROTOCOL_UDP);
- } else if ("ICMP".equalsIgnoreCase(value)) {
- rule.ipProto(IPv4.PROTOCOL_ICMP);
- } else {
- throw new AclRuleParseException("ipProto must be assigned to TCP, UDP, or ICMP.");
- }
- } else if ("dstTpPort".equals(key)) {
- try {
- rule.dstTpPort(Short.parseShort(value));
- } catch (NumberFormatException e) {
- throw new AclRuleParseException("dstTpPort must be assigned to a numerical value.");
- }
- } else if ("action".equals(key)) {
- if (!"allow".equalsIgnoreCase(value) && !"deny".equalsIgnoreCase(value)) {
- throw new AclRuleParseException("action must be assigned to ALLOW or DENY.");
- }
- if ("allow".equalsIgnoreCase(value)) {
- rule.action(AclRule.Action.ALLOW);
- }
- }
- }
- return rule.build();
- }
-
-} \ No newline at end of file
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java
deleted file mode 100644
index 754a6435..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/RuleId.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl;
-
-/**
- * ACL rule identifier suitable as an external key.
- * <p>This class is immutable.</p>
- */
-public final class RuleId {
- private final long value;
-
- /**
- * Creates an ACL rule identifier from the specified long value.
- *
- * @param value long value
- * @return ACL rule identifier
- */
- public static RuleId valueOf(long value) {
- return new RuleId(value);
- }
-
- /**
- * Constructor for serializer.
- */
- RuleId() {
- this.value = 0;
- }
-
- /**
- * Constructs the ID corresponding to a given long value.
- *
- * @param value the underlying value of this ID
- */
- RuleId(long value) {
- this.value = value;
- }
-
- /**
- * Returns the backing value.
- *
- * @return the value
- */
- public long fingerprint() {
- return value;
- }
-
- @Override
- public int hashCode() {
- return Long.hashCode(value);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj == this) {
- return true;
- }
- if (!(obj instanceof RuleId)) {
- return false;
- }
- RuleId that = (RuleId) obj;
- return this.value == that.value;
- }
-
- @Override
- public String toString() {
- return "0x" + Long.toHexString(value);
- }
-}
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java b/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java
deleted file mode 100644
index 0ffd4bcd..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/AclManager.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl.impl;
-
-import org.onlab.packet.Ethernet;
-import org.onlab.packet.IPv4;
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.TpPort;
-import org.onos.acl.AclRule;
-import org.onos.acl.AclService;
-import org.onos.acl.AclStore;
-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.onos.acl.RuleId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.core.IdGenerator;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.MastershipRole;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.flow.DefaultFlowEntry;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowEntry;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostService;
-import org.slf4j.Logger;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the ACL service.
- */
-@Component(immediate = true)
-@Service
-public class AclManager implements AclService {
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected AclStore aclStore;
-
- private final Logger log = getLogger(getClass());
- private ApplicationId appId;
- private final HostListener hostListener = new InternalHostListener();
- private IdGenerator idGenerator;
-
- /**
- * Checks if the given IP address is in the given CIDR address.
- */
- private boolean checkIpInCIDR(Ip4Address ip, Ip4Prefix cidr) {
- int offset = 32 - cidr.prefixLength();
- int cidrPrefix = cidr.address().toInt();
- int ipIntValue = ip.toInt();
- cidrPrefix = cidrPrefix >> offset;
- ipIntValue = ipIntValue >> offset;
- cidrPrefix = cidrPrefix << offset;
- ipIntValue = ipIntValue << offset;
-
- return (cidrPrefix == ipIntValue);
- }
-
- private class InternalHostListener implements HostListener {
-
- /**
- * Generate new ACL flow rules for new host following the given ACL rule.
- */
- private void processHostAddedEvent(HostEvent event, AclRule rule) {
- DeviceId deviceId = event.subject().location().deviceId();
- for (IpAddress address : event.subject().ipAddresses()) {
- if ((rule.srcIp() != null) ?
- (checkIpInCIDR(address.getIp4Address(), rule.srcIp())) :
- (checkIpInCIDR(address.getIp4Address(), rule.dstIp()))) {
- if (!aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) {
- List<RuleId> allowingRuleList = aclStore
- .getAllowingRuleByDenyingRule(rule.id());
- if (allowingRuleList != null) {
- for (RuleId allowingRuleId : allowingRuleList) {
- generateACLFlow(aclStore.getAclRule(allowingRuleId), deviceId);
- }
- }
- generateACLFlow(rule, deviceId);
- }
- }
- }
- }
-
- @Override
- public void event(HostEvent event) {
- // if a new host appears and an existing rule denies
- // its traffic, a new ACL flow rule is generated.
- if (event.type() == HostEvent.Type.HOST_ADDED) {
- DeviceId deviceId = event.subject().location().deviceId();
- if (mastershipService.getLocalRole(deviceId) == MastershipRole.MASTER) {
- for (AclRule rule : aclStore.getAclRules()) {
- if (rule.action() != AclRule.Action.ALLOW) {
- processHostAddedEvent(event, rule);
- }
- }
- }
- }
- }
- }
-
- @Activate
- public void activate() {
- appId = coreService.registerApplication("org.onos.acl");
- hostService.addListener(hostListener);
- idGenerator = coreService.getIdGenerator("acl-ids");
- AclRule.bindIdGenerator(idGenerator);
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- hostService.removeListener(hostListener);
- flowRuleService.removeFlowRulesById(appId);
- aclStore.clearAcl();
- log.info("Stopped");
- }
-
- @Override
- public List<AclRule> getAclRules() {
- return aclStore.getAclRules();
- }
-
- /**
- * Checks if the new ACL rule matches an existing rule.
- * If existing allowing rules matches the new denying rule, store the mappings.
- * @return true if the new ACL rule matches an existing rule, false otherwise
- */
- private boolean matchCheck(AclRule newRule) {
- for (AclRule existingRule : aclStore.getAclRules()) {
- if (newRule.checkMatch(existingRule)) {
- return true;
- }
-
- if (existingRule.action() == AclRule.Action.ALLOW
- && newRule.action() == AclRule.Action.DENY) {
- if (existingRule.checkMatch(newRule)) {
- aclStore.addDenyToAllowMapping(newRule.id(), existingRule.id());
- }
- }
- }
- return false;
- }
-
- @Override
- public boolean addAclRule(AclRule rule) {
- if (matchCheck(rule)) {
- return false;
- }
- aclStore.addAclRule(rule);
- log.info("ACL rule(id:{}) is added.", rule.id());
- if (rule.action() != AclRule.Action.ALLOW) {
- enforceRuleAdding(rule);
- }
- return true;
- }
-
- /**
- * Gets a set containing all devices connecting with the hosts
- * whose IP address is in the given CIDR IP address.
- */
- private Set<DeviceId> getDeviceIdSet(Ip4Prefix cidrAddr) {
- Set<DeviceId> deviceIdSet = new HashSet<>();
- final Iterable<Host> hosts = hostService.getHosts();
-
- if (cidrAddr.prefixLength() != 32) {
- for (Host h : hosts) {
- for (IpAddress a : h.ipAddresses()) {
- if (checkIpInCIDR(a.getIp4Address(), cidrAddr)) {
- deviceIdSet.add(h.location().deviceId());
- }
- }
- }
- } else {
- for (Host h : hosts) {
- for (IpAddress a : h.ipAddresses()) {
- if (checkIpInCIDR(a.getIp4Address(), cidrAddr)) {
- deviceIdSet.add(h.location().deviceId());
- return deviceIdSet;
- }
- }
- }
- }
- return deviceIdSet;
- }
-
- /**
- * Enforces denying ACL rule by ACL flow rules.
- */
- private void enforceRuleAdding(AclRule rule) {
- Set<DeviceId> dpidSet;
- if (rule.srcIp() != null) {
- dpidSet = getDeviceIdSet(rule.srcIp());
- } else {
- dpidSet = getDeviceIdSet(rule.dstIp());
- }
-
- for (DeviceId deviceId : dpidSet) {
- List<RuleId> allowingRuleList = aclStore.getAllowingRuleByDenyingRule(rule.id());
- if (allowingRuleList != null) {
- for (RuleId allowingRuleId : allowingRuleList) {
- generateACLFlow(aclStore.getAclRule(allowingRuleId), deviceId);
- }
- }
- generateACLFlow(rule, deviceId);
- }
- }
-
- /**
- * Generates ACL flow rule according to ACL rule
- * and install it into related device.
- */
- private void generateACLFlow(AclRule rule, DeviceId deviceId) {
- if (rule == null || aclStore.checkIfRuleWorksInDevice(rule.id(), deviceId)) {
- return;
- }
-
- TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- FlowEntry.Builder flowEntry = DefaultFlowEntry.builder();
-
- selectorBuilder.matchEthType(Ethernet.TYPE_IPV4);
- if (rule.srcIp() != null) {
- selectorBuilder.matchIPSrc(rule.srcIp());
- if (rule.dstIp() != null) {
- selectorBuilder.matchIPDst(rule.dstIp());
- }
- } else {
- selectorBuilder.matchIPDst(rule.dstIp());
- }
- if (rule.ipProto() != 0) {
- selectorBuilder.matchIPProtocol(Integer.valueOf(rule.ipProto()).byteValue());
- }
- if (rule.dstTpPort() != 0) {
- switch (rule.ipProto()) {
- case IPv4.PROTOCOL_TCP:
- selectorBuilder.matchTcpDst(TpPort.tpPort(rule.dstTpPort()));
- break;
- case IPv4.PROTOCOL_UDP:
- selectorBuilder.matchUdpDst(TpPort.tpPort(rule.dstTpPort()));
- break;
- default:
- break;
- }
- }
- if (rule.action() == AclRule.Action.ALLOW) {
- treatment.add(Instructions.createOutput(PortNumber.CONTROLLER));
- }
- flowEntry.forDevice(deviceId);
- flowEntry.withPriority(aclStore.getPriorityByDevice(deviceId));
- flowEntry.withSelector(selectorBuilder.build());
- flowEntry.withTreatment(treatment.build());
- flowEntry.fromApp(appId);
- flowEntry.makePermanent();
- // install flow rule
- flowRuleService.applyFlowRules(flowEntry.build());
- log.debug("ACL flow rule {} is installed in {}.", flowEntry.build(), deviceId);
- aclStore.addRuleToFlowMapping(rule.id(), flowEntry.build());
- aclStore.addRuleToDeviceMapping(rule.id(), deviceId);
- }
-
- @Override
- public void removeAclRule(RuleId ruleId) {
- aclStore.removeAclRule(ruleId);
- log.info("ACL rule(id:{}) is removed.", ruleId);
- enforceRuleRemoving(ruleId);
- }
-
- /**
- * Enforces removing an existing ACL rule.
- */
- private void enforceRuleRemoving(RuleId ruleId) {
- Set<FlowRule> flowSet = aclStore.getFlowByRule(ruleId);
- if (flowSet != null) {
- for (FlowRule flowRule : flowSet) {
- flowRuleService.removeFlowRules(flowRule);
- log.debug("ACL flow rule {} is removed from {}.", flowRule.toString(), flowRule.deviceId().toString());
- }
- }
- aclStore.removeRuleToFlowMapping(ruleId);
- aclStore.removeRuleToDeviceMapping(ruleId);
- aclStore.removeDenyToAllowMapping(ruleId);
- }
-
- @Override
- public void clearAcl() {
- aclStore.clearAcl();
- flowRuleService.removeFlowRulesById(appId);
- log.info("ACL is cleared.");
- }
-
-}
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
deleted file mode 100644
index 5c8a93cb..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/DistributedAclStore.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li, Heng Qi and Haisheng Yu
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl.impl;
-
-import com.google.common.collect.Collections2;
-import org.onos.acl.AclRule;
-import org.onos.acl.AclStore;
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.util.KryoNamespace;
-import org.onos.acl.RuleId;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.flow.FlowRule;
-import org.onosproject.store.AbstractStore;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.ConsistentMap;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.Versioned;
-import org.slf4j.Logger;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Implementation of the ACL store service.
- */
-@Component(immediate = true)
-@Service
-public class DistributedAclStore extends AbstractStore implements AclStore {
-
- private final Logger log = getLogger(getClass());
- private final int defaultFlowMaxPriority = 30000;
-
- private ConsistentMap<RuleId, AclRule> ruleSet;
- private ConsistentMap<DeviceId, Integer> deviceToPriority;
- private ConsistentMap<RuleId, Set<DeviceId>> ruleToDevice;
- private ConsistentMap<RuleId, Set<FlowRule>> ruleToFlow;
- private ConsistentMap<RuleId, List<RuleId>> denyRuleToAllowRule;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
-
- @Activate
- public void activate() {
- ApplicationId appId = coreService.getAppId("org.onosproject.acl");
-
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API)
- .register(AclRule.class)
- .register(AclRule.Action.class)
- .register(RuleId.class);
-
- ruleSet = storageService.<RuleId, AclRule>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("acl-rule-set")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- deviceToPriority = storageService.<DeviceId, Integer>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("device-to-priority")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- ruleToFlow = storageService.<RuleId, Set<FlowRule>>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("rule-to-flow")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- denyRuleToAllowRule = storageService.<RuleId, List<RuleId>>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("deny-to-allow")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- ruleToDevice = storageService.<RuleId, Set<DeviceId>>consistentMapBuilder()
- .withSerializer(Serializer.using(serializer.build()))
- .withName("rule-to-device")
- .withApplicationId(appId)
- .withPurgeOnUninstall()
- .build();
-
- log.info("Started");
- }
-
- @Deactivate
- public void deactive() {
- log.info("Stopped");
- }
-
- @Override
- public List<AclRule> getAclRules() {
- List<AclRule> aclRules = new ArrayList<>();
- aclRules.addAll(Collections2.transform(ruleSet.values(), Versioned::value));
- return aclRules;
- }
-
- @Override
- public void addAclRule(AclRule rule) {
- ruleSet.putIfAbsent(rule.id(), rule);
- }
-
- @Override
- public AclRule getAclRule(RuleId ruleId) {
- Versioned<AclRule> rule = ruleSet.get(ruleId);
- if (rule != null) {
- return rule.value();
- } else {
- return null;
- }
- }
-
- @Override
- public void removeAclRule(RuleId ruleId) {
- ruleSet.remove(ruleId);
- }
-
- @Override
- public void clearAcl() {
- ruleSet.clear();
- deviceToPriority.clear();
- ruleToFlow.clear();
- denyRuleToAllowRule.clear();
- ruleToDevice.clear();
- }
-
- @Override
- public int getPriorityByDevice(DeviceId deviceId) {
- return deviceToPriority.compute(deviceId,
- (id, priority) -> (priority == null) ? defaultFlowMaxPriority : (priority - 1))
- .value();
- }
-
- @Override
- public Set<FlowRule> getFlowByRule(RuleId ruleId) {
- Versioned<Set<FlowRule>> flowRuleSet = ruleToFlow.get(ruleId);
- if (flowRuleSet != null) {
- return flowRuleSet.value();
- } else {
- return null;
- }
- }
-
- @Override
- public void addRuleToFlowMapping(RuleId ruleId, FlowRule flowRule) {
- ruleToFlow.computeIf(ruleId,
- flowRuleSet -> (flowRuleSet == null || !flowRuleSet.contains(flowRule)),
- (id, flowRuleSet) -> {
- Set<FlowRule> newSet = new HashSet<>();
- if (flowRuleSet != null) {
- newSet.addAll(flowRuleSet);
- }
- newSet.add(flowRule);
- return newSet;
- });
- }
-
- @Override
- public void removeRuleToFlowMapping(RuleId ruleId) {
- ruleToFlow.remove(ruleId);
- }
-
- @Override
- public List<RuleId> getAllowingRuleByDenyingRule(RuleId denyingRuleId) {
- Versioned<List<RuleId>> allowRuleIdSet = denyRuleToAllowRule.get(denyingRuleId);
- if (allowRuleIdSet != null) {
- return allowRuleIdSet.value();
- } else {
- return null;
- }
- }
-
- @Override
- public void addDenyToAllowMapping(RuleId denyingRuleId, RuleId allowingRuleId) {
- denyRuleToAllowRule.computeIf(denyingRuleId,
- ruleIdList -> (ruleIdList == null || !ruleIdList.contains(allowingRuleId)),
- (id, ruleIdList) -> {
- ArrayList<RuleId> newList = new ArrayList<>();
- if (ruleIdList != null) {
- newList.addAll(ruleIdList);
- }
- newList.add(allowingRuleId);
- return newList;
- });
- }
-
- @Override
- public void removeDenyToAllowMapping(RuleId denyingRuleId) {
- denyRuleToAllowRule.remove(denyingRuleId);
- }
-
- @Override
- public boolean checkIfRuleWorksInDevice(RuleId ruleId, DeviceId deviceId) {
- return ruleToDevice.containsKey(ruleId) && ruleToDevice.get(ruleId).value().contains(deviceId);
- }
-
- @Override
- public void addRuleToDeviceMapping(RuleId ruleId, DeviceId deviceId) {
- ruleToDevice.computeIf(ruleId,
- deviceIdSet -> (deviceIdSet == null || !deviceIdSet.contains(deviceId)),
- (id, deviceIdSet) -> {
- Set<DeviceId> newSet = new HashSet<>();
- if (deviceIdSet != null) {
- newSet.addAll(deviceIdSet);
- }
- newSet.add(deviceId);
- return newSet;
- });
- }
-
- @Override
- public void removeRuleToDeviceMapping(RuleId ruleId) {
- ruleToDevice.remove(ruleId);
- }
-
-}
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
deleted file mode 100644
index e9aa1448..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index fa4131ee..00000000
--- a/framework/src/onos/apps/acl/src/main/java/org/onos/acl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * ACL application.
- */
-package org.onos.acl;
diff --git a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java
index e792efba..9ec4c883 100644
--- a/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java
+++ b/framework/src/onos/apps/acl/src/main/java/org/onosproject/acl/AclWebResource.java
@@ -98,6 +98,7 @@ public class AclWebResource extends AbstractWebResource {
*
* @param stream JSON data describing the rule
* @return 200 OK
+ * @throws URISyntaxException uri syntax exception
*/
@POST
@Consumes(MediaType.APPLICATION_JSON)
diff --git a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java b/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java
deleted file mode 100644
index bb7d8051..00000000
--- a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/AclWebResourceTest.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl.web;
-
-import com.sun.jersey.api.client.WebResource;
-import org.onos.acl.AclService;
-import org.onos.acl.AclStore;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.rest.BaseResource;
-import org.onos.acl.AclRule;
-import org.onosproject.core.IdGenerator;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-import static org.easymock.EasyMock.*;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertThat;
-
-/**
- * Test class for ACL application REST resource.
- */
-public class AclWebResourceTest extends ResourceTest {
-
- final AclService mockAclService = createMock(AclService.class);
- final AclStore mockAclStore = createMock(AclStore.class);
- final List<AclRule> rules = new ArrayList<>();
-
- @Before
- public void setUp() {
- expect(mockAclService.getAclRules()).andReturn(rules).anyTimes();
- ServiceDirectory testDirectory = new TestServiceDirectory().add(AclService.class, mockAclService)
- .add(AclStore.class, mockAclStore);
- BaseResource.setServiceDirectory(testDirectory);
- }
-
- @After
- public void tearDown() {
- verify(mockAclService);
- }
-
- /**
- * Mock id generator for testing.
- */
- private class MockIdGenerator implements IdGenerator {
- private AtomicLong nextId = new AtomicLong(0);
-
- @Override
- public long getNewId() {
- return nextId.getAndIncrement();
- }
- }
-
- @Test
- public void testaddRule() throws IOException {
- WebResource rs = resource();
- String response;
- String json;
- IdGenerator idGenerator = new MockIdGenerator();
- AclRule.bindIdGenerator(idGenerator);
-
- replay(mockAclService);
-
- // input a invalid JSON string that contains neither nw_src and nw_dst
- json = "{\"ipProto\":\"TCP\",\"dstTpPort\":\"80\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Failed! Either srcIp or dstIp must be assigned."));
-
- // input a invalid JSON string that doesn't contain CIDR mask bits
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Malformed IPv4 prefix string: 10.0.0.1. " +
- "Address must take form \"x.x.x.x/y\""));
-
- // input a invalid JSON string that contains a invalid IP address
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.256/32\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Invalid IP address string: 10.0.0.256"));
-
- // input a invalid JSON string that contains a invalid IP address
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.01/32\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Invalid IP address string: 10.0.01"));
-
- // input a invalid JSON string that contains a invalid CIDR mask bits
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/a\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Failed! For input string: \"a\""));
-
- // input a invalid JSON string that contains a invalid CIDR mask bits
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/33\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("Invalid prefix length 33. The value must be in the interval [0, 32]"));
-
- // input a invalid JSON string that contains a invalid ipProto value
- json = "{\"ipProto\":\"ARP\",\"srcIp\":\"10.0.0.1/32\",\"dstTpPort\":\"80\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("ipProto must be assigned to TCP, UDP, or ICMP."));
-
- // input a invalid JSON string that contains a invalid dstTpPort value
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/32\",\"dstTpPort\":\"a\",\"action\":\"DENY\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("dstTpPort must be assigned to a numerical value."));
-
- // input a invalid JSON string that contains a invalid action value
- json = "{\"ipProto\":\"TCP\",\"srcIp\":\"10.0.0.1/32\",\"dstTpPort\":\"80\",\"action\":\"PERMIT\"}";
- response = rs.path("add").post(String.class, json);
- assertThat(response, containsString("action must be assigned to ALLOW or DENY."));
- }
-}
diff --git a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java b/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java
deleted file mode 100644
index 04cd10bd..00000000
--- a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/ResourceTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl.web;
-
-import com.sun.jersey.test.framework.AppDescriptor;
-import com.sun.jersey.test.framework.JerseyTest;
-import com.sun.jersey.test.framework.WebAppDescriptor;
-
-import java.io.IOException;
-import java.net.ServerSocket;
-
-/**
- * Base class for REST API tests. Performs common configuration operations.
- */
-public class ResourceTest extends JerseyTest {
-
- /**
- * Assigns an available port for the test.
- *
- * @param defaultPort If a port cannot be determined, this one is used.
- * @return free port
- */
- @Override
- public int getPort(int defaultPort) {
- try {
- ServerSocket socket = new ServerSocket(0);
- socket.setReuseAddress(true);
- int port = socket.getLocalPort();
- socket.close();
- return port;
- } catch (IOException ioe) {
- return defaultPort;
- }
- }
-
- @Override
- public AppDescriptor configure() {
- return new WebAppDescriptor.Builder("org.onos.acl").build();
- }
-
-}
diff --git a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java b/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java
deleted file mode 100644
index 6dbd302c..00000000
--- a/framework/src/onos/apps/acl/src/test/java/org/onos/acl/web/TestServiceDirectory.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- * Originally created by Pengfei Lu, Network and Cloud Computing Laboratory, Dalian University of Technology, China
- * Advisers: Keqiu Li and Heng Qi
- * This work is supported by the State Key Program of National Natural Science of China(Grant No. 61432002)
- * and Prospective Research Project on Future Networks in Jiangsu Future Networks Innovation Institute.
- *
- * 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.onos.acl.web;
-
-import com.google.common.collect.ClassToInstanceMap;
-import com.google.common.collect.MutableClassToInstanceMap;
-import org.onlab.osgi.ServiceDirectory;
-
-/**
- * Service directory implementation suitable for testing.
- */
-public class TestServiceDirectory implements ServiceDirectory {
-
-
- private ClassToInstanceMap<Object> services = MutableClassToInstanceMap.create();
-
- @Override
- public <T> T get(Class<T> serviceClass) {
- return services.getInstance(serviceClass);
- }
-
- /**
- * Adds a new service to the directory.
- *
- * @param serviceClass service class
- * @param service service instance
- * @return self
- */
- public TestServiceDirectory add(Class serviceClass, Object service) {
- services.putInstance(serviceClass, service);
- return this;
- }
-
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java
deleted file mode 100644
index e092586a..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressConfiguration.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.
- */
-package org.onosproject.config;
-
-import java.util.Collections;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-/**
- * Object to store address configuration read from a JSON file.
- */
-public class AddressConfiguration {
-
- private List<AddressEntry> addresses;
-
- /**
- * Gets a list of addresses in the system.
- *
- * @return the list of addresses
- */
- public List<AddressEntry> getAddresses() {
- return Collections.unmodifiableList(addresses);
- }
-
- /**
- * Sets a list of addresses in the system.
- *
- * @param addresses the list of addresses
- */
- @JsonProperty("addresses")
- public void setAddresses(List<AddressEntry> addresses) {
- this.addresses = addresses;
- }
-
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java
deleted file mode 100644
index 35fc4434..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/AddressEntry.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * 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.config;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-
-import java.util.List;
-
-/**
- * Represents a set of addresses bound to a port.
- */
-public class AddressEntry {
- private String dpid;
- private long portNumber;
- private List<String> ipAddresses;
- private String macAddress;
- private Short vlan;
-
- public String getDpid() {
- return dpid;
- }
-
- @JsonProperty("dpid")
- public void setDpid(String strDpid) {
- this.dpid = strDpid;
- }
-
- public long getPortNumber() {
- return portNumber;
- }
-
- @JsonProperty("port")
- public void setPortNumber(long portNumber) {
- this.portNumber = portNumber;
- }
-
- public List<String> getIpAddresses() {
- return ipAddresses;
- }
-
- @JsonProperty("ips")
- public void setIpAddresses(List<String> strIps) {
- this.ipAddresses = strIps;
- }
-
- public String getMacAddress() {
- return macAddress;
- }
-
- @JsonProperty("mac")
- public void setMacAddress(String macAddress) {
- this.macAddress = macAddress;
- }
-
- public Short getVlan() {
- return vlan;
- }
-
- @JsonProperty("vlan")
- public void setVlan(short vlan) {
- this.vlan = vlan;
- }
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java
deleted file mode 100644
index 4eb87b4a..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigReader.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * 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.config;
-
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Set;
-
-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.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.host.HostAdminService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-import org.slf4j.Logger;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Simple configuration module to read in supplementary network configuration
- * from a file.
- */
-@Component(immediate = true)
-@Service
-public class NetworkConfigReader implements NetworkConfigService {
-
- private final Logger log = getLogger(getClass());
-
- // Current working is /opt/onos/apache-karaf-*
- // TODO: Set the path to /opt/onos/config
- private static final String CONFIG_DIR = "../config";
- private static final String DEFAULT_CONFIG_FILE = "addresses.json";
- private String configFileName = DEFAULT_CONFIG_FILE;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostAdminService hostAdminService;
-
- @Activate
- protected void activate() {
- AddressConfiguration config = readNetworkConfig();
- if (config != null) {
- applyNetworkConfig(config);
- }
- log.info("Started network config reader");
- }
-
- @Deactivate
- protected void deactivate() {
- log.info("Stopped");
- }
-
- /**
- * Reads the network configuration.
- *
- * @return the network configuration on success, otherwise null
- */
- private AddressConfiguration readNetworkConfig() {
- File configFile = new File(CONFIG_DIR, configFileName);
- ObjectMapper mapper = new ObjectMapper();
-
- try {
- log.info("Loading config: {}", configFile.getAbsolutePath());
- AddressConfiguration config =
- mapper.readValue(configFile, AddressConfiguration.class);
-
- return config;
- } catch (FileNotFoundException e) {
- log.warn("Configuration file not found: {}", configFileName);
- } catch (IOException e) {
- log.error("Error loading configuration", e);
- }
-
- return null;
- }
-
- /**
- * Applies the network configuration.
- *
- * @param config the network configuration to apply
- */
- private void applyNetworkConfig(AddressConfiguration config) {
- for (AddressEntry entry : config.getAddresses()) {
- ConnectPoint cp = new ConnectPoint(
- DeviceId.deviceId(dpidToUri(entry.getDpid())),
- PortNumber.portNumber(entry.getPortNumber()));
-
- Set<InterfaceIpAddress> interfaceIpAddresses = new HashSet<>();
- for (String strIp : entry.getIpAddresses()) {
- // Get the IP address and the subnet mask length
- try {
- String[] splits = strIp.split("/");
- if (splits.length != 2) {
- throw new IllegalArgumentException(
- "Invalid IP address and prefix length format");
- }
- // NOTE: IpPrefix will mask-out the bits after the prefix length.
- IpPrefix subnet = IpPrefix.valueOf(strIp);
- IpAddress addr = IpAddress.valueOf(splits[0]);
- InterfaceIpAddress ia =
- new InterfaceIpAddress(addr, subnet);
- interfaceIpAddresses.add(ia);
- } catch (IllegalArgumentException e) {
- log.warn("Bad format for IP address in config: {}", strIp);
- }
- }
-
- MacAddress macAddress = null;
- if (entry.getMacAddress() != null) {
- try {
- macAddress = MacAddress.valueOf(entry.getMacAddress());
- } catch (IllegalArgumentException e) {
- log.warn("Bad format for MAC address in config: {}",
- entry.getMacAddress());
- }
- }
-
- VlanId vlan = null;
- if (entry.getVlan() == null) {
- vlan = VlanId.NONE;
- } else {
- try {
- vlan = VlanId.vlanId(entry.getVlan());
- } catch (IllegalArgumentException e) {
- log.warn("Bad format for VLAN id in config: {}",
- entry.getVlan());
- vlan = VlanId.NONE;
- }
- }
-
- PortAddresses addresses = new PortAddresses(cp,
- interfaceIpAddresses, macAddress, vlan);
- hostAdminService.bindAddressesToPort(addresses);
- }
- }
-
- private static String dpidToUri(String dpid) {
- return "of:" + dpid.replace(":", "");
- }
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java
deleted file mode 100644
index 1d9a895d..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/NetworkConfigService.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.config;
-
-/**
- * Service interface exported by the Network Configuration.
- *
- * @deprecated in Drake; see org.onosproject.net.config
- */
-@Deprecated
-public interface NetworkConfigService {
-}
diff --git a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java b/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java
deleted file mode 100644
index 6552f206..00000000
--- a/framework/src/onos/apps/config/src/main/java/org/onosproject/config/package-info.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * 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.
- */
-
-/**
- * Simple configuration module to read in supplementary network configuration
- * from a file.
- */
-package org.onosproject.config;
diff --git a/framework/src/onos/apps/config/src/main/resources/addresses.json b/framework/src/onos/apps/config/src/main/resources/addresses.json
deleted file mode 100644
index a88ed62a..00000000
--- a/framework/src/onos/apps/config/src/main/resources/addresses.json
+++ /dev/null
@@ -1,36 +0,0 @@
-{
- "addresses" : [
- {
- "dpid" : "00:00:00:00:00:00:00:a3",
- "port" : "1",
- "ips" : ["192.168.10.101/24"],
- "mac" : "00:00:00:00:00:01",
- "vlan" : "1"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a5",
- "port" : "1",
- "ips" : ["192.168.20.101/24"],
- "mac" : "00:00:00:00:00:01",
- "vlan" : "2"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a2",
- "port" : "1",
- "ips" : ["192.168.30.101/24"],
- "mac" : "00:00:00:00:00:01"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a6",
- "port" : "1",
- "ips" : ["192.168.40.101/24"],
- "mac" : "00:00:00:00:00:01"
- },
- {
- "dpid" : "00:00:00:00:00:00:00:a4",
- "port" : "4",
- "ips" : ["192.168.60.101/24"],
- "mac" : "00:00:00:00:00:01"
- }
- ]
-}
diff --git a/framework/src/onos/apps/cordvtn/pom.xml b/framework/src/onos/apps/cordvtn/pom.xml
index a019bec2..b8e913d4 100644
--- a/framework/src/onos/apps/cordvtn/pom.xml
+++ b/framework/src/onos/apps/cordvtn/pom.xml
@@ -49,6 +49,11 @@
<artifactId>onos-core-serializers</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-ovsdb-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
</project>
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
index cb8acab2..ba707800 100644
--- 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
@@ -15,6 +15,8 @@
*/
package org.onosproject.cordvtn;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.Sets;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -22,31 +24,39 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.util.KryoNamespace;
+import org.onosproject.cluster.ClusterService;
+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.behaviour.ControllerInfo;
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.ovsdb.controller.OvsdbClientService;
+import org.onosproject.ovsdb.controller.OvsdbController;
+import org.onosproject.ovsdb.controller.OvsdbNodeId;
import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.LogicalClockService;
+import org.onosproject.store.service.ConsistentMap;
+import org.onosproject.store.service.Serializer;
import org.onosproject.store.service.StorageService;
+import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-import java.util.stream.Collectors;
+import static com.google.common.base.Preconditions.checkNotNull;
import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.cordvtn.OvsdbNode.State;
-import static org.onosproject.cordvtn.OvsdbNode.State.INIT;
-import static org.onosproject.cordvtn.OvsdbNode.State.DISCONNECT;
import static org.onosproject.net.Device.Type.SWITCH;
import static org.slf4j.LoggerFactory.getLogger;
@@ -63,7 +73,17 @@ public class CordVtn implements CordVtnService {
private static final int NUM_THREADS = 1;
private static final KryoNamespace.Builder NODE_SERIALIZER = KryoNamespace.newBuilder()
.register(KryoNamespaces.API)
- .register(OvsdbNode.class);
+ .register(DefaultOvsdbNode.class);
+ private static final String DEFAULT_BRIDGE_NAME = "br-int";
+ private static final Map<String, String> VXLAN_OPTIONS = new HashMap<String, String>() {
+ {
+ put("key", "flow");
+ put("local_ip", "flow");
+ put("remote_ip", "flow");
+ }
+ };
+ private static final int DPID_BEGIN = 3;
+ private static final int OFPORT = 6653;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -72,14 +92,20 @@ public class CordVtn implements CordVtnService {
protected StorageService storageService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LogicalClockService clockService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected DeviceService deviceService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected HostService hostService;
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected OvsdbController controller;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
private final ExecutorService eventExecutor = Executors
.newFixedThreadPool(NUM_THREADS, groupedThreads("onos/cordvtn", "event-handler"));
@@ -90,15 +116,16 @@ public class CordVtn implements CordVtnService {
private final BridgeHandler bridgeHandler = new BridgeHandler();
private final VmHandler vmHandler = new VmHandler();
- private EventuallyConsistentMap<DeviceId, OvsdbNode> nodeStore;
+ private ConsistentMap<DeviceId, OvsdbNode> nodeStore;
+ private ApplicationId appId;
@Activate
protected void activate() {
- coreService.registerApplication("org.onosproject.cordvtn");
- nodeStore = storageService.<DeviceId, OvsdbNode>eventuallyConsistentMapBuilder()
+ appId = coreService.registerApplication("org.onosproject.cordvtn");
+ nodeStore = storageService.<DeviceId, OvsdbNode>consistentMapBuilder()
+ .withSerializer(Serializer.using(NODE_SERIALIZER.build()))
.withName("cordvtn-nodestore")
- .withSerializer(NODE_SERIALIZER)
- .withTimestampProvider((k, v) -> clockService.getTimestamp())
+ .withApplicationId(appId)
.build();
deviceService.addListener(deviceListener);
@@ -113,43 +140,59 @@ public class CordVtn implements CordVtnService {
hostService.removeListener(hostListener);
eventExecutor.shutdown();
- nodeStore.destroy();
+ nodeStore.clear();
log.info("Stopped");
}
@Override
- public void addNode(OvsdbNode ovsdbNode) {
- if (nodeStore.containsKey(ovsdbNode.deviceId())) {
- log.warn("Node {} already exists", ovsdbNode.host());
+ public void addNode(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+ nodeStore.put(ovsdb.deviceId(), ovsdb);
+ }
+
+ @Override
+ public void deleteNode(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ if (!nodeStore.containsKey(ovsdb.deviceId())) {
return;
}
- nodeStore.put(ovsdbNode.deviceId(), ovsdbNode);
- if (ovsdbNode.state() != INIT) {
- updateNode(ovsdbNode, INIT);
+
+ // check ovsdb and integration bridge connection state first
+ if (isNodeConnected(ovsdb)) {
+ log.warn("Cannot delete connected node {}", ovsdb.host());
+ } else {
+ nodeStore.remove(ovsdb.deviceId());
}
}
@Override
- public void deleteNode(OvsdbNode ovsdbNode) {
- if (!nodeStore.containsKey(ovsdbNode.deviceId())) {
- log.warn("Node {} does not exist", ovsdbNode.host());
+ public void connect(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ if (!nodeStore.containsKey(ovsdb.deviceId())) {
+ log.warn("Node {} does not exist", ovsdb.host());
return;
}
- updateNode(ovsdbNode, DISCONNECT);
+ controller.connect(ovsdb.ip(), ovsdb.port());
}
@Override
- public void updateNode(OvsdbNode ovsdbNode, State state) {
- if (!nodeStore.containsKey(ovsdbNode.deviceId())) {
- log.warn("Node {} does not exist", ovsdbNode.host());
+ public void disconnect(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ if (!nodeStore.containsKey(ovsdb.deviceId())) {
+ log.warn("Node {} does not exist", ovsdb.host());
return;
}
- DefaultOvsdbNode updatedNode = new DefaultOvsdbNode(ovsdbNode.host(),
- ovsdbNode.ip(),
- ovsdbNode.port(),
- state);
- nodeStore.put(ovsdbNode.deviceId(), updatedNode);
+
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ checkNotNull(ovsdbClient);
+
+ if (ovsdbClient.isConnected()) {
+ ovsdbClient.disconnect();
+ }
}
@Override
@@ -159,14 +202,42 @@ public class CordVtn implements CordVtnService {
@Override
public OvsdbNode getNode(DeviceId deviceId) {
- return nodeStore.get(deviceId);
+ Versioned<OvsdbNode> ovsdb = nodeStore.get(deviceId);
+ if (ovsdb != null) {
+ return ovsdb.value();
+ } else {
+ return null;
+ }
}
@Override
public List<OvsdbNode> getNodes() {
- return nodeStore.values()
- .stream()
- .collect(Collectors.toList());
+ List<OvsdbNode> ovsdbs = new ArrayList<>();
+ ovsdbs.addAll(Collections2.transform(nodeStore.values(), Versioned::value));
+ return ovsdbs;
+ }
+
+ @Override
+ public boolean isNodeConnected(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ if (ovsdbClient == null) {
+ return false;
+ } else {
+ return ovsdbClient.isConnected();
+ }
+ }
+
+ private OvsdbClientService getOvsdbClient(OvsdbNode ovsdb) {
+ checkNotNull(ovsdb);
+
+ OvsdbClientService ovsdbClient = controller.getOvsdbClient(
+ new OvsdbNodeId(ovsdb.ip(), ovsdb.port().toInt()));
+ if (ovsdbClient == null) {
+ log.warn("Couldn't find ovsdb client of node {}", ovsdb.host());
+ }
+ return ovsdbClient;
}
private class InternalDeviceListener implements DeviceListener {
@@ -182,6 +253,7 @@ public class CordVtn implements CordVtnService {
break;
case DEVICE_AVAILABILITY_CHANGED:
eventExecutor.submit(() -> handler.disconnected(device));
+ // TODO handle the case that the device is recovered
break;
default:
break;
@@ -212,14 +284,27 @@ public class CordVtn implements CordVtnService {
@Override
public void connected(Device device) {
- // create bridge and set bridgeId
- // set node state connected
+ log.info("Ovsdb {} is connected", device.id());
+
+ if (!mastershipService.isLocalMaster(device.id())) {
+ return;
+ }
+
+ // TODO change to use bridge config
+ OvsdbNode ovsdb = getNode(device.id());
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+
+ List<ControllerInfo> controllers = new ArrayList<>();
+ Sets.newHashSet(clusterService.getNodes()).forEach(controller ->
+ controllers.add(new ControllerInfo(controller.ip(), OFPORT, "tcp")));
+ String dpid = ovsdb.intBrId().toString().substring(DPID_BEGIN);
+
+ ovsdbClient.createBridge(DEFAULT_BRIDGE_NAME, dpid, controllers);
}
@Override
public void disconnected(Device device) {
- // set node state disconnected if the node exists
- // which means that the node is not deleted explicitly
+ log.warn("Ovsdb {} is disconnected", device.id());
}
}
@@ -227,12 +312,29 @@ public class CordVtn implements CordVtnService {
@Override
public void connected(Device device) {
- // create vxlan port
+ log.info("Integration Bridge {} is detected", device.id());
+
+ OvsdbNode ovsdb = getNodes().stream()
+ .filter(node -> node.intBrId().equals(device.id()))
+ .findFirst().get();
+
+ if (ovsdb == null) {
+ log.warn("Couldn't find OVSDB associated with {}", device.id());
+ return;
+ }
+
+ if (!mastershipService.isLocalMaster(ovsdb.deviceId())) {
+ return;
+ }
+
+ // TODO change to use tunnel config and tunnel description
+ OvsdbClientService ovsdbClient = getOvsdbClient(ovsdb);
+ ovsdbClient.createTunnel(DEFAULT_BRIDGE_NAME, "vxlan", "vxlan", VXLAN_OPTIONS);
}
@Override
public void disconnected(Device device) {
-
+ log.info("Integration Bridge {} is vanished", device.id());
}
}
@@ -240,12 +342,12 @@ public class CordVtn implements CordVtnService {
@Override
public void connected(Host host) {
- // install flow rules for this vm
+ log.info("VM {} is detected", host.id());
}
@Override
public void disconnected(Host host) {
- // uninstall flow rules associated with this vm
+ log.info("VM {} is vanished", host.id());
}
}
}
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
index fdaf752a..550452ce 100644
--- 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
@@ -20,6 +20,7 @@ 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.DeviceId;
import org.onosproject.net.config.Config;
import java.util.Set;
@@ -35,6 +36,7 @@ public class CordVtnConfig extends Config<ApplicationId> {
public static final String HOST = "host";
public static final String IP = "ip";
public static final String PORT = "port";
+ public static final String BRIDGE_ID = "bridgeId";
/**
* Returns the set of ovsdb nodes read from network config.
@@ -51,7 +53,8 @@ public class CordVtnConfig extends Config<ApplicationId> {
nodes.forEach(jsonNode -> ovsdbNodes.add(new OvsdbNodeConfig(
jsonNode.path(HOST).asText(),
IpAddress.valueOf(jsonNode.path(IP).asText()),
- TpPort.tpPort(jsonNode.path(PORT).asInt()))));
+ TpPort.tpPort(jsonNode.path(PORT).asInt()),
+ DeviceId.deviceId(jsonNode.path(BRIDGE_ID).asText()))));
return ovsdbNodes;
}
@@ -64,11 +67,13 @@ public class CordVtnConfig extends Config<ApplicationId> {
private final String host;
private final IpAddress ip;
private final TpPort port;
+ private final DeviceId bridgeId;
- public OvsdbNodeConfig(String host, IpAddress ip, TpPort port) {
+ public OvsdbNodeConfig(String host, IpAddress ip, TpPort port, DeviceId bridgeId) {
this.host = checkNotNull(host);
this.ip = checkNotNull(ip);
this.port = checkNotNull(port);
+ this.bridgeId = checkNotNull(bridgeId);
}
/**
@@ -97,5 +102,9 @@ public class CordVtnConfig extends Config<ApplicationId> {
public TpPort port() {
return this.port;
}
+
+ public DeviceId bridgeId() {
+ return this.bridgeId;
+ }
}
}
diff --git a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
index 043b3760..f276c7ca 100644
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
+++ b/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/CordVtnConfigManager.java
@@ -20,11 +20,6 @@ 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.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.net.config.ConfigFactory;
@@ -35,7 +30,6 @@ import org.onosproject.net.config.NetworkConfigService;
import org.onosproject.net.config.basics.SubjectFactories;
import org.slf4j.Logger;
-import static org.onosproject.cordvtn.OvsdbNode.State.INIT;
import static org.slf4j.LoggerFactory.getLogger;
/**
@@ -58,12 +52,6 @@ public class CordVtnConfigManager {
protected NetworkConfigService configService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CordVtnService cordVtnService;
private final ConfigFactory configFactory =
@@ -74,29 +62,22 @@ public class CordVtnConfigManager {
}
};
- private final LeadershipEventListener leadershipListener = new InternalLeadershipListener();
private final NetworkConfigListener configListener = new InternalConfigListener();
- private NodeId local;
private ApplicationId appId;
@Activate
protected void active() {
- local = clusterService.getLocalNode().id();
appId = coreService.getAppId(CordVtnService.CORDVTN_APP_ID);
configService.addListener(configListener);
configRegistry.registerConfigFactory(configFactory);
- leadershipService.addListener(leadershipListener);
- leadershipService.runForLeadership(CordVtnService.CORDVTN_APP_ID);
+ readConfiguration();
}
@Deactivate
protected void deactivate() {
- leadershipService.removeListener(leadershipListener);
- leadershipService.withdraw(appId.name());
-
configRegistry.unregisterConfigFactory(configFactory);
configService.removeListener(configListener);
}
@@ -110,30 +91,13 @@ public class CordVtnConfigManager {
}
config.ovsdbNodes().forEach(node -> {
- DefaultOvsdbNode ovsdbNode =
- new DefaultOvsdbNode(node.host(), node.ip(), node.port(), INIT);
- cordVtnService.addNode(ovsdbNode);
- log.info("Add new node {}", node.host());
+ DefaultOvsdbNode ovsdb = new DefaultOvsdbNode(
+ node.host(), node.ip(), node.port(), node.bridgeId());
+ cordVtnService.addNode(ovsdb);
+ cordVtnService.connect(ovsdb);
});
}
- private synchronized void processLeadershipChange(NodeId leader) {
- if (leader == null || !leader.equals(local)) {
- return;
- }
- readConfiguration();
- }
-
- private class InternalLeadershipListener implements LeadershipEventListener {
-
- @Override
- public void event(LeadershipEvent event) {
- if (event.subject().topic().equals(appId.name())) {
- processLeadershipChange(event.subject().leader());
- }
- }
- }
-
private class InternalConfigListener implements NetworkConfigListener {
@Override
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
index 1f75dceb..7e01a452 100644
--- 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
@@ -15,7 +15,6 @@
*/
package org.onosproject.cordvtn;
-import org.onosproject.cordvtn.OvsdbNode.State;
import org.onosproject.net.DeviceId;
import java.util.List;
@@ -29,25 +28,30 @@ public interface CordVtnService {
/**
* Adds a new node to the service.
*
- * @param ovsdbNode ovsdb node
+ * @param ovsdb ovsdb node
*/
- void addNode(OvsdbNode ovsdbNode);
+ void addNode(OvsdbNode ovsdb);
/**
* Deletes a node from the service.
*
- * @param ovsdbNode ovsdb node
+ * @param ovsdb ovsdb node
*/
- void deleteNode(OvsdbNode ovsdbNode);
+ void deleteNode(OvsdbNode ovsdb);
/**
- * Updates ovsdb node.
- * It only used for updating node's connection state.
+ * Connect to a node.
*
- * @param ovsdbNode ovsdb node
- * @param state ovsdb connection state
+ * @param ovsdb ovsdb node
*/
- void updateNode(OvsdbNode ovsdbNode, State state);
+ void connect(OvsdbNode ovsdb);
+
+ /**
+ * Disconnect a node.
+ *
+ * @param ovsdb ovsdb node
+ */
+ void disconnect(OvsdbNode ovsdb);
/**
* Returns the number of the nodes known to the service.
@@ -65,6 +69,14 @@ public interface CordVtnService {
OvsdbNode getNode(DeviceId deviceId);
/**
+ * Returns connection state of the node.
+ *
+ * @param ovsdb ovsdb node
+ * @return true if the node is connected, false otherwise
+ */
+ boolean isNodeConnected(OvsdbNode ovsdb);
+
+ /**
* Returns all nodes known to the service.
*
* @return list of nodes
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
index ce8b0f1d..eba52108 100644
--- 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
@@ -30,13 +30,13 @@ public class DefaultOvsdbNode implements OvsdbNode {
private final String host;
private final IpAddress ip;
private final TpPort port;
- private final State state;
+ private final DeviceId brId;
- public DefaultOvsdbNode(String host, IpAddress ip, TpPort port, State state) {
+ public DefaultOvsdbNode(String host, IpAddress ip, TpPort port, DeviceId brId) {
this.host = host;
this.ip = ip;
this.port = port;
- this.state = state;
+ this.brId = brId;
}
@Override
@@ -55,8 +55,8 @@ public class DefaultOvsdbNode implements OvsdbNode {
}
@Override
- public State state() {
- return this.state;
+ public DeviceId intBrId() {
+ return this.brId;
}
@Override
@@ -65,11 +65,6 @@ public class DefaultOvsdbNode implements OvsdbNode {
}
@Override
- public DeviceId intBrId() {
- return DeviceId.deviceId("of:" + this.host);
- }
-
- @Override
public boolean equals(Object o) {
if (this == o) {
return true;
@@ -79,7 +74,8 @@ public class DefaultOvsdbNode implements OvsdbNode {
DefaultOvsdbNode that = (DefaultOvsdbNode) o;
if (this.host.equals(that.host) &&
this.ip.equals(that.ip) &&
- this.port.equals(that.port)) {
+ this.port.equals(that.port) &&
+ this.brId.equals(that.brId)) {
return true;
}
}
@@ -97,7 +93,7 @@ public class DefaultOvsdbNode implements OvsdbNode {
.add("host", host)
.add("ip", ip)
.add("port", port)
- .add("state", state)
+ .add("bridgeId", brId)
.toString();
}
}
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
deleted file mode 100644
index ebba4cd5..00000000
--- a/framework/src/onos/apps/cordvtn/src/main/java/org/onosproject/cordvtn/NodeConnectionManager.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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.onosproject.cluster.ClusterService;
-import org.onosproject.cluster.LeadershipService;
-import org.onosproject.cluster.NodeId;
-import org.onosproject.mastership.MastershipService;
-import org.onosproject.net.Device;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-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.onosproject.cordvtn.OvsdbNode.State.CONNECTED;
-import static org.onosproject.cordvtn.OvsdbNode.State.DISCONNECTED;
-import static org.onosproject.cordvtn.OvsdbNode.State.READY;
-import static org.slf4j.LoggerFactory.getLogger;
-
-/**
- * Provides the connection state management of all nodes registered to the service
- * so that the nodes keep connected unless it is requested to be deleted.
- */
-@Component(immediate = true)
-public class NodeConnectionManager {
- protected final Logger log = getLogger(getClass());
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- MastershipService mastershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- LeadershipService leadershipService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- ClusterService clusterService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- DeviceService deviceService;
-
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- CordVtnService cordVtnService;
-
- private static final int DELAY_SEC = 5;
-
- private final DeviceListener deviceListener = new InternalDeviceListener();
- private final ScheduledExecutorService connectionExecutor = Executors
- .newSingleThreadScheduledExecutor(groupedThreads("onos/cordvtn", "connection-manager"));
-
- private NodeId localId;
-
- @Activate
- protected void activate() {
- localId = clusterService.getLocalNode().id();
- deviceService.addListener(deviceListener);
-
- connectionExecutor.scheduleWithFixedDelay(() -> cordVtnService.getNodes()
- .stream()
- .filter(node -> localId.equals(getMaster(node)))
- .forEach(node -> {
- connect(node);
- disconnect(node);
- }), 0, DELAY_SEC, TimeUnit.SECONDS);
- }
-
- @Deactivate
- public void stop() {
- connectionExecutor.shutdown();
- deviceService.removeListener(deviceListener);
- }
-
- public void connect(OvsdbNode ovsdbNode) {
- switch (ovsdbNode.state()) {
- case INIT:
- case DISCONNECTED:
- setPassiveMode(ovsdbNode);
- case READY:
- setupConnection(ovsdbNode);
- break;
- default:
- break;
- }
- }
-
- public void disconnect(OvsdbNode ovsdbNode) {
- switch (ovsdbNode.state()) {
- case DISCONNECT:
- // TODO: disconnect
- break;
- default:
- break;
- }
- }
-
- private class InternalDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (device.type() != Device.Type.CONTROLLER) {
- return;
- }
-
- DefaultOvsdbNode node;
- switch (event.type()) {
- case DEVICE_ADDED:
- node = (DefaultOvsdbNode) cordVtnService.getNode(device.id());
- if (node != null) {
- cordVtnService.updateNode(node, CONNECTED);
- }
- break;
- case DEVICE_AVAILABILITY_CHANGED:
- node = (DefaultOvsdbNode) cordVtnService.getNode(device.id());
- if (node != null) {
- cordVtnService.updateNode(node, DISCONNECTED);
- }
- break;
- default:
- break;
- }
- }
- }
-
- private NodeId getMaster(OvsdbNode ovsdbNode) {
- NodeId master = mastershipService.getMasterFor(ovsdbNode.intBrId());
-
- // master is null if there's no such device
- if (master == null) {
- master = leadershipService.getLeader(CordVtnService.CORDVTN_APP_ID);
- }
- return master;
- }
-
- private void setPassiveMode(OvsdbNode ovsdbNode) {
- // TODO: need ovsdb client implementation first
- // TODO: set the remove ovsdb server passive mode
- cordVtnService.updateNode(ovsdbNode, READY);
- }
-
- private void setupConnection(OvsdbNode ovsdbNode) {
- // TODO initiate connection
- }
-}
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
index 296bd439..c5b7a078 100644
--- 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
@@ -23,12 +23,6 @@ import org.onosproject.net.DeviceId;
* Representation of a node with ovsdb server.
*/
public interface OvsdbNode {
- /**
- * Ovsdb connection state.
- */
- enum State {
- INIT, READY, CONNECTED, DISCONNECT, DISCONNECTED
- }
/**
* Returns the IP address of the ovsdb server.
@@ -53,13 +47,6 @@ public interface OvsdbNode {
String host();
/**
- * Returns the connection state of the ovsdb server.
- *
- * @return connection state
- */
- State state();
-
- /**
* Returns the device id of the ovsdb server.
*
* @return device id
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 5615af1a..e263b3a2 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
@@ -64,6 +64,7 @@ public interface DhcpStore {
* Releases the IP assigned to a Mac ID into the free pool.
*
* @param hostId the host ID for which the mapping needs to be changed
+ * @return released ip
*/
Ip4Address releaseIP(HostId hostId);
diff --git a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java b/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java
deleted file mode 100644
index 0059e7e5..00000000
--- a/framework/src/onos/apps/dhcp/src/main/java/org/onosproject/dhcp/impl/DhcpStoreConfig.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.
- */
-package org.onosproject.dhcp.impl;
-
-import org.onosproject.core.ApplicationId;
-import org.onosproject.net.config.Config;
-import org.onosproject.net.config.basics.BasicElementConfig;
-
-/**
- * DHCP Store Config class.
- */
-public class DhcpStoreConfig extends Config<ApplicationId> {
-
- 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";
-
- /**
- * Returns the delay after which the dhcp server will purge expired entries.
- *
- * @return time delay or null if not set
- */
- public String timerDelay() {
- return get(TIMER_DELAY, null);
- }
-
- /**
- * 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(String delay) {
- return (BasicElementConfig) setOrClear(TIMER_DELAY, delay);
- }
-
- /**
- * Returns the default timeout for pending assignments.
- *
- * @return default timeout or null if not set
- */
- public String defaultTimeout() {
- return get(DEFAULT_TIMEOUT, null);
- }
-
- /**
- * Sets the default timeout for pending assignments.
- *
- * @param defaultTimeout new default timeout; null to clear
- * @return self
- */
- public BasicElementConfig defaultTimeout(String 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 String startIP() {
- return get(START_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 String endIP() {
- return get(END_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/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java b/framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java
index 6aaaaee8..86ab37fa 100644
--- a/framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java
+++ b/framework/src/onos/apps/flowanalyzer/src/main/java/org/onosproject/flowanalyzer/FlowAnalyzer.java
@@ -85,6 +85,8 @@ public class FlowAnalyzer {
* the network. The possible states are: Cleared (implying that the entry leads to
* a host), Cycle (implying that it is part of cycle), and Black Hole (implying
* that the entry does not lead to a single host).
+ *
+ * @return result string
*/
public String analyze() {
graph = topologyService.getGraph(topologyService.currentTopology());
diff --git a/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java b/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java
index ae539c62..b7827406 100644
--- a/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java
+++ b/framework/src/onos/apps/igmp/src/main/java/org/onosproject/igmp/impl/IGMPComponent.java
@@ -111,18 +111,18 @@ public class IGMPComponent {
"\tingress port: " + context.inPacket().receivedFrom().toString());
if (ip.getProtocol() != IPv4.PROTOCOL_IGMP) {
- log.error("IGMP Picked up a non IGMP packet.");
+ log.debug("IGMP Picked up a non IGMP packet.");
return;
}
IpPrefix mcast = IpPrefix.valueOf("224.0.0.0/4");
if (!mcast.contains(gaddr)) {
- log.error("IGMP Picked up a non multicast packet.");
+ log.debug("IGMP Picked up a non multicast packet.");
return;
}
if (mcast.contains(saddr)) {
- log.error("IGMP Picked up a packet with a multicast source address.");
+ log.debug("IGMP Picked up a packet with a multicast source address.");
return;
}
IpPrefix spfx = IpPrefix.valueOf(saddr, 32);
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 fb984c9e..1f0df456 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
@@ -196,10 +196,10 @@ public class TopologyMetrics implements TopologyMetricsService {
// Ignore PORT_STATS_UPDATED probe event from interfering with
// other device event timestamps
if (event.type() == DeviceEvent.Type.PORT_STATS_UPDATED) {
- log.info("PORT_STATS_UPDATED event ignored from metrics");
+ log.debug("PORT_STATS_UPDATED event ignored from metrics");
} else {
recordEvent(event, topologyDeviceEventMetric);
- log.info("Device Event: time = {} type = {} event = {}",
+ log.debug("Device Event: time = {} type = {} event = {}",
event.time(), event.type(), event);
}
}
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
index ae5d9e93..c794c800 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/cli/McastDeleteCommand.java
@@ -37,9 +37,32 @@ public class McastDeleteCommand extends AbstractShellCommand {
required = true, multiValued = false)
String gAddr = null;
+ @Argument(index = 2, name = "egressList",
+ description = "Egress id/port",
+ required = false, multiValued = true)
+ String[] egressList = null;
+
+
@Override
protected void execute() {
+
+ boolean deleted = false;
McastRouteTable mrib = McastRouteTable.getInstance();
- mrib.removeRoute(sAddr, gAddr);
+
+ if (egressList == null) {
+ mrib.removeRoute(sAddr, gAddr);
+ deleted = true;
+ } else {
+ // check list for validity before we begin to delete.
+ for (String egress : egressList) {
+ deleted = mrib.removeEgress(sAddr, gAddr, egress);
+ }
+ }
+
+ if (deleted) {
+ print("Successful delete");
+ } else {
+ print("Failed to delete");
+ }
}
-} \ No newline at end of file
+}
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
index 90f65c94..b7f1f3ce 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastIntentManager.java
@@ -79,8 +79,7 @@ public class McastIntentManager {
TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
- if (mroute.getIngressPoint() == null ||
- mroute.getEgressPoints().isEmpty()) {
+ if (mroute.getIngressPoint() == null) {
return null;
}
@@ -96,16 +95,22 @@ public class McastIntentManager {
.matchIPDst(mroute.getGaddr())
.matchIPSrc(mroute.getSaddr());
- SinglePointToMultiPointIntent intent =
- SinglePointToMultiPointIntent.builder()
+
+ SinglePointToMultiPointIntent.Builder builder = SinglePointToMultiPointIntent.builder()
.appId(McastForwarding.getAppId())
.selector(selector.build())
.treatment(treatment)
- .ingressPoint(mroute.getIngressPoint().getConnectPoint())
- .egressPoints(mroute.getEgressConnectPoints()).
- build();
+ .ingressPoint(mroute.getIngressPoint().getConnectPoint());
+
+ // allowing intent to be pushed without egress points means we can drop packets.
+ if (!mroute.getEgressPoints().isEmpty()) {
+ builder.egressPoints(mroute.getEgressConnectPoints());
+ }
+ SinglePointToMultiPointIntent intent = builder.build();
intentService.submit(intent);
+ mroute.setDirty(false);
+
return intent;
}
@@ -114,9 +119,10 @@ public class McastIntentManager {
*
* @param mroute the mcast route whose intent we want to remove
*/
- public void withdrawIntent(McastRouteBase mroute) {
+ public void withdrawIntent(McastRoute mroute) {
Intent intent = intentService.getIntent(mroute.getIntentKey());
intentService.withdraw(intent);
+ mroute.setDirty(false);
}
/**
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
index 12b7e6d4..a67725d7 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRoute.java
@@ -57,6 +57,21 @@ interface McastRoute {
public boolean isIp6();
/**
+ * Get the dirty state.
+ *
+ * @return whether this route is dirty or not.
+ */
+ public boolean getDirty();
+
+ /**
+ * Set the dirty state to indicate that something changed.
+ * This may require an update to the flow tables (intents).
+ *
+ * @param dirty set the dirty bit
+ */
+ public void setDirty(boolean dirty);
+
+ /**
* Add the ingress ConnectPoint.
*
* @param cpstr string representing a ConnectPoint
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
index 730acfa7..4da1f33c 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteBase.java
@@ -17,7 +17,6 @@ package org.onosproject.mfwd.impl;
import static com.google.common.base.Preconditions.checkNotNull;
-import org.apache.commons.collections.set.ListOrderedSet;
import org.onlab.packet.IpPrefix;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.intent.SinglePointToMultiPointIntent;
@@ -267,6 +266,33 @@ public class McastRouteBase implements McastRoute {
}
/**
+ * Remove an egress from McastConnectPoint.
+ *
+ * @param connectPoint the egress connect point
+ * @return boolean result of removal
+ */
+ public boolean removeEgressPoint(String connectPoint) {
+ checkNotNull(connectPoint);
+ return this.removeEgressPoint(ConnectPoint.deviceConnectPoint(connectPoint));
+ }
+
+ /**
+ * Remove an egress from McastConnectPoint.
+ *
+ * @param cp the egress connect point
+ * @return boolean result of removal
+ */
+ public boolean removeEgressPoint(ConnectPoint cp) {
+ boolean removed = false;
+ McastConnectPoint mcp = this.findEgressConnectPoint(checkNotNull(cp));
+ if (mcp != null) {
+ removed = egressPoints.remove(mcp);
+ setDirty(true);
+ }
+ return removed;
+ }
+
+ /**
* Add an egress McastConnectPoint.
*
* @param cpstr deviceId/port of the connect point
@@ -292,7 +318,7 @@ public class McastRouteBase implements McastRoute {
* @return Set of egress ConnectPoints
*/
public Set<ConnectPoint> getEgressConnectPoints() {
- Set<ConnectPoint> cps = new ListOrderedSet();
+ Set<ConnectPoint> cps = new HashSet<ConnectPoint>();
for (McastConnectPoint mcp : egressPoints) {
cps.add(mcp.getConnectPoint());
@@ -417,7 +443,7 @@ public class McastRouteBase implements McastRoute {
out += "intent: ";
out += (intentKey == null) ? "not installed" : this.intentKey.toString();
out += "\n\tingress: ";
- out += (ingressPoint == null) ? "NULL" : ingressPoint.toString();
+ out += (ingressPoint == null) ? "NULL" : ingressPoint.getConnectPoint().toString();
out += "\n\tegress: {\n";
if (egressPoints != null && !egressPoints.isEmpty()) {
for (McastConnectPoint eg : egressPoints) {
diff --git a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
index 5a07bec7..1140c3a8 100644
--- a/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
+++ b/framework/src/onos/apps/mfwd/src/main/java/org/onosproject/mfwd/impl/McastRouteTable.java
@@ -17,6 +17,7 @@ package org.onosproject.mfwd.impl;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpPrefix;
+
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull;
@@ -191,6 +192,30 @@ public final class McastRouteTable {
}
/**
+ * Delete a specific egress from the MRIB.
+ *
+ * @param saddr source address * or x.x.x.x or x.x.x.x/y
+ * @param gaddr group address x.x.x.x or x.x.x.x/y
+ * @param egress group address x.x.x.x or x.x.x.x/y
+ * @return boolean if egress was deleted
+ */
+ public boolean removeEgress(String saddr, String gaddr, String egress) {
+
+ IpPrefix gpfx = IpPrefix.valueOf(gaddr);
+ IpPrefix spfx = IpPrefix.valueOf(0, 0);
+ if (saddr != null && !saddr.equals("*")) {
+ spfx = IpPrefix.valueOf(saddr);
+ }
+
+ McastRouteSource src = (McastRouteSource) findBestMatch(spfx, gpfx);
+ boolean removed = src.removeEgressPoint(egress);
+ if (removed) {
+ src.setIntent();
+ }
+ return removed;
+ }
+
+ /**
* Delete a multicast route from the MRIB.
*
* @param saddr source address * or x.x.x.x or x.x.x.x/y
diff --git a/framework/src/onos/apps/config/pom.xml b/framework/src/onos/apps/mlb/pom.xml
index 1b95c579..21692374 100644
--- a/framework/src/onos/apps/config/pom.xml
+++ b/framework/src/onos/apps/mlb/pom.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
- ~ Copyright 2014 Open Networking Laboratory
+ ~ Copyright 2015 Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
@@ -22,31 +22,23 @@
<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-config</artifactId>
+ <artifactId>onos-app-mlb</artifactId>
<packaging>bundle</packaging>
- <description>Network configuration application</description>
+ <description>Balances mastership among nodes</description>
<properties>
- <onos.app.name>org.onosproject.config</onos.app.name>
+ <onos.app.name>org.onosproject.mlb</onos.app.name>
</properties>
<dependencies>
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-misc</artifactId>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.compendium</artifactId>
</dependency>
</dependencies>
diff --git a/framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java b/framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
new file mode 100644
index 00000000..bcf4e2ef
--- /dev/null
+++ b/framework/src/onos/apps/mlb/src/main/java/org/onosproject/mlb/MastershipLoadBalancer.java
@@ -0,0 +1,165 @@
+/*
+ * 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.mlb;
+
+import com.google.common.util.concurrent.ListenableScheduledFuture;
+import com.google.common.util.concurrent.ListeningScheduledExecutorService;
+import com.google.common.util.concurrent.MoreExecutors;
+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.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.mastership.MastershipAdminService;
+import org.onosproject.mastership.MastershipEvent;
+import org.onosproject.mastership.MastershipListener;
+import org.onosproject.mastership.MastershipService;
+import org.slf4j.Logger;
+
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicReference;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+/**
+ * An app to perform automatic load balancing in response to events. Load balancing events are triggered by any
+ * change in mastership and are limited to a frequency of one every 30 seconds, all load balancing is run on an outside
+ * thread executor that must only have one thread due to issues that can occur is multiple balancing events occur in
+ * parallel.
+ */
+@Component(immediate = true)
+public class MastershipLoadBalancer {
+
+ private final Logger log = getLogger(getClass());
+
+ private static final String REBALANCE_MASTERSHIP = "rebalance/mastership";
+
+ private NodeId localId;
+
+ private AtomicBoolean isLeader = new AtomicBoolean(false);
+
+ private AtomicReference<Future> nextTask = new AtomicReference<>();
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipAdminService mastershipAdminService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LeadershipService leadershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
+ private InnerLeadershipListener leadershipListener = new InnerLeadershipListener();
+
+ /* This listener is used to trigger balancing for any mastership event which will include switches changing state
+ between active and inactive states as well as the same variety of event occurring with ONOS nodes. Must
+ use a listenable executor to ensure events are triggered with no frequency greater than once every 30 seconds.
+ */
+ private InnerMastershipListener mastershipListener = new InnerMastershipListener();
+
+ //Ensures that all executions do not interfere with one another (single thread)
+ private ListeningScheduledExecutorService executorService = MoreExecutors.
+ listeningDecorator(Executors.newSingleThreadScheduledExecutor());
+
+ @Activate
+ public void activate() {
+ mastershipService.addListener(mastershipListener);
+ localId = clusterService.getLocalNode().id();
+ leadershipService.addListener(leadershipListener);
+ leadershipService.runForLeadership(REBALANCE_MASTERSHIP);
+ log.info("Started");
+ }
+
+ @Deactivate
+ public void deactivate() {
+ mastershipService.removeListener(mastershipListener);
+ leadershipService.withdraw(REBALANCE_MASTERSHIP);
+ leadershipService.removeListener(leadershipListener);
+ cancelBalance();
+ executorService.shutdown();
+ log.info("Stopped");
+ }
+
+ private synchronized void processLeadershipChange(NodeId newLeader) {
+ if (newLeader == null) {
+ return;
+ }
+ boolean currLeader = newLeader.equals(localId);
+ if (isLeader.getAndSet(currLeader) != currLeader) {
+ if (currLeader) {
+ scheduleBalance();
+ } else {
+ cancelBalance();
+ }
+ }
+ }
+
+ private void scheduleBalance() {
+ if (isLeader.get() && nextTask.get() == null) {
+
+ ListenableScheduledFuture task = executorService.schedule(mastershipAdminService::balanceRoles, 30,
+ TimeUnit.SECONDS);
+ task.addListener(() -> {
+ log.info("Completed balance roles");
+ nextTask.set(null);
+ }, MoreExecutors.directExecutor()
+ );
+ if (!nextTask.compareAndSet(null, task)) {
+ task.cancel(false);
+ }
+ }
+ }
+
+ private void cancelBalance() {
+ Future task = nextTask.getAndSet(null);
+ if (task != null) {
+ task.cancel(false);
+ }
+ }
+
+ private class InnerMastershipListener implements MastershipListener {
+
+ @Override
+ public void event(MastershipEvent event) {
+ //Sets flag at execution to indicate there is currently a scheduled rebalancing, reverts upon completion
+ scheduleBalance();
+ }
+ }
+
+ private class InnerLeadershipListener implements LeadershipEventListener {
+ @Override
+ public boolean isRelevant(LeadershipEvent event) {
+ return REBALANCE_MASTERSHIP.equals(event.subject().topic());
+ }
+
+ @Override
+ public void event(LeadershipEvent event) {
+ processLeadershipChange(event.subject().leader());
+ }
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/apps/pom.xml b/framework/src/onos/apps/pom.xml
index b955130a..98210736 100644
--- a/framework/src/onos/apps/pom.xml
+++ b/framework/src/onos/apps/pom.xml
@@ -59,6 +59,7 @@
<module>mfwd</module>
<module>igmp</module>
<module>pim</module>
+ <module>mlb</module>
</modules>
<properties>
diff --git a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java b/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java
deleted file mode 100644
index 78eecb86..00000000
--- a/framework/src/onos/apps/routing/src/main/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptor.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * 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.routing.config.impl;
-
-import com.google.common.collect.Sets;
-import org.onlab.packet.IpAddress;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-import org.onosproject.routing.config.Interface;
-
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
-/**
- * Adapts PortAddresses data from the HostService into Interface data used by
- * the routing module.
- */
-public class HostToInterfaceAdaptor {
-
- private final HostService hostService;
-
- public HostToInterfaceAdaptor(HostService hostService) {
- this.hostService = checkNotNull(hostService);
- }
-
- public Set<Interface> getInterfaces() {
- Set<PortAddresses> addresses = hostService.getAddressBindings();
- Set<Interface> interfaces = Sets.newHashSetWithExpectedSize(addresses.size());
- for (PortAddresses a : addresses) {
- interfaces.add(new Interface(a));
- }
- return interfaces;
- }
-
- public Interface getInterface(ConnectPoint connectPoint) {
- checkNotNull(connectPoint);
-
- Set<PortAddresses> portAddresses =
- hostService.getAddressBindingsForPort(connectPoint);
-
- for (PortAddresses addresses : portAddresses) {
- if (addresses.connectPoint().equals(connectPoint)) {
- return new Interface(addresses);
- }
- }
-
- return null;
- }
-
- public Interface getInterface(IpAddress ip) {
- Set<PortAddresses> portAddresses = hostService.getAddressBindings();
-
- for (PortAddresses portAddress : portAddresses) {
- for (InterfaceIpAddress portIp : portAddress.ipAddresses()) {
- if (portIp.ipAddress().equals(ip)) {
- return new Interface(portAddress);
- }
- }
- }
-
- return null;
- }
-
- public Interface getMatchingInterface(IpAddress ipAddress) {
- checkNotNull(ipAddress);
-
- for (PortAddresses portAddresses : hostService.getAddressBindings()) {
- for (InterfaceIpAddress ia : portAddresses.ipAddresses()) {
- if (ia.subnetAddress().contains(ipAddress)) {
- return new Interface(portAddresses);
- }
- }
- }
-
- return null;
- }
-
-}
diff --git a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java b/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java
deleted file mode 100644
index 0347fc5f..00000000
--- a/framework/src/onos/apps/routing/src/test/java/org/onosproject/routing/config/impl/HostToInterfaceAdaptorTest.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * 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.routing.config.impl;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import org.junit.Before;
-import org.junit.Test;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onlab.packet.VlanId;
-import org.onosproject.net.ConnectPoint;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.host.HostService;
-import org.onosproject.net.host.InterfaceIpAddress;
-import org.onosproject.net.host.PortAddresses;
-import org.onosproject.routing.config.Interface;
-
-import java.util.Collections;
-import java.util.Map;
-import java.util.Set;
-
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Unit tests for the HostToInterfaceAdaptor class.
- */
-public class HostToInterfaceAdaptorTest {
-
- private HostService hostService;
- private HostToInterfaceAdaptor adaptor;
-
- private Set<PortAddresses> portAddresses;
- private Map<ConnectPoint, Interface> interfaces;
-
- private static final ConnectPoint CP1 = new ConnectPoint(
- DeviceId.deviceId("of:1"), PortNumber.portNumber(1));
- private static final ConnectPoint CP2 = new ConnectPoint(
- DeviceId.deviceId("of:1"), PortNumber.portNumber(2));
- private static final ConnectPoint CP3 = new ConnectPoint(
- DeviceId.deviceId("of:2"), PortNumber.portNumber(1));
-
- private static final ConnectPoint NON_EXISTENT_CP = new ConnectPoint(
- DeviceId.deviceId("doesnotexist"), PortNumber.portNumber(1));
-
- @Before
- public void setUp() throws Exception {
- hostService = createMock(HostService.class);
-
- portAddresses = Sets.newHashSet();
- interfaces = Maps.newHashMap();
-
- InterfaceIpAddress ia11 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.1.1"),
- IpPrefix.valueOf("192.168.1.0/24"));
- createPortAddressesAndInterface(CP1,
- Sets.newHashSet(ia11),
- MacAddress.valueOf("00:00:00:00:00:01"),
- VlanId.NONE);
-
- // Two addresses in the same subnet
- InterfaceIpAddress ia21 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.2.1"),
- IpPrefix.valueOf("192.168.2.0/24"));
- InterfaceIpAddress ia22 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.2.2"),
- IpPrefix.valueOf("192.168.2.0/24"));
- createPortAddressesAndInterface(CP2,
- Sets.newHashSet(ia21, ia22),
- MacAddress.valueOf("00:00:00:00:00:02"),
- VlanId.vlanId((short) 4));
-
- // Two addresses in different subnets
- InterfaceIpAddress ia31 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.3.1"),
- IpPrefix.valueOf("192.168.3.0/24"));
- InterfaceIpAddress ia41 =
- new InterfaceIpAddress(IpAddress.valueOf("192.168.4.1"),
- IpPrefix.valueOf("192.168.4.0/24"));
- createPortAddressesAndInterface(CP3,
- Sets.newHashSet(ia31, ia41),
- MacAddress.valueOf("00:00:00:00:00:03"),
- VlanId.NONE);
-
- expect(hostService.getAddressBindings()).andReturn(portAddresses).anyTimes();
-
- replay(hostService);
-
- adaptor = new HostToInterfaceAdaptor(hostService);
- }
-
- /**
- * Creates both a PortAddresses and an Interface for the given inputs and
- * places them in the correct global data stores.
- *
- * @param cp the connect point
- * @param ipAddresses the set of interface IP addresses
- * @param mac the MAC address
- * @param vlan the VLAN ID
- */
- private void createPortAddressesAndInterface(
- ConnectPoint cp, Set<InterfaceIpAddress> ipAddresses,
- MacAddress mac, VlanId vlan) {
- PortAddresses pa = new PortAddresses(cp, ipAddresses, mac, vlan);
- portAddresses.add(pa);
- expect(hostService.getAddressBindingsForPort(cp)).andReturn(
- Collections.singleton(pa)).anyTimes();
-
- Interface intf = new Interface(cp, ipAddresses, mac, vlan);
- interfaces.put(cp, intf);
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getInterfaces()}.
- * Verifies that the set of interfaces returned matches what is expected
- * based on the input PortAddresses data.
- */
- @Test
- public void testGetInterfaces() {
- Set<Interface> adaptorIntfs = adaptor.getInterfaces();
-
- assertEquals(3, adaptorIntfs.size());
- assertTrue(adaptorIntfs.contains(this.interfaces.get(CP1)));
- assertTrue(adaptorIntfs.contains(this.interfaces.get(CP2)));
- assertTrue(adaptorIntfs.contains(this.interfaces.get(CP3)));
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)}.
- * Verifies that the correct interface is returned for a given connect
- * point.
- */
- @Test
- public void testGetInterface() {
- assertEquals(this.interfaces.get(CP1), adaptor.getInterface(CP1));
- assertEquals(this.interfaces.get(CP2), adaptor.getInterface(CP2));
- assertEquals(this.interfaces.get(CP3), adaptor.getInterface(CP3));
-
- // Try and get an interface for a connect point with no addresses
- reset(hostService);
- expect(hostService.getAddressBindingsForPort(NON_EXISTENT_CP))
- .andReturn(Collections.<PortAddresses>emptySet()).anyTimes();
- replay(hostService);
-
- assertNull(adaptor.getInterface(NON_EXISTENT_CP));
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getInterface(ConnectPoint)} in the
- * case that the input connect point is null.
- * Verifies that a NullPointerException is thrown.
- */
- @Test(expected = NullPointerException.class)
- public void testGetInterfaceNull() {
- ConnectPoint c = null;
- adaptor.getInterface(c);
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)}.
- * Verifies that the correct interface is returned based on the given IP
- * address.
- */
- @Test
- public void testGetMatchingInterface() {
- assertEquals(this.interfaces.get(CP1),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.1.100")));
- assertEquals(this.interfaces.get(CP2),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.2.100")));
- assertEquals(this.interfaces.get(CP3),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.3.100")));
- assertEquals(this.interfaces.get(CP3),
- adaptor.getMatchingInterface(IpAddress.valueOf("192.168.4.100")));
-
- // Try and match an address we don't have subnet configured for
- assertNull(adaptor.getMatchingInterface(IpAddress.valueOf("1.1.1.1")));
- }
-
- /**
- * Tests {@link HostToInterfaceAdaptor#getMatchingInterface(IpAddress)} in the
- * case that the input IP address is null.
- * Verifies that a NullPointerException is thrown.
- */
- @Test(expected = NullPointerException.class)
- public void testGetMatchingInterfaceNull() {
- adaptor.getMatchingInterface(null);
- }
-
-}
diff --git a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java b/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java
deleted file mode 100644
index d26d3060..00000000
--- a/framework/src/onos/apps/sdnip/src/main/java/org/onosproject/sdnip/SdnIpService.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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.sdnip;
-
-/**
- * Service interface exported by SDN-IP.
- */
-public interface SdnIpService {
-
- /**
- * Changes whether this SDN-IP instance is the primary or not based on the
- * boolean parameter.
- *
- * @param isPrimary true if the instance is primary, false if it is not
- */
- void modifyPrimary(boolean isPrimary);
-
-}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java
index 6ca6d193..f42f84b1 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/ArpHandler.java
@@ -88,7 +88,6 @@ public class ArpHandler {
}
private void handleArpRequest(DeviceId deviceId, ConnectPoint inPort, Ethernet payload) {
-
ARP arpRequest = (ARP) payload.getPayload();
HostId targetHostId = HostId.hostId(MacAddress.valueOf(
arpRequest.getTargetHardwareAddress()));
@@ -98,14 +97,16 @@ public class ArpHandler {
Ip4Address targetAddress = Ip4Address.valueOf(arpRequest.getTargetProtocolAddress());
sendArpResponse(arpRequest, config.getRouterMacForAGatewayIp(targetAddress));
- // ARP request for known hosts
- } else if (srManager.hostService.getHost(targetHostId) != null) {
- MacAddress targetMac = srManager.hostService.getHost(targetHostId).mac();
- sendArpResponse(arpRequest, targetMac);
-
- // ARP request for unknown host in the subnet
- } else if (isArpReqForSubnet(deviceId, arpRequest)) {
- flood(payload, inPort);
+ } else {
+ Host targetHost = srManager.hostService.getHost(targetHostId);
+ // ARP request for known hosts
+ if (targetHost != null) {
+ sendArpResponse(arpRequest, targetHost.mac());
+
+ // ARP request for unknown host in the subnet
+ } else if (isArpReqForSubnet(deviceId, arpRequest)) {
+ flood(payload, inPort);
+ }
}
}
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 8fdf81a2..eef1b147 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
@@ -62,11 +62,18 @@ public class DeviceConfiguration implements DeviceProperties {
HashMap<PortNumber, Ip4Address> gatewayIps;
HashMap<PortNumber, Ip4Prefix> subnets;
List<AdjacencySid> adjacencySids;
+
+ public SegmentRouterInfo() {
+ this.gatewayIps = new HashMap<>();
+ this.subnets = new HashMap<>();
+ }
}
/**
* Constructor. Reads all the configuration for all devices of type
* Segment Router and organizes into various maps for easier access.
+ *
+ * @param cfgService config service
*/
public DeviceConfiguration(NetworkConfigRegistry cfgService) {
// Read config from device subject, excluding gatewayIps and subnets.
@@ -82,8 +89,6 @@ public class DeviceConfiguration implements DeviceProperties {
info.mac = config.getMac();
info.isEdge = config.isEdgeRouter();
info.adjacencySids = config.getAdjacencySids();
- info.gatewayIps = new HashMap<>();
- info.subnets = new HashMap<>();
this.deviceConfigMap.put(info.deviceId, info);
this.allSegmentIds.add(info.nodeSid);
@@ -107,11 +112,14 @@ public class DeviceConfiguration implements DeviceProperties {
PortNumber port = networkInterface.connectPoint().port();
SegmentRouterInfo info = this.deviceConfigMap.get(dpid);
- Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses();
- interfaceAddresses.forEach(interfaceAddress -> {
- info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address());
- info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix());
- });
+ // skip if there is no corresponding device for this ConenctPoint
+ if (info != null) {
+ Set<InterfaceIpAddress> interfaceAddresses = networkInterface.ipAddresses();
+ interfaceAddresses.forEach(interfaceAddress -> {
+ info.gatewayIps.put(port, interfaceAddress.ipAddress().getIp4Address());
+ info.subnets.put(port, interfaceAddress.subnetAddress().getIp4Prefix());
+ });
+ }
});
});
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java
deleted file mode 100644
index d3468178..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/NetworkConfigHandler.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting;
-
-import com.google.common.collect.Lists;
-
-import org.onlab.packet.Ip4Address;
-import org.onlab.packet.Ip4Prefix;
-import org.onlab.packet.IpPrefix;
-import org.onlab.packet.MacAddress;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.net.PortNumber;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * This class is temporary class and used only for test.
- * It will be replaced with "real" Network Config Manager.
- *
- * TODO: Knock off this wrapper and directly use DeviceConfiguration class
- */
-
-public class NetworkConfigHandler {
-
- private static Logger log = LoggerFactory.getLogger(NetworkConfigHandler.class);
- private SegmentRoutingManager srManager;
- private DeviceConfiguration deviceConfig;
-
- public NetworkConfigHandler(SegmentRoutingManager srManager,
- DeviceConfiguration deviceConfig) {
- this.srManager = srManager;
- this.deviceConfig = deviceConfig;
- }
-
- public List<Ip4Address> getGatewayIpAddress(DeviceId deviceId) {
- return this.deviceConfig.getSubnetGatewayIps(deviceId);
- }
-
- public IpPrefix getRouterIpAddress(DeviceId deviceId) {
- return IpPrefix.valueOf(deviceConfig.getRouterIp(deviceId), 32);
- }
-
- public MacAddress getRouterMacAddress(DeviceId deviceId) {
- return deviceConfig.getDeviceMac(deviceId);
- }
-
- public boolean inSameSubnet(DeviceId deviceId, Ip4Address destIp) {
-
- List<Ip4Prefix> subnets = getSubnetInfo(deviceId);
- if (subnets == null) {
- return false;
- }
-
- return subnets.stream()
- .anyMatch((subnet) -> subnet.contains(destIp));
- }
-
- public boolean inSameSubnet(Ip4Address address, int sid) {
- DeviceId deviceId = deviceConfig.getDeviceId(sid);
- if (deviceId == null) {
- log.warn("Cannot find a device for SID {}", sid);
- return false;
- }
-
- return inSameSubnet(deviceId, address);
- }
-
- public List<Ip4Prefix> getSubnetInfo(DeviceId deviceId) {
- return deviceConfig.getSubnets(deviceId);
- }
-
- public int getMplsId(DeviceId deviceId) {
- return deviceConfig.getSegmentId(deviceId);
- }
-
- public int getMplsId(MacAddress routerMac) {
- return deviceConfig.getSegmentId(routerMac);
- }
-
- public int getMplsId(Ip4Address routerIpAddress) {
- return deviceConfig.getSegmentId(routerIpAddress);
- }
-
- public boolean isEcmpNotSupportedInTransit(DeviceId deviceId) {
- //TODO: temporarily changing to true to test with Dell
- return true;
- }
-
- public boolean isTransitRouter(DeviceId deviceId) {
- return !(deviceConfig.isEdgeDevice(deviceId));
- }
-
-
- public boolean isEdgeRouter(DeviceId deviceId) {
- return deviceConfig.isEdgeDevice(deviceId);
- }
-
- private List<PortNumber> getPortsToNeighbors(DeviceId deviceId, List<DeviceId> fwdSws) {
-
- List<PortNumber> portNumbers = Lists.newArrayList();
-
- Set<Link> links = srManager.linkService.getDeviceEgressLinks(deviceId);
- for (Link link: links) {
- for (DeviceId swId: fwdSws) {
- if (link.dst().deviceId().equals(swId)) {
- portNumbers.add(link.src().port());
- break;
- }
- }
- }
-
- return portNumbers;
- }
-
- public List<PortNumber> getPortsToDevice(DeviceId deviceId) {
- List<PortNumber> portNumbers = Lists.newArrayList();
-
- Set<Link> links = srManager.linkService.getDeviceEgressLinks(deviceId);
- for (Link link: links) {
- if (link.dst().deviceId().equals(deviceId)) {
- portNumbers.add(link.src().port());
- }
- }
-
- return portNumbers;
- }
-
-
- public Ip4Address getDestinationRouterAddress(Ip4Address destIpAddress) {
- return deviceConfig.getRouterIpAddressForASubnetHost(destIpAddress);
- }
-
- public DeviceId getDeviceId(Ip4Address ip4Address) {
- return deviceConfig.getDeviceId(ip4Address);
- }
-
- public MacAddress getRouterMac(Ip4Address targetAddress) {
- return deviceConfig.getRouterMacForAGatewayIp(targetAddress);
- }
-}
diff --git a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
index 05663129..9011160c 100644
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
+++ b/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/SegmentRoutingManager.java
@@ -116,11 +116,12 @@ public class SegmentRoutingManager implements SegmentRoutingService {
protected ApplicationId appId;
protected DeviceConfiguration deviceConfiguration = null;
-
private DefaultRoutingHandler defaultRoutingHandler = null;
private TunnelHandler tunnelHandler = null;
private PolicyHandler policyHandler = null;
- private InternalPacketProcessor processor = new InternalPacketProcessor();
+ private InternalPacketProcessor processor = null;
+ private InternalLinkListener linkListener = null;
+ private InternalDeviceListener deviceListener = null;
private InternalEventHandler eventHandler = new InternalEventHandler();
private ScheduledExecutorService executorService = Executors
@@ -214,6 +215,16 @@ public class SegmentRoutingManager implements SegmentRoutingService {
cfgService.addListener(cfgListener);
cfgService.registerConfigFactory(cfgFactory);
+ processor = new InternalPacketProcessor();
+ linkListener = new InternalLinkListener();
+ deviceListener = new InternalDeviceListener();
+
+ packetService.addProcessor(processor, PacketProcessor.director(2));
+ linkService.addListener(linkListener);
+ deviceService.addListener(deviceListener);
+
+ cfgListener.configureNetwork();
+
log.info("Started");
}
@@ -223,7 +234,14 @@ public class SegmentRoutingManager implements SegmentRoutingService {
cfgService.unregisterConfigFactory(cfgFactory);
packetService.removeProcessor(processor);
+ linkService.removeListener(linkListener);
+ deviceService.removeListener(deviceListener);
processor = null;
+ linkListener = null;
+ deviceService = null;
+
+ groupHandlerMap.clear();
+
log.info("Stopped");
}
@@ -284,7 +302,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
* @return GroupKey object for the NeighborSet
*/
public GroupKey getGroupKey(NeighborSet ns) {
-
for (DefaultGroupHandler groupHandler : groupHandlerMap.values()) {
return groupHandler.getGroupKey(ns);
}
@@ -301,7 +318,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
* @return next objective ID
*/
public int getNextObjectiveId(DeviceId deviceId, NeighborSet ns) {
-
if (groupHandlerMap.get(deviceId) != null) {
log.trace("getNextObjectiveId query in device {}", deviceId);
return groupHandlerMap
@@ -313,7 +329,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private class InternalPacketProcessor implements PacketProcessor {
-
@Override
public void process(PacketContext context) {
@@ -350,16 +365,8 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private class InternalDeviceListener implements DeviceListener {
-
@Override
public void event(DeviceEvent event) {
- /*if (mastershipService.getLocalRole(event.subject().id()) != MastershipRole.MASTER) {
- log.debug("Local role {} is not MASTER for device {}",
- mastershipService.getLocalRole(event.subject().id()),
- event.subject().id());
- return;
- }*/
-
switch (event.type()) {
case DEVICE_ADDED:
case PORT_REMOVED:
@@ -374,7 +381,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private void scheduleEventHandlerIfNotScheduled(Event event) {
-
synchronized (threadSchedulerLock) {
eventQueue.add(event);
numOfEventsQueued++;
@@ -392,7 +398,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
}
private class InternalEventHandler implements Runnable {
-
@Override
public void run() {
try {
@@ -413,8 +418,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
processLinkAdded((Link) event.subject());
} else if (event.type() == LinkEvent.Type.LINK_REMOVED) {
processLinkRemoved((Link) event.subject());
- //} else if (event.type() == GroupEvent.Type.GROUP_ADDED) {
- // processGroupAdded((Group) event.subject());
} else if (event.type() == DeviceEvent.Type.DEVICE_ADDED ||
event.type() == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
event.type() == DeviceEvent.Type.DEVICE_UPDATED) {
@@ -526,10 +529,6 @@ public class SegmentRoutingManager implements SegmentRoutingService {
flowObjectiveService,
tunnelHandler, policyStore);
- packetService.addProcessor(processor, PacketProcessor.director(2));
- linkService.addListener(new InternalLinkListener());
- deviceService.addListener(new InternalDeviceListener());
-
for (Device device : deviceService.getDevices()) {
//Irrespective whether the local is a MASTER or not for this device,
//create group handler instance and push default TTP flow rules.
@@ -550,12 +549,15 @@ public class SegmentRoutingManager implements SegmentRoutingService {
@Override
public void event(NetworkConfigEvent event) {
- if ((event.type() == NetworkConfigEvent.Type.CONFIG_ADDED ||
- event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) &&
- event.configClass().equals(SegmentRoutingConfig.class)) {
- log.info("Network configuration change detected. (Re)Configuring...");
- configureNetwork();
- return;
+ if (event.configClass().equals(SegmentRoutingConfig.class)) {
+ if (event.type() == NetworkConfigEvent.Type.CONFIG_ADDED) {
+ log.info("Network configuration added.");
+ configureNetwork();
+ }
+ if (event.type() == NetworkConfigEvent.Type.CONFIG_UPDATED) {
+ log.info("Network configuration updated.");
+ // TODO support dynamic configuration
+ }
}
}
}
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
deleted file mode 100644
index 0c7749e6..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfig.java
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-import org.onosproject.net.DeviceId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Public class corresponding to JSON described data model. Defines the network
- * configuration at startup.
- */
-public class NetworkConfig {
- protected static final Logger log = LoggerFactory.getLogger(NetworkConfig.class);
-
- @SuppressWarnings("unused")
- private String comment;
-
- private Boolean restrictSwitches;
- private Boolean restrictLinks;
- private List<SwitchConfig> switches;
- private List<LinkConfig> links;
-
- /**
- * Default constructor.
- */
- public NetworkConfig() {
- switches = new ArrayList<>();
- links = new ArrayList<>();
- }
-
- @JsonProperty("comment")
- public void setComment(String c) {
- log.trace("NetworkConfig: comment={}", c);
- comment = c;
- }
-
- @JsonProperty("restrictSwitches")
- public void setRestrictSwitches(boolean rs) {
- log.trace("NetworkConfig: restrictSwitches={}", rs);
- restrictSwitches = rs;
- }
-
- /**
- * Returns default restrict configuration for switches.
- *
- * @return boolean
- */
- public Boolean getRestrictSwitches() {
- return restrictSwitches;
- }
-
- @JsonProperty("restrictLinks")
- public void setRestrictLinks(boolean rl) {
- log.trace("NetworkConfig: restrictLinks={}", rl);
- restrictLinks = rl;
- }
-
- /**
- * Returns default restrict configuration for links.
- *
- * @return boolean
- */
- public Boolean getRestrictLinks() {
- return restrictLinks;
- }
-
- /**
- * Returns configuration for switches.
- *
- * @return list of switch configuration
- */
- public List<SwitchConfig> getSwitchConfig() {
- return switches;
- }
-
- @JsonProperty("switchConfig")
- public void setSwitchConfig(List<SwitchConfig> switches2) {
- log.trace("NetworkConfig: switchConfig={}", switches2);
- this.switches = switches2;
- }
-
- /**
- * Java class corresponding to JSON described switch
- * configuration data model.
- */
- public static class SwitchConfig {
- protected String nodeDpid;
- protected String name;
- protected String type;
- protected boolean allowed;
- protected double latitude;
- protected double longitude;
- protected Map<String, JsonNode> params;
- protected Map<String, String> publishAttributes;
- protected DeviceId dpid;
-
- /**
- * Returns the configured "name" of a switch.
- *
- * @return string
- */
- public String getName() {
- return name;
- }
-
- @JsonProperty("name")
- public void setName(String name) {
- log.trace("SwitchConfig: name={}", name);
- this.name = name;
- }
-
- /**
- * Returns the data plane identifier of a switch.
- *
- * @return ONOS device identifier
- */
- public DeviceId getDpid() {
- return dpid;
- }
-
- public void setDpid(DeviceId dpid) {
- this.dpid = dpid;
- this.nodeDpid = dpid.toString();
- }
-
- /**
- * Returns the data plane identifier of a switch.
- *
- * @return string
- */
- public String getNodeDpid() {
- return nodeDpid;
- }
-
- // mapper sets both DeviceId and string fields for dpid
- @JsonProperty("nodeDpid")
- public void setNodeDpid(String nodeDpid) {
- log.trace("SwitchConfig: nodeDpid={}", nodeDpid);
- this.nodeDpid = nodeDpid;
- this.dpid = DeviceId.deviceId(nodeDpid);
- }
-
- /**
- * Returns the type of a switch.
- *
- * @return string
- */
- public String getType() {
- return type;
- }
-
- @JsonProperty("type")
- public void setType(String type) {
- log.trace("SwitchConfig: type={}", type);
- this.type = type;
- }
-
- /**
- * Returns the latitude of a switch.
- *
- * @return double
- */
- public double getLatitude() {
- return latitude;
- }
-
- @JsonProperty("latitude")
- public void setLatitude(double latitude) {
- log.trace("SwitchConfig: latitude={}", latitude);
- this.latitude = latitude;
- }
-
- /**
- * Returns the longitude of a switch.
- *
- * @return double
- */
- public double getLongitude() {
- return longitude;
- }
-
- @JsonProperty("longitude")
- public void setLongitude(double longitude) {
- log.trace("SwitchConfig: longitude={}", longitude);
- this.longitude = longitude;
- }
-
- /**
- * Returns the allowed flag for a switch.
- *
- * @return boolean
- */
- public boolean isAllowed() {
- return allowed;
- }
-
- @JsonProperty("allowed")
- public void setAllowed(boolean allowed) {
- this.allowed = allowed;
- }
-
- /**
- * Returns the additional configured parameters of a switch.
- *
- * @return key value map
- */
- public Map<String, JsonNode> getParams() {
- return params;
- }
-
- @JsonProperty("params")
- public void setParams(Map<String, JsonNode> params) {
- this.params = params;
- }
-
- /**
- * Reserved for future use.
- *
- * @return key value map
- */
- public Map<String, String> getPublishAttributes() {
- return publishAttributes;
- }
-
- @JsonProperty("publishAttributes")
- public void setPublishAttributes(Map<String, String> publishAttributes) {
- this.publishAttributes = publishAttributes;
- }
-
- }
-
- @JsonProperty("linkConfig")
- public void setLinkConfig(List<LinkConfig> links2) {
- this.links = links2;
- }
-
- /**
- * Reserved for future use.
- *
- * @return list of configured link configuration
- */
- public List<LinkConfig> getLinkConfig() {
- return links;
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkConfig {
- protected String type;
- protected Boolean allowed;
- protected DeviceId dpid1;
- protected DeviceId dpid2;
- protected String nodeDpid1;
- protected String nodeDpid2;
- protected Map<String, JsonNode> params;
- protected Map<String, String> publishAttributes;
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public Boolean isAllowed() {
- return allowed;
- }
-
- public void setAllowed(Boolean allowed) {
- this.allowed = allowed;
- }
-
- public String getNodeDpid1() {
- return nodeDpid1;
- }
-
- // mapper sets both long and string fields for dpid
- public void setNodeDpid1(String nodeDpid1) {
- this.nodeDpid1 = nodeDpid1;
- this.dpid1 = DeviceId.deviceId(nodeDpid1);
- }
-
- public String getNodeDpid2() {
- return nodeDpid2;
- }
-
- // mapper sets both long and string fields for dpid
- public void setNodeDpid2(String nodeDpid2) {
- this.nodeDpid2 = nodeDpid2;
- this.dpid2 = DeviceId.deviceId(nodeDpid2);
- }
-
- public DeviceId getDpid1() {
- return dpid1;
- }
-
- public void setDpid1(DeviceId dpid1) {
- this.dpid1 = dpid1;
- this.nodeDpid1 = dpid1.toString();
- }
-
- public DeviceId getDpid2() {
- return dpid2;
- }
-
- public void setDpid2(DeviceId dpid2) {
- this.dpid2 = dpid2;
- this.nodeDpid2 = dpid2.toString();
- }
-
- public Map<String, JsonNode> getParams() {
- return params;
- }
-
- public void setParams(Map<String, JsonNode> params) {
- this.params = params;
- }
-
- public Map<String, String> getPublishAttributes() {
- return publishAttributes;
- }
-
- public void setPublishAttributes(Map<String, String> publishAttributes) {
- this.publishAttributes = publishAttributes;
- }
- }
-}
-
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
deleted file mode 100644
index 0c0dac86..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigException.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import org.onosproject.net.DeviceId;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * NetworkConfigExceptions specifies a set of unchecked runtime exceptions that
- * can be thrown by the {@link NetworkConfigManager}. It indicates errors that
- * must be fixed in the config file before controller execution can proceed.
- */
-public class NetworkConfigException extends RuntimeException {
-
- private static final long serialVersionUID = 4959684709803000652L;
- protected static final Logger log = LoggerFactory
- .getLogger(NetworkConfigException.class);
-
- /**
- * Exception for duplicate device identifier configuration.
- */
- public static class DuplicateDpid extends RuntimeException {
- private static final long serialVersionUID = 5491113234592145335L;
-
- public DuplicateDpid(DeviceId dpid) {
- super();
- log.error("Duplicate dpid found in switch-config Dpid:{}",
- dpid);
- }
- }
-
- /**
- * Exception for duplicate device name configuration.
- */
- public static class DuplicateName extends RuntimeException {
- private static final long serialVersionUID = -4090171438031376129L;
-
- public DuplicateName(String name) {
- super();
- log.error("Duplicate name found in switch-config name:{}", name);
- }
- }
-
- /**
- * Exception for unspecified device identifier for a switch.
- */
- public static class DpidNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -8494418855597117254L;
-
- public DpidNotSpecified(String name) {
- super();
- log.error("Dpid not specified for switch-config name:{}", name);
- }
- }
-
- /**
- * Exception for unspecified device name for a switch.
- */
- public static class NameNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -3518881744110422891L;
-
- public NameNotSpecified(DeviceId dpid) {
- super();
- log.error("Name not specified for switch-config dpid:{}",
- dpid);
- }
- }
-
- /**
- * Exception for unspecified device type for a switch.
- */
- public static class SwitchTypeNotSpecified extends RuntimeException {
- private static final long serialVersionUID = 2527453336226053753L;
-
- public SwitchTypeNotSpecified(DeviceId dpid) {
- super();
- log.error("Switch type not specified for switch-config dpid:{}",
- dpid);
- }
- }
-
- /**
- * Exception for unknown device type configured for a switch.
- */
- public static class UnknownSwitchType extends RuntimeException {
- private static final long serialVersionUID = 7758418165512249170L;
-
- public UnknownSwitchType(String type, String name) {
- super();
- log.error("Unknown switch type {} for switch name:{}", type, name);
- }
- }
-
- /**
- * Exception for missing required parameter configuration for a switch.
- */
- public static class ParamsNotSpecified extends RuntimeException {
- private static final long serialVersionUID = 6247582323691265513L;
-
- public ParamsNotSpecified(String name) {
- super();
- log.error("Params required - not specified for switch:{}", name);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkTypeNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -2089470389588542215L;
-
- public LinkTypeNotSpecified(String dpid1, String dpid2) {
- super();
- log.error("Link type not specified for link-config between "
- + "dpid1:{} and dpid2:{}", dpid1, dpid2);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkDpidNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -5701825916378616004L;
-
- public LinkDpidNotSpecified(String dpid1, String dpid2) {
- super();
- if (dpid1 == null) {
- log.error("nodeDpid1 not specified for link-config ");
- }
- if (dpid2 == null) {
- log.error("nodeDpid2 not specified for link-config ");
- }
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkForUnknownSwitchConfig extends RuntimeException {
- private static final long serialVersionUID = -2910458439881964094L;
-
- public LinkForUnknownSwitchConfig(String dpid) {
- super();
- log.error("Link configuration was specified for a switch-dpid {} "
- + "that has not been configured", dpid);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class UnknownLinkType extends RuntimeException {
- private static final long serialVersionUID = -5505376193106542305L;
-
- public UnknownLinkType(String linktype, String dpid1, String dpid2) {
- super();
- log.error("unknown link type {} for links between dpid1:{} "
- + "and dpid2:{}", linktype, dpid1, dpid2);
- }
- }
-
- /**
- * Exception for generic configuration errors.
- */
- public static class ErrorConfig extends RuntimeException {
- private static final long serialVersionUID = -2827406314700193147L;
-
- public ErrorConfig(String errorMsg) {
- super();
- log.error(errorMsg);
- }
-
- }
-
- /**
- * Reserved for future use.
- */
- public static class SwitchDpidNotConverted extends RuntimeException {
- private static final long serialVersionUID = 5640347104590170426L;
-
- public SwitchDpidNotConverted(String name) {
- super();
- log.error("Switch dpid specified as a HexString {} does not match "
- + "with long value", name);
- }
- }
-
- /**
- * Reserved for future use.
- */
- public static class LinkDpidNotConverted extends RuntimeException {
- private static final long serialVersionUID = 2397245646094080774L;
-
- public LinkDpidNotConverted(String dpid1, String dpid2) {
- log.error("Dpids expressed as HexStrings for links between dpid1:{} "
- + "and dpid2:{} do not match with long values", dpid1, dpid2);
- }
- }
-
-}
-
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
deleted file mode 100644
index f034f372..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigManager.java
+++ /dev/null
@@ -1,338 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
-import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * NetworkConfigManager manages all network configuration for switches, links
- * and any other state that needs to be configured for correct network
- * operation.
- *
- */
-public class NetworkConfigManager implements NetworkConfigService {
- protected static final Logger log = LoggerFactory
- .getLogger(NetworkConfigManager.class);
- private static final String CONFIG_DIR = "../config";
- private static final String DEFAULT_CONFIG_FILE = "segmentrouting.conf";
- private final String configFileName = DEFAULT_CONFIG_FILE;
- /**
- * JSON Config file needs to use one of the following types for defining the
- * kind of switch or link it wishes to configure.
- */
- public static final String SEGMENT_ROUTER = "Router_SR";
-
- public static final String PKT_LINK = "pktLink";
-
- NetworkConfig networkConfig;
- private ConcurrentMap<DeviceId, SwitchConfig> configuredSwitches;
- private ConcurrentMap<Link, LinkConfig> configuredLinks;
- private Map<String, DeviceId> nameToDpid;
-
- @Override
- public SwitchConfigStatus checkSwitchConfig(DeviceId dpid) {
- SwitchConfig swc = configuredSwitches.get(dpid);
- if (networkConfig.getRestrictSwitches()) {
- // default deny behavior
- if (swc == null) {
- // switch is not configured - we deny this switch
- return new SwitchConfigStatus(NetworkConfigState.DENY, null,
- "Switch not configured, in network denying switches by default.");
- }
- if (swc.isAllowed()) {
- // switch is allowed in config, return configured attributes
- return new SwitchConfigStatus(NetworkConfigState.ACCEPT_ADD, swc);
- } else {
- // switch has been configured off (administratively down)
- return new SwitchConfigStatus(NetworkConfigState.DENY, null,
- "Switch configured down (allowed=false).");
- }
- } else {
- // default allow behavior
- if (swc == null) {
- // no config to add
- return new SwitchConfigStatus(NetworkConfigState.ACCEPT, null);
- }
- if (swc.isAllowed()) {
- // switch is allowed in config, return configured attributes
- return new SwitchConfigStatus(NetworkConfigState.ACCEPT_ADD, swc);
- } else {
- // switch has been configured off (administratively down)
- return new SwitchConfigStatus(NetworkConfigState.DENY, null,
- "Switch configured down (allowed=false).");
- }
- }
-
- }
-
- @Override
- public LinkConfigStatus checkLinkConfig(Link linkTuple) {
- LinkConfig lkc = getConfiguredLink(linkTuple);
- // links are always disallowed if any one of the nodes that make up the
- // link are disallowed
- DeviceId linkNode1 = linkTuple.src().deviceId();
- SwitchConfigStatus scs1 = checkSwitchConfig(linkNode1);
- if (scs1.getConfigState() == NetworkConfigState.DENY) {
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link-node: " + linkNode1 + " denied by config: " + scs1.getMsg());
- }
- DeviceId linkNode2 = linkTuple.dst().deviceId();
- SwitchConfigStatus scs2 = checkSwitchConfig(linkNode2);
- if (scs2.getConfigState() == NetworkConfigState.DENY) {
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link-node: " + linkNode2 + " denied by config: " + scs2.getMsg());
- }
- if (networkConfig.getRestrictLinks()) {
- // default deny behavior
- if (lkc == null) {
- // link is not configured - we deny this link
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link not configured, in network denying links by default.");
- }
- if (lkc.isAllowed()) {
- // link is allowed in config, return configured attributes
- return new LinkConfigStatus(NetworkConfigState.ACCEPT_ADD, lkc);
- } else {
- // link has been configured off (administratively down)
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link configured down (allowed=false).");
- }
- } else {
- // default allow behavior
- if (lkc == null) {
- // no config to add
- return new LinkConfigStatus(NetworkConfigState.ACCEPT, null);
- }
- if (lkc.isAllowed()) {
- // link is allowed in config, return configured attributes
- return new LinkConfigStatus(NetworkConfigState.ACCEPT_ADD, lkc);
- } else {
- // link has been configured off (administratively down)
- return new LinkConfigStatus(NetworkConfigState.DENY, null,
- "Link configured down (allowed=false).");
- }
- }
-
- }
-
- @Override
- public List<SwitchConfig> getConfiguredAllowedSwitches() {
- List<SwitchConfig> allowed = new ArrayList<>();
- for (SwitchConfig swc : configuredSwitches.values()) {
- if (swc.isAllowed()) {
- allowed.add(swc);
- }
- }
- return allowed;
- }
-
- @Override
- public List<LinkConfig> getConfiguredAllowedLinks() {
- List<LinkConfig> allowed = new ArrayList<>();
- for (LinkConfig lkc : configuredLinks.values()) {
- if (lkc.isAllowed()) {
- allowed.add(lkc);
- }
- }
- return allowed;
- }
-
- @Override
- public DeviceId getDpidForName(String name) {
- if (nameToDpid.get(name) != null) {
- return nameToDpid.get(name);
- }
- return null;
- }
-
- // **************
- // Private methods
- // **************
-
- private void loadNetworkConfig() {
- File configFile = new File(CONFIG_DIR, configFileName);
- ObjectMapper mapper = new ObjectMapper();
- networkConfig = new NetworkConfig();
-
- try {
- networkConfig = mapper.readValue(configFile,
- NetworkConfig.class);
- } catch (JsonParseException e) {
- String err = String.format("JsonParseException while loading network "
- + "config from file: %s: %s", configFileName,
- e.getMessage());
- throw new NetworkConfigException.ErrorConfig(err);
- } catch (JsonMappingException e) {
- String err = String.format(
- "JsonMappingException while loading network config "
- + "from file: %s: %s",
- configFileName,
- e.getMessage());
- throw new NetworkConfigException.ErrorConfig(err);
- } catch (IOException e) {
- String err = String.format("IOException while loading network config "
- + "from file: %s %s", configFileName, e.getMessage());
- throw new NetworkConfigException.ErrorConfig(err);
- }
-
- log.info("Network config specifies: {} switches and {} links",
- (networkConfig.getRestrictSwitches())
- ? networkConfig.getSwitchConfig().size() : "default allow",
- (networkConfig.getRestrictLinks())
- ? networkConfig.getLinkConfig().size() : "default allow");
- }
-
- private void parseNetworkConfig() {
- List<SwitchConfig> swConfList = networkConfig.getSwitchConfig();
- List<LinkConfig> lkConfList = networkConfig.getLinkConfig();
- validateSwitchConfig(swConfList);
- createTypeSpecificSwitchConfig(swConfList);
- validateLinkConfig(lkConfList);
- createTypeSpecificLinkConfig(lkConfList);
- // TODO validate reachability matrix 'names' for configured dpids
- }
-
- private void createTypeSpecificSwitchConfig(List<SwitchConfig> swConfList) {
- for (SwitchConfig swc : swConfList) {
- nameToDpid.put(swc.getName(), swc.getDpid());
- String swtype = swc.getType();
- switch (swtype) {
- case SEGMENT_ROUTER:
- SwitchConfig sr = new SegmentRouterConfig(swc);
- configuredSwitches.put(sr.getDpid(), sr);
- break;
- default:
- throw new NetworkConfigException.UnknownSwitchType(swtype,
- swc.getName());
- }
- }
- }
-
- private void createTypeSpecificLinkConfig(List<LinkConfig> lkConfList) {
- for (LinkConfig lkc : lkConfList) {
- String lktype = lkc.getType();
- switch (lktype) {
- case PKT_LINK:
- PktLinkConfig pk = new PktLinkConfig(lkc);
- for (Link lt : pk.getLinkTupleList()) {
- configuredLinks.put(lt, pk);
- }
- break;
- default:
- throw new NetworkConfigException.UnknownLinkType(lktype,
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- }
- }
-
- private void validateSwitchConfig(List<SwitchConfig> swConfList) {
- 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());
- }
- // ensure both String and DeviceId values of dpid are set
- if (!swc.getDpid().equals(DeviceId.deviceId(swc.getNodeDpid()))) {
- throw new NetworkConfigException.SwitchDpidNotConverted(
- swc.getName());
- }
- if (swc.getName() == null) {
- throw new NetworkConfigException.NameNotSpecified(swc.getDpid());
- }
- if (swc.getType() == null) {
- throw new NetworkConfigException.SwitchTypeNotSpecified(
- swc.getDpid());
- }
- if (!swDpids.add(swc.getDpid())) {
- throw new NetworkConfigException.DuplicateDpid(swc.getDpid());
- }
- if (!swNames.add(swc.getName())) {
- throw new NetworkConfigException.DuplicateName(swc.getName());
- }
- // TODO Add more validations
- }
- }
-
- private void validateLinkConfig(List<LinkConfig> lkConfList) {
- for (LinkConfig lkc : lkConfList) {
- if (lkc.getNodeDpid1() == null || lkc.getNodeDpid2() == null) {
- throw new NetworkConfigException.LinkDpidNotSpecified(
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- // ensure both String and Long values are set
- if (!lkc.getDpid1().equals(DeviceId.deviceId(lkc.getNodeDpid1())) ||
- !lkc.getDpid2().equals(DeviceId.deviceId(lkc.getNodeDpid2()))) {
- throw new NetworkConfigException.LinkDpidNotConverted(
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- if (lkc.getType() == null) {
- throw new NetworkConfigException.LinkTypeNotSpecified(
- lkc.getNodeDpid1(), lkc.getNodeDpid2());
- }
- if (configuredSwitches.get(lkc.getDpid1()) == null) {
- throw new NetworkConfigException.LinkForUnknownSwitchConfig(
- lkc.getNodeDpid1());
- }
- if (configuredSwitches.get(lkc.getDpid2()) == null) {
- throw new NetworkConfigException.LinkForUnknownSwitchConfig(
- lkc.getNodeDpid2());
- }
- // TODO add more validations
- }
-
- }
-
- private LinkConfig getConfiguredLink(Link linkTuple) {
- LinkConfig lkc = null;
- // first try the unidirectional link with the ports assigned
- lkc = configuredLinks.get(linkTuple);
- return lkc;
- }
-
-
- /**
- * Initializes the network configuration manager module by
- * loading and parsing the network configuration file.
- */
- public void init() {
- loadNetworkConfig();
- 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
deleted file mode 100644
index afbb0fcc..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/NetworkConfigService.java
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.util.List;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
-import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
-import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;
-
-/**
- * Exposes methods to retrieve network configuration.
- *
- * TODO: currently only startup-configuration is exposed and such configuration
- * cannot be changed at runtime. Need to add runtime support for changes to
- * configuration (via REST/CLI) in future releases.
- *
- * TODO: return immutable objects or defensive copies of network config so that
- * users of this API do not inadvertently or maliciously change network config.
- *
- * @deprecated in Drake; see org.onosproject.net.config
- */
-@Deprecated
-public interface NetworkConfigService {
-
- /**
- * Suggests the action to be taken by the caller given the configuration
- * associated with the queried network-object (eg. switch, link etc.).
- */
- enum NetworkConfigState {
- /**
- * Associated network object has been configured to not be allowed in
- * the network.
- */
- DENY,
-
- /**
- * Associated network object has been configured to be allowed in the
- * network.
- */
- ACCEPT,
-
- /**
- * Associated network object has been configured to be allowed in the
- * network. In addition, there are configured parameters that should be
- * added to the object.
- */
- ACCEPT_ADD,
- }
-
- /**
- * Returns the configuration outcome (accept, deny etc.), and any configured
- * parameters to the caller, in response to a query for the configuration
- * associated with a switch.
- */
- class SwitchConfigStatus {
- private NetworkConfigState configState;
- private SwitchConfig switchConfig;
- private String msg;
-
- SwitchConfigStatus(NetworkConfigState configState,
- SwitchConfig switchConfig, String msg) {
- this.configState = configState;
- this.switchConfig = switchConfig;
- this.msg = msg;
- }
-
- SwitchConfigStatus(NetworkConfigState configState,
- SwitchConfig switchConfig) {
- this.configState = configState;
- this.switchConfig = switchConfig;
- this.msg = "";
- }
-
- /**
- * Returns the configuration state for the switch.
- *
- * @return non-null NetworkConfigState
- */
- public NetworkConfigState getConfigState() {
- return configState;
- }
-
- /**
- * Returns the switch configuration, which may be null if no
- * configuration exists, or if the configuration state disallows the
- * switch.
- *
- * @return SwitchConfig, the switch configuration, or null
- */
- public SwitchConfig getSwitchConfig() {
- return switchConfig;
- }
-
- /**
- * User readable string typically used to specify the reason why a
- * switch is being disallowed.
- *
- * @return A non-null but possibly empty String
- */
- public String getMsg() {
- return msg;
- }
-
- }
-
- /**
- * Reserved for future use.
- *
- * Returns the configuration outcome (accept, deny etc.), and any configured
- * parameters to the caller, in response to a query for the configuration
- * associated with a link.
- */
- class LinkConfigStatus {
- private NetworkConfigState configState;
- private LinkConfig linkConfig;
- private String msg;
-
- LinkConfigStatus(NetworkConfigState configState,
- LinkConfig linkConfig, String msg) {
- this.configState = configState;
- this.linkConfig = linkConfig;
- this.msg = msg;
- }
-
- LinkConfigStatus(NetworkConfigState configState,
- LinkConfig linkConfig) {
- this.configState = configState;
- this.linkConfig = linkConfig;
- this.msg = "";
- }
-
- /**
- * Returns the configuration state for the link.
- *
- * @return non-null NetworkConfigState
- */
- public NetworkConfigState getConfigState() {
- return configState;
- }
-
- /**
- * Returns the link configuration, which may be null if no configuration
- * exists, or if the configuration state disallows the link.
- *
- * @return SwitchConfig, the switch configuration, or null
- */
- public LinkConfig getLinkConfig() {
- return linkConfig;
- }
-
- /**
- * User readable string typically used to specify the reason why a link
- * is being disallowed.
- *
- * @return msg A non-null but possibly empty String
- */
- public String getMsg() {
- return msg;
- }
-
- }
-
- /**
- * Checks the switch configuration (if any) associated with the 'dpid'.
- * Determines if the switch should be allowed or denied according to
- * configuration rules.
- *
- * The method always returns a non-null SwitchConfigStatus. The enclosed
- * ConfigState contains the result of the check. The enclosed SwitchConfig
- * may or may not be null, depending on the outcome of the check.
- *
- * @param dpid device id of the switch to be queried
- * @return SwitchConfigStatus with outcome of check and associated config.
- */
- SwitchConfigStatus checkSwitchConfig(DeviceId dpid);
-
- /**
- * Reserved for future use.
- *
- * Checks the link configuration (if any) associated with the 'link'.
- * Determines if the link should be allowed or denied according to
- * configuration rules. Note that the 'link' is a unidirectional link which
- * checked against configuration that is typically defined for a
- * bidirectional link. The caller may make a second call if it wishes to
- * check the 'reverse' direction.
- *
- * Also note that the configuration may not specify ports for a given
- * bidirectional link. In such cases, the configuration applies to all links
- * between the two switches. This method will check the given 'link' against
- * such configuration.
-
- * The method always returns a non-null LinkConfigStatus. The enclosed
- * ConfigState contains the result of the check. The enclosed LinkConfig may
- * or may not be null, depending on the outcome of the check.
- *
- * @param linkTuple unidirectional link to be queried
- * @return LinkConfigStatus with outcome of check and associated config.
- */
- LinkConfigStatus checkLinkConfig(Link linkTuple);
-
- /**
- * Retrieves a list of switches that have been configured, and have been
- * determined to be 'allowed' in the network, according to configuration
- * rules.
- *
- * Note that it is possible that there are other switches that are allowed
- * in the network that have NOT been configured. Such switches will not be a
- * part of the returned list.
- *
- * Also note that it is possible that some switches will not be discovered
- * and the only way the controller can know about these switches is via
- * configuration. Such switches will be included in this list. It is up to
- * the caller to determine which SwitchConfig applies to non-discovered
- * switches.
- *
- * @return a non-null List of SwitchConfig which may be empty
- */
- List<SwitchConfig> getConfiguredAllowedSwitches();
-
- /**
- * Reserved for future use.
- *
- * Retrieves a list of links that have been configured, and have been
- * determined to be 'allowed' in the network, according to configuration
- * rules.
- *
- * Note that it is possible that there are other links that are allowed in
- * the network that have NOT been configured. Such links will not be a part
- * of the returned list.
- *
- * Also note that it is possible that some links will not be discovered and
- * the only way the controller can know about these links is via
- * configuration. Such links will be included in this list. It is up to the
- * caller to determine which LinkConfig applies to non-discovered links.
- *
- * In addition, note that the LinkConfig applies to the configured
- * bi-directional link, which may or may not have declared ports. The
- * associated unidirectional LinkTuple can be retrieved from the
- * getLinkTupleList() method in the LinkConfig object.
- *
- * @return a non-null List of LinkConfig which may be empty
- */
- List<LinkConfig> getConfiguredAllowedLinks();
-
- /**
- * Retrieves the Dpid associated with a 'name' for a configured switch
- * object. This method does not check of the switches are 'allowed' by
- * config.
- *
- * @param name device name
- * @return the Dpid corresponding to a given 'name', or null if no
- * configured switch was found for the given 'name'.
- */
- DeviceId getDpidForName(String name);
-
-}
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
deleted file mode 100644
index 3c51fa9d..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/PktLinkConfig.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onosproject.net.Link;
-import org.onosproject.segmentrouting.config.NetworkConfig.LinkConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.databind.JsonNode;
-
-/**
- * Reserved for future use.
- * Configuration for a link between two packet-switches.
- */
-public class PktLinkConfig extends LinkConfig {
- protected static final Logger log = LoggerFactory
- .getLogger(PktLinkConfig.class);
- private int port1;
- private int port2;
- private String nodeName1;
- private String nodeName2;
- private List<Link> linkTupleList;
-
- public PktLinkConfig(LinkConfig lkc) {
- nodeDpid1 = lkc.getNodeDpid1();
- nodeDpid2 = lkc.getNodeDpid2();
- dpid1 = lkc.getDpid1();
- dpid2 = lkc.getDpid2();
- type = lkc.getType();
- allowed = lkc.isAllowed();
- params = lkc.getParams();
- publishAttributes = new ConcurrentHashMap<>();
- parseParams();
- validateParams();
- setPublishAttributes();
- }
-
- // ********************
- // Packet Link Configuration
- // ********************
-
- public int getPort1() {
- return port1;
- }
-
- public void setPort1(int port1) {
- this.port1 = port1;
- }
-
- public int getPort2() {
- return port2;
- }
-
- public void setPort2(int port2) {
- this.port2 = port2;
- }
-
- public String getNodeName1() {
- return nodeName1;
- }
-
- public void setNodeName1(String nodeName1) {
- this.nodeName1 = nodeName1;
- }
-
- public String getNodeName2() {
- return nodeName2;
- }
-
- public void setNodeName2(String nodeName2) {
- this.nodeName2 = nodeName2;
- }
-
- /**
- * Returns the two unidirectional links corresponding to the packet-link
- * configuration. It is possible that the ports in the LinkTuple have
- * portnumber '0', implying that the configuration applies to all links
- * between the two switches.
- *
- * @return a list of LinkTuple with exactly 2 unidirectional links
- */
- public List<Link> getLinkTupleList() {
- return linkTupleList;
- }
-
- private void setPublishAttributes() {
-
- }
-
- private void parseParams() {
- if (params == null) {
- throw new PktLinkParamsNotSpecified(nodeDpid1, nodeDpid2);
- }
- Set<Entry<String, JsonNode>> m = params.entrySet();
- for (Entry<String, JsonNode> e : m) {
- String key = e.getKey();
- JsonNode j = e.getValue();
- if (key.equals("nodeName1")) {
- setNodeName1(j.asText());
- } else if (key.equals("nodeName2")) {
- setNodeName2(j.asText());
- } else if (key.equals("port1")) {
- setPort1(j.asInt());
- } else if (key.equals("port2")) {
- setPort2(j.asInt());
- } else {
- throw new UnknownPktLinkConfig(key, nodeDpid1, nodeDpid2);
- }
- }
- }
-
- private void validateParams() {
- // TODO - wrong-names, duplicate links,
- // duplicate use of port, is switch-allowed for which link is allowed?
- // valid port numbers
- }
-
- public static class PktLinkParamsNotSpecified extends RuntimeException {
- private static final long serialVersionUID = 6247582323691265513L;
-
- public PktLinkParamsNotSpecified(String dpidA, String dpidB) {
- super();
- log.error("Params required for packet link - not specified "
- + "for link between switch1:{} and switch2:{}",
- dpidA, dpidB);
- }
- }
-
- public static class UnknownPktLinkConfig extends RuntimeException {
- private static final long serialVersionUID = -5750132094884129179L;
-
- public UnknownPktLinkConfig(String key, String dpidA, String dpidB) {
- super();
- log.error("Unknown packet-link config {} for link between"
- + " dpid1: {} and dpid2: {}", key,
- dpidA, dpidB);
- }
- }
-
-}
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
deleted file mode 100644
index c8d4a54a..00000000
--- a/framework/src/onos/apps/segmentrouting/src/main/java/org/onosproject/segmentrouting/config/SegmentRouterConfig.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.segmentrouting.config;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.onosproject.net.DeviceId;
-import org.onosproject.segmentrouting.config.NetworkConfig.SwitchConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * Manages additional configuration for switches configured as Segment Routers.
- */
-public class SegmentRouterConfig extends SwitchConfig {
- protected static final Logger log = LoggerFactory
- .getLogger(SegmentRouterConfig.class);
- private String routerIp;
- private String routerMac;
- private int nodeSid;
- private boolean isEdgeRouter;
- private List<AdjacencySid> adjacencySids;
- private List<Subnet> subnets;
-
- public static final String ROUTER_IP = "routerIp";
- public static final String ROUTER_MAC = "routerMac";
- public static final String NODE_SID = "nodeSid";
- public static final String ADJACENCY_SIDS = "adjacencySids";
- public static final String SUBNETS = "subnets";
- public static final String ISEDGE = "isEdgeRouter";
- private static final int SRGB_MAX = 1000;
-
- /**
- * Parses and validates the additional configuration parameters applicable
- * to segment routers.
- *
- * @param swc switch configuration
- */
- public SegmentRouterConfig(SwitchConfig swc) {
- this.setName(swc.getName());
- this.setDpid(swc.getDpid());
- this.setType(swc.getType());
- this.setLatitude(swc.getLatitude());
- this.setLongitude(swc.getLongitude());
- this.setParams(swc.getParams());
- this.setAllowed(swc.isAllowed());
- publishAttributes = new ConcurrentHashMap<>();
- adjacencySids = new ArrayList<>();
- subnets = new ArrayList<>();
- parseParams();
- validateParams();
- setPublishAttributes();
- }
-
- /**
- * Returns the configured segment router IP address.
- *
- * @return ip address in string format
- */
- public String getRouterIp() {
- return routerIp;
- }
-
- public void setRouterIp(String routerIp) {
- this.routerIp = routerIp;
- }
-
- /**
- * Returns the configured segment router mac address.
- *
- * @return mac address in string format
- */
- public String getRouterMac() {
- return routerMac;
- }
-
- public void setRouterMac(String routerMac) {
- this.routerMac = routerMac;
- }
-
- /**
- * Returns the configured sID for a segment router.
- *
- * @return segment identifier
- */
- public int getNodeSid() {
- return nodeSid;
- }
-
- public void setNodeSid(int nodeSid) {
- this.nodeSid = nodeSid;
- }
-
- /**
- * Returns the flag that indicates the configured segment router
- * is edge or backbone router.
- *
- * @return boolean
- */
- public boolean isEdgeRouter() {
- return isEdgeRouter;
- }
-
- public void setIsEdgeRouter(boolean isEdge) {
- this.isEdgeRouter = isEdge;
- }
-
- /**
- * Class representing segment router adjacency identifier.
- */
- public static class AdjacencySid {
- private int adjSid;
- private List<Integer> ports;
-
- public AdjacencySid(int adjSid, List<Integer> ports) {
- this.ports = ports;
- this.adjSid = adjSid;
- }
-
- /**
- * Returns the list of ports part of a segment
- * router adjacency identifier.
- *
- * @return list of integers
- */
- public List<Integer> getPorts() {
- return ports;
- }
-
- public void setPorts(List<Integer> ports) {
- this.ports = ports;
- }
-
- /**
- * Returns the configured adjacency id of a segment router.
- *
- * @return integer
- */
- public int getAdjSid() {
- return adjSid;
- }
-
- public void setAdjSid(int adjSid) {
- this.adjSid = adjSid;
- }
- }
-
- /**
- * Returns the configured adjacent segment IDs for a segment router.
- *
- * @return list of adjacency identifier
- */
- public List<AdjacencySid> getAdjacencySids() {
- return adjacencySids;
- }
-
- public void setAdjacencySids(List<AdjacencySid> adjacencySids) {
- this.adjacencySids = adjacencySids;
- }
-
- /**
- * Class representing a subnet attached to a segment router.
- */
- public static class Subnet {
- private int portNo;
- private String subnetIp;
-
- public Subnet(int portNo, String subnetIp) {
- this.portNo = portNo;
- this.subnetIp = subnetIp;
- }
-
- /**
- * Returns the port number of segment router on
- * which subnet is attached.
- *
- * @return integer
- */
- public int getPortNo() {
- return portNo;
- }
-
- public void setPortNo(int portNo) {
- this.portNo = portNo;
- }
-
- /**
- * Returns the configured subnet address.
- *
- * @return subnet ip address in string format
- */
- public String getSubnetIp() {
- return subnetIp;
- }
-
- public void setSubnetIp(String subnetIp) {
- this.subnetIp = subnetIp;
- }
- }
-
- /**
- * Returns the configured subnets for a segment router.
- *
- * @return list of subnets
- */
- public List<Subnet> getSubnets() {
- return subnets;
- }
-
- public void setSubnets(List<Subnet> subnets) {
- this.subnets = subnets;
- }
-
- // ********************
- // Helper methods
- // ********************
-
- private void parseParams() {
- if (params == null) {
- throw new NetworkConfigException.ParamsNotSpecified(name);
- }
-
- Set<Entry<String, JsonNode>> m = params.entrySet();
- for (Entry<String, JsonNode> e : m) {
- String key = e.getKey();
- JsonNode j = e.getValue();
- if (key.equals("routerIp")) {
- setRouterIp(j.asText());
- } else if (key.equals("routerMac")) {
- setRouterMac(j.asText());
- } else if (key.equals("nodeSid")) {
- setNodeSid(j.asInt());
- } else if (key.equals("isEdgeRouter")) {
- setIsEdgeRouter(j.asBoolean());
- } else if (key.equals("adjacencySids") || key.equals("subnets")) {
- getInnerParams(j, key);
- } else {
- throw new UnknownSegmentRouterConfig(key, dpid);
- }
- }
- }
-
- private void getInnerParams(JsonNode j, String innerParam) {
- Iterator<JsonNode> innerList = j.elements();
- while (innerList.hasNext()) {
- Iterator<Entry<String, JsonNode>> f = innerList.next().fields();
- int portNo = -1;
- int adjSid = -1;
- String subnetIp = null;
- List<Integer> ports = null;
- while (f.hasNext()) {
- Entry<String, JsonNode> fe = f.next();
- if (fe.getKey().equals("portNo")) {
- portNo = fe.getValue().asInt();
- } else if (fe.getKey().equals("adjSid")) {
- adjSid = fe.getValue().asInt();
- } else if (fe.getKey().equals("subnetIp")) {
- subnetIp = fe.getValue().asText();
- } else if (fe.getKey().equals("ports")) {
- if (fe.getValue().isArray()) {
- Iterator<JsonNode> i = fe.getValue().elements();
- ports = new ArrayList<>();
- while (i.hasNext()) {
- ports.add(i.next().asInt());
- }
- }
- } else {
- throw new UnknownSegmentRouterConfig(fe.getKey(), dpid);
- }
- }
- if (innerParam.equals("adjacencySids")) {
- AdjacencySid ads = new AdjacencySid(adjSid, ports);
- adjacencySids.add(ads);
- } else {
- Subnet sip = new Subnet(portNo, subnetIp);
- subnets.add(sip);
- }
- }
- }
-
- private void validateParams() {
- if (routerIp == null) {
- throw new IpNotSpecified(dpid);
- }
- if (routerMac == null) {
- throw new MacNotSpecified(dpid);
- }
- if (isEdgeRouter && subnets.isEmpty()) {
- throw new SubnetNotSpecifiedInEdgeRouter(dpid);
- }
- if (!isEdgeRouter && !subnets.isEmpty()) {
- throw new SubnetSpecifiedInBackboneRouter(dpid);
- }
- if (nodeSid > SRGB_MAX) {
- throw new NodeLabelNotInSRGB(nodeSid, dpid);
- }
- for (AdjacencySid as : adjacencySids) {
- int label = as.getAdjSid();
- List<Integer> plist = as.getPorts();
- if (label <= SRGB_MAX) {
- throw new AdjacencyLabelInSRGB(label, dpid);
- }
- if (plist.size() <= 1) {
- throw new AdjacencyLabelNotEnoughPorts(label, dpid);
- }
- }
-
-
- // TODO more validations
- }
-
- /**
- * Setting publishAttributes implies that this is the configuration that
- * will be added to Topology.Switch object before it is published on the
- * channel to other controller instances.
- */
- private void setPublishAttributes() {
- publishAttributes.put(ROUTER_IP, routerIp);
- publishAttributes.put(ROUTER_MAC, routerMac);
- publishAttributes.put(NODE_SID, String.valueOf(nodeSid));
- publishAttributes.put(ISEDGE, String.valueOf(isEdgeRouter));
- ObjectMapper mapper = new ObjectMapper();
- try {
- publishAttributes.put(ADJACENCY_SIDS,
- mapper.writeValueAsString(adjacencySids));
- publishAttributes.put(SUBNETS,
- mapper.writeValueAsString(subnets));
- } catch (JsonProcessingException e) {
- log.error("Error while writing SR config: {}", e.getCause());
- } catch (IOException e) {
- log.error("Error while writing SR config: {}", e.getCause());
- }
- }
-
- // ********************
- // Exceptions
- // ********************
-
- public static class IpNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -3001502553646331686L;
-
- public IpNotSpecified(DeviceId dpid) {
- super();
- log.error("Router IP address not specified for SR config dpid:{}",
- dpid);
- }
- }
-
- public static class MacNotSpecified extends RuntimeException {
- private static final long serialVersionUID = -5850132094884129179L;
-
- public MacNotSpecified(DeviceId dpid) {
- super();
- log.error("Router Mac address not specified for SR config dpid:{}",
- dpid);
- }
- }
-
- public static class UnknownSegmentRouterConfig extends RuntimeException {
- private static final long serialVersionUID = -5750132094884129179L;
-
- public UnknownSegmentRouterConfig(String key, DeviceId dpid) {
- super();
- log.error("Unknown Segment Router config {} in dpid: {}", key,
- dpid);
- }
- }
-
- public static class SubnetNotSpecifiedInEdgeRouter extends RuntimeException {
- private static final long serialVersionUID = -5855458472668581268L;
-
- public SubnetNotSpecifiedInEdgeRouter(DeviceId dpid) {
- super();
- log.error("Subnet was not specified for edge router in dpid: {}",
- dpid);
- }
- }
-
- public static class SubnetSpecifiedInBackboneRouter extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public SubnetSpecifiedInBackboneRouter(DeviceId dpid) {
- super();
- log.error("Subnet was specified in backbone router in dpid: {}",
- dpid);
- }
- }
-
- public static class NodeLabelNotInSRGB extends RuntimeException {
- private static final long serialVersionUID = -8482670903748519526L;
-
- public NodeLabelNotInSRGB(int label, DeviceId dpid) {
- super();
- log.error("Node sif {} specified in not in global label-base "
- + "in dpid: {}", label,
- dpid);
- }
- }
-
- public static class AdjacencyLabelInSRGB extends RuntimeException {
- private static final long serialVersionUID = -8482670903748519526L;
-
- public AdjacencyLabelInSRGB(int label, DeviceId dpid) {
- super();
- log.error("Adjaceny label {} specified from global label-base "
- + "in dpid: {}", label,
- dpid);
- }
- }
-
- public static class AdjacencyLabelNotEnoughPorts extends RuntimeException {
- private static final long serialVersionUID = -8482670903748519526L;
-
- public AdjacencyLabelNotEnoughPorts(int label, DeviceId dpid) {
- super();
- log.error("Adjaceny label {} must be specified for at least 2 ports. "
- + "Adjacency labels for single ports are auto-generated "
- + "in dpid: {}", label,
- dpid);
- }
- }
-}
diff --git a/framework/src/onos/apps/vtn/features.xml b/framework/src/onos/apps/vtn/features.xml
deleted file mode 100644
index a8f9cb49..00000000
--- a/framework/src/onos/apps/vtn/features.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.0" name="${project.artifactId}-${project.version}">
- <repository>mvn:${project.groupId}/${project.artifactId}/${project.version}/xml/features</repository>
- <feature name="${project.artifactId}" version="${project.version}"
- description="${project.description}">
- <feature>onos-api</feature>
- <feature>onos-drivers</feature>
- <feature>onos-app-vtnrsc</feature>
- <feature>onos-app-vtnweb</feature>
- <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
- </feature>
-</features>
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java
deleted file mode 100644
index a20f852b..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/VTNService.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn;
-
-import org.onosproject.net.Device;
-import org.onosproject.net.Host;
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-public interface VTNService {
-
- /**
- * Creates a vxlan tunnel and creates the ovs when a ovs controller node is detected.
- *
- * @param device controller-type device
- */
- void onServerDetected(Device device);
-
- /**
- * Drops a vxlan tunnel and drops the ovs when a ovs controller node is vanished.
- *
- * @param device controller-type device
- */
- void onServerVanished(Device device);
-
- /**
- * Applies default forwarding flows when a ovs is detected.
- *
- * @param device switch-type device
- */
- void onOvsDetected(Device device);
-
- /**
- * Remove default forwarding flows when a ovs is vanished.
- *
- * @param device switch-type device
- */
- void onOvsVanished(Device device);
-
- /**
- * Applies multicast flows and tunnel flows when a VM is detected.
- *
- * @param host a VM
- */
- void onHostDetected(Host host);
-
- /**
- * Remove multicast flows and tunnel flows when a VM is vanished.
- *
- * @param host a VM
- */
- void onHostVanished(Host host);
-
-}
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
deleted file mode 100644
index ba4745b6..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/VTNManager.java
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtn.impl;
-
-import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
-import static org.onlab.util.Tools.groupedThreads;
-import static org.slf4j.LoggerFactory.getLogger;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ScheduledExecutorService;
-
-import org.apache.felix.scr.annotations.Activate;
-import org.apache.felix.scr.annotations.Component;
-import org.apache.felix.scr.annotations.Deactivate;
-import org.apache.felix.scr.annotations.Reference;
-import org.apache.felix.scr.annotations.ReferenceCardinality;
-import org.apache.felix.scr.annotations.Service;
-import org.onlab.osgi.DefaultServiceDirectory;
-import org.onlab.osgi.ServiceDirectory;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.MacAddress;
-import org.onlab.util.KryoNamespace;
-import org.onosproject.core.ApplicationId;
-import org.onosproject.core.CoreService;
-import org.onosproject.net.Device;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Host;
-import org.onosproject.net.HostId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.behaviour.BridgeConfig;
-import org.onosproject.net.behaviour.BridgeDescription;
-import org.onosproject.net.behaviour.BridgeName;
-import org.onosproject.net.behaviour.DefaultTunnelDescription;
-import org.onosproject.net.behaviour.IpTunnelEndPoint;
-import org.onosproject.net.behaviour.Pipeliner;
-import org.onosproject.net.behaviour.PipelinerContext;
-import org.onosproject.net.behaviour.TunnelConfig;
-import org.onosproject.net.behaviour.TunnelDescription;
-import org.onosproject.net.behaviour.TunnelEndPoint;
-import org.onosproject.net.device.DeviceEvent;
-import org.onosproject.net.device.DeviceListener;
-import org.onosproject.net.device.DeviceService;
-import org.onosproject.net.driver.DefaultDriverData;
-import org.onosproject.net.driver.Driver;
-import org.onosproject.net.driver.DriverHandler;
-import org.onosproject.net.driver.DriverService;
-import org.onosproject.net.flow.DefaultTrafficSelector;
-import org.onosproject.net.flow.DefaultTrafficTreatment;
-import org.onosproject.net.flow.FlowRuleService;
-import org.onosproject.net.flow.TrafficSelector;
-import org.onosproject.net.flow.TrafficTreatment;
-import org.onosproject.net.flow.criteria.Criteria;
-import org.onosproject.net.flow.instructions.Instructions;
-import org.onosproject.net.flowobjective.DefaultForwardingObjective;
-import org.onosproject.net.flowobjective.FlowObjectiveService;
-import org.onosproject.net.flowobjective.FlowObjectiveStore;
-import org.onosproject.net.flowobjective.ForwardingObjective;
-import org.onosproject.net.flowobjective.ForwardingObjective.Flag;
-import org.onosproject.net.flowobjective.Objective;
-import org.onosproject.net.host.HostEvent;
-import org.onosproject.net.host.HostListener;
-import org.onosproject.net.host.HostService;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.EventuallyConsistentMap;
-import org.onosproject.store.service.StorageService;
-import org.onosproject.store.service.WallClockTimestamp;
-import org.onosproject.vtn.VTNService;
-import org.onosproject.vtnrsc.SegmentationId;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-import org.slf4j.Logger;
-
-import com.google.common.collect.Sets;
-
-/**
- * Provides implementation of VTNService.
- */
-@Component(immediate = true)
-@Service
-public class VTNManager implements VTNService {
- private final Logger log = getLogger(getClass());
-
- private static final String APP_ID = "org.onosproject.app.vtn";
- private ScheduledExecutorService backgroundService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DeviceService deviceService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected HostService hostService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowRuleService flowRuleService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected CoreService coreService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected StorageService storageService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected TenantNetworkService tenantNetworkService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected VirtualPortService virtualPortService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected DriverService driverService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveService flowObjectiveService;
- @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected FlowObjectiveStore flowObjectiveStore;
- protected ServiceDirectory serviceDirectory = new DefaultServiceDirectory();
- private EventuallyConsistentMap<HostId, SegmentationId> binding;
- private ApplicationId appId;
- private HostListener hostListener = new InnerHostListener();
- private DeviceListener deviceListener = new InnerDeviceListener();
- private static final String IFACEID = "ifaceid";
- private static final String PORT_HEAD = "vxlan";
- private static final String DEFAULT_BRIDGE_NAME = "br-int";
- private static final String CONTROLLER_IP_KEY = "ipaddress";
- private static final int DEFAULT_MAC_PRIORITY = 0x0000;
- private static final int MAC_PRIORITY = 0xffff;
- private static final int DEFAULT_PORT_PRIORITY = 0x0000;
- private static final int PORT_PRIORITY = 0xffff;
- private static final String SWITCH_CHANNEL_ID = "channelId";
- private static final String DRIVER_NAME = "onosfw";
-
- @Activate
- public void activate() {
- KryoNamespace.Builder serializer = KryoNamespace.newBuilder()
- .register(KryoNamespaces.API);
- appId = coreService.registerApplication(APP_ID);
- deviceService.addListener(deviceListener);
- hostService.addListener(hostListener);
- backgroundService = newSingleThreadScheduledExecutor(groupedThreads("onos-apps/vtn",
- "manager-background"));
- binding = storageService
- .<HostId, SegmentationId>eventuallyConsistentMapBuilder()
- .withName("all_tunnel").withSerializer(serializer)
- .withTimestampProvider((k, v) -> new WallClockTimestamp())
- .build();
- log.info("Started");
- }
-
- @Deactivate
- public void deactivate() {
- backgroundService.shutdown();
- binding.destroy();
- log.info("Stopped");
- }
-
- @Override
- public void onServerDetected(Device device) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- DriverHandler handler = driverService.createHandler(device.id());
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE_NAME));
- String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
- IpAddress ip = IpAddress.valueOf(ipAddress);
- Sets.newHashSet(devices).stream()
- .filter(d -> Device.Type.CONTROLLER == d.type())
- .filter(d -> !device.id().equals(d.id())).forEach(d -> {
- String ipAddress1 = d.annotations()
- .value(CONTROLLER_IP_KEY);
- IpAddress ip1 = IpAddress.valueOf(ipAddress1);
- applyTunnelConfig(ip, ip1, handler);
- DriverHandler handler1 = driverService
- .createHandler(d.id());
- applyTunnelConfig(ip1, ip, handler1);
-
- });
- }
-
- @Override
- public void onServerVanished(Device device) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- String ipAddress = device.annotations().value(CONTROLLER_IP_KEY);
- IpAddress dst = IpAddress.valueOf(ipAddress);
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER)
- .filter(d -> !device.id().equals(d.id())).forEach(d -> {
- String ipAddress1 = d.annotations()
- .value(CONTROLLER_IP_KEY);
- DriverHandler handler = driverService.createHandler(d.id());
- IpAddress src = IpAddress.valueOf(ipAddress1);
- removeTunnelConfig(src, dst, handler);
- });
- }
-
- private void applyTunnelConfig(IpAddress src, IpAddress dst,
- DriverHandler handler) {
- TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
- TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelAsSrc,
- tunnelAsDst,
- TunnelDescription.Type.VXLAN,
- null);
- TunnelConfig config = handler.behaviour(TunnelConfig.class);
- config.createTunnel(tunnel);
- }
-
- private void removeTunnelConfig(IpAddress src, IpAddress dst,
- DriverHandler handler) {
- TunnelEndPoint tunnelAsSrc = IpTunnelEndPoint.ipTunnelPoint(src);
- TunnelEndPoint tunnelAsDst = IpTunnelEndPoint.ipTunnelPoint(dst);
- TunnelDescription tunnel = new DefaultTunnelDescription(
- tunnelAsSrc,
- tunnelAsDst,
- TunnelDescription.Type.VXLAN,
- null);
- TunnelConfig config = handler.behaviour(TunnelConfig.class);
- config.removeTunnel(tunnel);
- }
-
- @Override
- public void onOvsDetected(Device device) {
- programMacDefaultRules(device.id(), appId, Objective.Operation.ADD);
- programPortDefaultRules(device.id(), appId, Objective.Operation.ADD);
- }
-
- @Override
- public void onOvsVanished(Device device) {
- programMacDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
- programPortDefaultRules(device.id(), appId, Objective.Operation.REMOVE);
- }
-
- @Override
- public void onHostDetected(Host host) {
- String ifaceId = host.annotations().value(IFACEID);
- DeviceId deviceId = host.location().deviceId();
- String currentControllerIp = getControllerIpOfSwitch(deviceId);
- Iterable<Device> devices = deviceService.getAvailableDevices();
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- TenantNetwork network = tenantNetworkService
- .getNetwork(port.networkId());
- String tunnelName = "vxlan-" + currentControllerIp;
- binding.put(host.id(), network.segmentationId());
- List<Port> allPorts = deviceService.getPorts(deviceId);
- PortNumber inPort = host.location().port();
- List<PortNumber> localVmPorts = getLocalPorts(deviceId, ifaceId);
- List<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(allPorts.iterator()).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL)).forEach(p -> {
- if (p.annotations().value("portName").startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
-
- localVmPorts.forEach(lp -> programLocalBcastRules(deviceId, network.segmentationId(), lp, localVmPorts,
- localTunnelPorts, appId, Objective.Operation.ADD));
- programLocalOut(deviceId, network.segmentationId(), inPort, host.mac(),
- appId, Objective.Operation.ADD);
- localTunnelPorts
- .forEach(tp -> programTunnelFloodOut(deviceId,
- network.segmentationId(),
- tp, localVmPorts,
- appId,
- Objective.Operation.ADD));
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER).forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler
- .behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig
- .getBridges();
-
- Iterator<BridgeDescription> it = bridgeDescriptions
- .iterator();
- if (it.hasNext()) {
- BridgeDescription sw = it.next();
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- ports.stream()
- .filter(p -> p.name()
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> programTunnelOut(sw.deviceId(),
- network.segmentationId(), p,
- host.mac(), appId,
- Objective.Operation.ADD));
- }
- });
- programLocalIn(deviceId, network.segmentationId(), inPort, host.mac(),
- appId, Objective.Operation.ADD);
- localTunnelPorts
- .forEach(tp -> programTunnelIn(deviceId,
- network.segmentationId(),
- tp, inPort, host.mac(),
- appId, Objective.Operation.ADD));
-
- }
-
- @Override
- public void onHostVanished(Host host) {
- String ifaceId = host.annotations().value(IFACEID);
- SegmentationId segId = binding.remove(host.id());
- DeviceId deviceId = host.location().deviceId();
- String currentControllerIp = getControllerIpOfSwitch(deviceId);
- Iterable<Device> devices = deviceService.getAvailableDevices();
-
- String tunnelName = "vxlan-" + currentControllerIp;
- List<Port> allPorts = deviceService.getPorts(deviceId);
- PortNumber inPort = host.location().port();
-
- List<PortNumber> localTunnelPorts = new ArrayList<>();
- Sets.newHashSet(allPorts.iterator()).stream()
- .filter(p -> !p.number().equals(PortNumber.LOCAL)).forEach(p -> {
- if (p.annotations().value("portName").startsWith(PORT_HEAD)) {
- localTunnelPorts.add(p.number());
- }
- });
-
- List<PortNumber> localVmPorts = getLocalPorts(deviceId, ifaceId);
- localVmPorts.add(inPort);
- localVmPorts.forEach(lp -> programLocalBcastRules(deviceId, segId, lp, localVmPorts,
- localTunnelPorts, appId, Objective.Operation.REMOVE));
- programLocalOut(deviceId, segId, inPort, host.mac(),
- appId, Objective.Operation.REMOVE);
- localTunnelPorts
- .forEach(tp -> programTunnelFloodOut(deviceId,
- segId,
- tp, localVmPorts,
- appId,
- Objective.Operation.REMOVE));
- Sets.newHashSet(devices).stream()
- .filter(d -> d.type() == Device.Type.CONTROLLER).forEach(d -> {
- DriverHandler handler = driverService.createHandler(d.id());
- BridgeConfig bridgeConfig = handler
- .behaviour(BridgeConfig.class);
- Collection<BridgeDescription> bridgeDescriptions = bridgeConfig
- .getBridges();
-
- Iterator<BridgeDescription> it = bridgeDescriptions
- .iterator();
- if (it.hasNext()) {
- BridgeDescription sw = it.next();
- Set<PortNumber> ports = bridgeConfig.getPortNumbers();
- ports.stream()
- .filter(p -> p.name()
- .equalsIgnoreCase(tunnelName))
- .forEach(p -> programTunnelOut(sw.deviceId(),
- segId, p,
- host.mac(), appId,
- Objective.Operation.REMOVE));
- }
- });
- programLocalIn(deviceId, segId, inPort, host.mac(),
- appId, Objective.Operation.REMOVE);
- localTunnelPorts
- .forEach(tp -> programTunnelIn(deviceId,
- segId,
- tp, inPort, host.mac(),
- appId, Objective.Operation.REMOVE));
- }
-
- private class InnerDeviceListener implements DeviceListener {
-
- @Override
- public void event(DeviceEvent event) {
- Device device = event.subject();
- if (Device.Type.CONTROLLER == device.type()
- && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> onServerDetected(device));
- } else if (Device.Type.CONTROLLER == device.type()
- && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
- .type()) {
- backgroundService.execute(() -> onServerVanished(device));
- } else if (Device.Type.SWITCH == device.type()
- && DeviceEvent.Type.DEVICE_ADDED == event.type()) {
- backgroundService.execute(() -> onOvsDetected(device));
- } else if (Device.Type.SWITCH == device.type()
- && DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED == event
- .type()) {
- backgroundService.execute(() -> onOvsVanished(device));
- } else {
- log.info("Do nothing for this device type");
- }
- }
-
- }
-
- private class InnerHostListener implements HostListener {
-
- @Override
- public void event(HostEvent event) {
- Host host = event.subject();
- if (HostEvent.Type.HOST_ADDED == event.type()) {
- backgroundService.execute(() -> onHostDetected(host));
- } else if (HostEvent.Type.HOST_REMOVED == event.type()) {
- backgroundService.execute(() -> onHostVanished(host));
- } else if (HostEvent.Type.HOST_UPDATED == event.type()) {
- backgroundService.execute(() -> {
- onHostVanished(host);
- onHostDetected(host);
- });
- }
- }
-
- }
-
- // Used to forward the flows to the local VM.
- private void programLocalOut(DeviceId dpid, SegmentationId segmentationId,
- PortNumber outPort, MacAddress sourceMac,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchTunnelId(Long.parseLong(segmentationId.toString()))
- .matchEthDst(sourceMac).build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(outPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
-
- }
-
- // Used to forward the flows into the VXLAN tunnel.
- private void programTunnelOut(DeviceId dpid, SegmentationId segmentationId,
- PortNumber tunnelOutPort, MacAddress dstMac,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchEthDst(dstMac).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder()
-
- .setOutput(tunnelOutPort).build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).withFlag(Flag.SPECIFIC)
- .withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
-
- }
-
- // Used to forward multicast flows to remote VMs of the same tenant via
- // VXLAN tunnel.
- private void programTunnelFloodOut(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber ofPortOut,
- List<PortNumber> localVmPorts,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(ofPortOut)
-
- .add(Criteria.matchTunnelId(Long.parseLong(segmentationId
- .toString()))).matchEthDst(MacAddress.BROADCAST)
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
-
- for (PortNumber outPort : localVmPorts) {
- treatment.setOutput(outPort);
- }
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(deviceId, objective.add());
- } else {
- flowServiceForward(deviceId, objective.remove());
- }
- }
-
- // Applies default flows to mac table.
- private void programMacDefaultRules(DeviceId dpid, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder().build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().drop()
- .build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(DEFAULT_MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to forward the flows to the local VMs with the same tenant.
- private void programLocalBcastRules(DeviceId deviceId,
- SegmentationId segmentationId,
- PortNumber inPort,
- List<PortNumber> localVmPorts,
- List<PortNumber> localTunnelPorts,
- ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthDst(MacAddress.BROADCAST)
- .add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- for (PortNumber outPort : localVmPorts) {
- if (inPort != outPort) {
- treatment.setOutput(outPort);
- }
- }
- for (PortNumber outport : localTunnelPorts) {
- treatment.setOutput(outport);
- }
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(MAC_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(deviceId, objective.add());
- } else {
- flowServiceForward(deviceId, objective.remove());
- }
- }
-
- // Used to apply local entry flow.
- private void programLocalIn(DeviceId dpid, SegmentationId segmentationId,
- PortNumber inPort, MacAddress srcMac,
- ApplicationId appid, Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(inPort).matchEthSrc(srcMac).build();
- TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
- treatment.add(Instructions.modTunnelId(Long.parseLong(segmentationId
- .toString())));
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment.build())
- .withSelector(selector).fromApp(appId).makePermanent()
- .withFlag(Flag.SPECIFIC).withPriority(PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to forward the flows from the egress tunnel to the VM.
- private void programTunnelIn(DeviceId dpid, SegmentationId segmentationId,
- PortNumber tunnelInPort, PortNumber outPort,
- MacAddress sourceMac, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(tunnelInPort).add(Criteria.matchTunnelId(Long
- .parseLong(segmentationId.toString())))
- .build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
-
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Applies the default flows to port table.
- private void programPortDefaultRules(DeviceId dpid, ApplicationId appid,
- Objective.Operation type) {
- TrafficSelector selector = DefaultTrafficSelector.builder().build();
- TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
- ForwardingObjective.Builder objective = DefaultForwardingObjective
- .builder().withTreatment(treatment).withSelector(selector)
- .fromApp(appId).makePermanent().withFlag(Flag.SPECIFIC)
- .withPriority(DEFAULT_PORT_PRIORITY);
- if (type.equals(Objective.Operation.ADD)) {
- flowServiceForward(dpid, objective.add());
- } else {
- flowServiceForward(dpid, objective.remove());
- }
- }
-
- // Used to get channelId from the device annotations.
- private String getControllerIpOfSwitch(DeviceId deviceId) {
- Device device = deviceService.getDevice(deviceId);
- String url = device.annotations().value(SWITCH_CHANNEL_ID);
- return url.substring(0, url.lastIndexOf(":"));
- }
-
- private Iterable<String> getIfaceIds(String ifaceId) {
- VirtualPortId portId = VirtualPortId.portId(ifaceId);
- VirtualPort port = virtualPortService.getPort(portId);
- TenantNetwork network = tenantNetworkService
- .getNetwork(port.networkId());
- Collection<String> ifaceIds = new HashSet<>();
- Collection<VirtualPort> ports = virtualPortService
- .getPorts(network.id());
- Sets.newHashSet(ports).stream()
- .forEach(p -> ifaceIds.add(p.portId().portId()));
- return ifaceIds;
- }
-
- private List<PortNumber> getLocalPorts(DeviceId deviceId, String ifaceId) {
- DriverHandler handler = driverService
- .createHandler(getController(deviceId));
- BridgeConfig bridgeConfig = handler.behaviour(BridgeConfig.class);
- Iterable<String> ifaceIds = getIfaceIds(ifaceId);
- return bridgeConfig.getLocalPorts(ifaceIds);
- }
-
- private DeviceId getController(DeviceId deviceId) {
- Iterable<Device> devices = deviceService.getAvailableDevices();
- for (Device device : devices) {
- if (device.type() == Device.Type.CONTROLLER && device.id()
- .toString().contains(getControllerIpOfSwitch(deviceId))) {
- return device.id();
- }
- }
- log.info("Can not find controller for device : {}", deviceId);
- return null;
- }
-
- //Used to apply flowRule
- private void flowServiceForward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
- Driver driver = driverService.getDriver(DRIVER_NAME);
- Pipeliner pipeLiner = driver.createBehaviour(new DefaultDriverData(driver, deviceId), Pipeliner.class);
- if (pipeLiner != null) {
- final PipelinerContext context = new InnerPipelineContext();
- pipeLiner.init(deviceId, context);
- pipeLiner.forward(forwardingObjective);
- }
- }
-
- // Processing context for initializing pipeline driver behaviours.
- private class InnerPipelineContext implements PipelinerContext {
- @Override
- public ServiceDirectory directory() {
- return serviceDirectory;
- }
-
- @Override
- public FlowObjectiveStore store() {
- return flowObjectiveStore;
- }
- }
-
-}
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java
deleted file mode 100644
index f18dbf8a..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn.impl;
diff --git a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java b/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java
deleted file mode 100644
index 371466c3..00000000
--- a/framework/src/onos/apps/vtn/src/main/java/org/onosproject/vtn/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN application that applies configuration and flows to the device.
- */
-package org.onosproject.vtn;
diff --git a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
index deb9ca37..251dcffc 100644
--- a/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
+++ b/framework/src/onos/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
@@ -69,8 +69,8 @@ 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 not found";
+ public static final String SUBNET_NOT_CREATED = "Subnet failed to create!";
+ public static final String SUBNET_NOT_FOUND = "Subnet is not found";
public static final String JSON_NOT_NULL = "JsonNode can not be null";
@GET
@@ -111,11 +111,11 @@ public class SubnetWebResource extends AbstractWebResource {
Iterable<Subnet> subnets = createOrUpdateByInputStream(subnode);
Boolean result = nullIsNotFound((get(SubnetService.class)
.createSubnets(subnets)),
- SUBNET_NOT_CREATE);
+ SUBNET_NOT_CREATED);
if (!result) {
return Response.status(INTERNAL_SERVER_ERROR)
- .entity(SUBNET_NOT_CREATE).build();
+ .entity(SUBNET_NOT_CREATED).build();
}
return Response.status(202).entity(result.toString()).build();
} catch (Exception e) {
diff --git a/framework/src/onos/apps/vtnrsc/pom.xml b/framework/src/onos/apps/vtnrsc/pom.xml
deleted file mode 100644
index 0874f6d9..00000000
--- a/framework/src/onos/apps/vtnrsc/pom.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?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.4.0-SNAPSHOT</version>
- <relativePath>../pom.xml</relativePath>
- </parent>
-
-
- <artifactId>onos-app-vtnrsc</artifactId>
- <packaging>bundle</packaging>
-
- <properties>
- <onos.app.name>org.onosproject.vtnrsc</onos.app.name>
- </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-cli</artifactId>
- <version>${project.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.scr.annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.karaf.shell</groupId>
- <artifactId>org.apache.karaf.shell.console</artifactId>
- </dependency>
- <dependency>
- <groupId>org.onosproject</groupId>
- <artifactId>onlab-junit</artifactId>
- <version>${project.version}</version>
- </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/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
deleted file mode 100644
index 3d6ba8e8..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllocationPool.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 4e1028d8..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/AllowedAddressPair.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index c715d08a..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/BindingHostId.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 8a480194..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultAllocationPool.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 8679100d..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultHostRoute.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 6049b558..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultSubnet.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 8c941ea2..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultTenantNetwork.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 9ee85da7..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultVirtualPort.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index c6569a7b..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/FixedIp.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index b18cb950..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/HostRoute.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index e96e666a..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/PhysicalNetwork.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 9ec1dc63..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SecurityGroup.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index a076265f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SegmentationId.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index f563a78f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/Subnet.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 4bcc3329..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/SubnetId.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index c4d99e49..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantId.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 256352f4..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetwork.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-/**
- * 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
deleted file mode 100644
index fbb9e480..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/TenantNetworkId.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index d2d7c146..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPort.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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
deleted file mode 100644
index 3038bdff..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/VirtualPortId.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc;
-
-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/TenantNetworkCreateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java
deleted file mode 100644
index bcfdacfa..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkCreateCommand.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-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 com.google.common.collect.Sets;
-
-/**
- * Supports for creating a TenantNetwork.
- */
-@Command(scope = "onos", name = "tenantnetwork-create",
- description = "Supports for creating a TenantNetwork")
-public class TenantNetworkCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
- required = true, multiValued = false)
- String tenantID = null;
-
- @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
- multiValued = false)
- String type = null;
-
- @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
- required = true, multiValued = false)
- String segmentationID = "";
-
- @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
- multiValued = false)
- String name = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
- required = false, multiValued = false)
- boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
- required = false, multiValued = false)
- String state = null;
-
- @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-r", aliases = "--routerExternal",
- description = "TenantNetwork is routerExternal or not", required = false,
- multiValued = false)
- boolean routerExternal = false;
-
- @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
- required = false, multiValued = false)
- String physicalNetwork = "";
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- shared, TenantId.tenantId(tenantID),
- routerExternal,
- TenantNetwork.Type.valueOf(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet(network);
- service.createNetworks(networksSet);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java
deleted file mode 100644
index 47ea83c2..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkQueryCommand.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.TenantNetwork;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-/**
- * Supports for querying TenantNetworks by network id.
- */
-@Command(scope = "onos", name = "tenantnetworks", description = "Supports for querying"
- + "tenantNetworks by networkid")
-public class TenantNetworkQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--id", description = "TenantNetwork id", required = false,
- multiValued = false)
- String id = null;
-
- private static final String FMT = "networkId=%s, networkName=%s, segmentationId=%s,"
- + "tenantId=%s, type=%s, adminStateUp=%s";
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- if (id != null) {
- TenantNetwork network = service.getNetwork(TenantNetworkId.networkId(id));
- printNetwork(network);
- } else {
- Iterable<TenantNetwork> networks = service.getNetworks();
- for (TenantNetwork network : networks) {
- printNetwork(network);
- }
- }
- }
-
- private void printNetwork(TenantNetwork network) {
- if (network == null) {
- return;
- }
- print(FMT, network.id(), network.name(), network.segmentationId(),
- network.tenantId(), network.type(), network.adminStateUp());
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java
deleted file mode 100644
index 0ea22853..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkRemoveCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.tenantnetwork.TenantNetworkService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a TenantNetwork by network id.
- */
-@Command(scope = "onos", name = "tenantnetwork-remove", description = "Supports for removing"
- + " a tenantNetwork by tenantNetworkid")
-public class TenantNetworkRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork neutronNetwork Id",
- required = true, multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- Set<TenantNetworkId> networkIds = Sets.newHashSet(TenantNetworkId.networkId(id));
- service.removeNetworks(networkIds);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java
deleted file mode 100644
index 2a738f72..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/TenantNetworkUpdateCommand.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.network;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-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 com.google.common.collect.Sets;
-
-/**
- * Supports for updating a TenantNetwork.
- */
-@Command(scope = "onos", name = "tenantnetwork-update",
- description = "Supports for updating a TenantNetwork")
-public class TenantNetworkUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "TenantNetwork network id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "tenantID", description = "The tenant id of TenantNetwork",
- required = true, multiValued = false)
- String tenantID = null;
-
- @Argument(index = 2, name = "type", description = "The type of TenantNetwork", required = true,
- multiValued = false)
- String type = null;
-
- @Argument(index = 3, name = "segmentationID", description = "The segmentation id of TenantNetwork",
- required = true, multiValued = false)
- String segmentationID = "";
-
- @Option(name = "-n", aliases = "--name", description = "TenantNetwork name", required = false,
- multiValued = false)
- String name = null;
-
- @Option(name = "-a", aliases = "--adminStateUp", description = "TenantNetwork adminStateUp is true or false",
- required = false, multiValued = false)
- boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "The state of TenantNetwork",
- required = false, multiValued = false)
- String state = null;
-
- @Option(name = "-d", aliases = "--shared", description = "TenantNetwork is shared or not",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-r", aliases = "--routerExternal",
- description = "TenantNetwork is routerExternal or not", required = false,
- multiValued = false)
- boolean routerExternal = false;
-
- @Option(name = "-p", aliases = "--physicalNetwork", description = "The physical network of Tenant",
- required = false, multiValued = false)
- String physicalNetwork = "";
-
- @Override
- protected void execute() {
- TenantNetworkService service = get(TenantNetworkService.class);
- TenantNetwork network = new DefaultTenantNetwork(TenantNetworkId.networkId(id), name,
- adminStateUp,
- TenantNetwork.State.valueOf(state),
- shared, TenantId.tenantId(tenantID),
- routerExternal,
- TenantNetwork.Type.valueOf(type),
- PhysicalNetwork.physicalNetwork(physicalNetwork),
- SegmentationId.segmentationId(segmentationID));
-
- Set<TenantNetwork> networksSet = Sets.newHashSet();
- networksSet.add(network);
- service.updateNetworks(networksSet);
- }
-
-}
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
deleted file mode 100644
index 1622c800..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/network/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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/SubnetCreateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java
deleted file mode 100644
index 56236408..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetCreateCommand.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a subnet.
- */
-@Command(scope = "onos", name = "subnet-create", description = "Supports for creating a subnet")
-public class SubnetCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet Id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "subnetName", description = "Subnet String name", required = true,
- multiValued = false)
- String subnetName = null;
-
- @Argument(index = 2, name = "networkId", description = "Subnet Network Id", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 3, name = "tenantId", description = "Subnet Tenant Id", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Option(name = "-i", aliases = "--ipVersion", description = "Subnet Version ipVersion",
- required = false, multiValued = false)
- Version ipVersion = null;
-
- @Option(name = "-c", aliases = "--cidr", description = "Subnet IpPrefix cidr",
- required = false, multiValued = false)
- String cidr = "0.0.0.0/0";
-
- @Option(name = "-g", aliases = "--gatewayIp", description = "Subnet IpAddress gatewayIp",
- required = false, multiValued = false)
- String gatewayIp = "0.0.0.0";
-
- @Option(name = "-d", aliases = "--dhcpEnabled", description = "Subnet boolean dhcpEnabled",
- required = false, multiValued = false)
- boolean dhcpEnabled = false;
-
- @Option(name = "-s", aliases = "--shared", description = "Subnet boolean shared",
- required = false, multiValued = false)
- boolean shared = false;
-
- @Option(name = "-m", aliases = "--ipV6AddressMode",
- description = "Subnet Mode ipV6AddressMode", required = false, multiValued = false)
- String ipV6AddressMode = null;
-
- @Option(name = "-r", aliases = "--ipV6RaMode", description = "Subnet Mode ipV6RaMode",
- required = false, multiValued = false)
- String ipV6RaMode = null;
-
- @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
- required = false, multiValued = false)
- Set<HostRoute> hostRoutes = Sets.newHashSet();
-
- @Option(name = "-a", aliases = "--allocationPools",
- description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- if (id == null || networkId == null || tenantId == null) {
- print(null, "id,networkId,tenantId can not be null");
- return;
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- TenantNetworkId.networkId(networkId),
- TenantId.tenantId(tenantId), ipVersion,
- cidr == null ? null : IpPrefix.valueOf(cidr),
- gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
- dhcpEnabled, shared, hostRoutes,
- ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
- ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
- allocationPools);
-
- Set<Subnet> subnetsSet = Sets.newHashSet(subnet);
- service.createSubnets(subnetsSet);
- }
-
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java
deleted file mode 100644
index f5a94f0f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetQueryCommand.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-/**
- * Supports for querying a subnet.
- */
-@Command(scope = "onos", name = "subnets", description = "Supports for querying a subnet")
-public class SubnetQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-i", aliases = "--id", description = "Subnet id", required = false,
- multiValued = false)
- String id = null;
-
- private static final String FMT = "subnetId=%s, networkId=%s, subnetName=%s,"
- + "tenantId=%s, cidr=%s, dhcpEnabled=%s, gatewayIp=%s," + "ipVersion=%s";
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- if (id != null) {
- Subnet subnet = service.getSubnet(SubnetId.subnetId(id));
- printSubnet(subnet);
- } else {
- Iterable<Subnet> subnets = service.getSubnets();
- if (subnets == null) {
- return;
- }
- for (Subnet subnet : subnets) {
- printSubnet(subnet);
- }
- }
- }
-
- private void printSubnet(Subnet subnet) {
- print(FMT, subnet.id(), subnet.networkId(), subnet.subnetName(),
- subnet.tenantId(), subnet.cidr(), subnet.dhcpEnabled(), subnet
- .gatewayIp(), subnet.ipVersion());
-
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java
deleted file mode 100644
index 241af87e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetRemoveCommand.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a subnet.
- */
-@Command(scope = "onos", name = "subnet-remove", description = "Supports for removing a subnet")
-public class SubnetRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet SubnetId Id", required = true,
- multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- Set<SubnetId> subnetsSet = Sets.newHashSet();
- subnetsSet.add(SubnetId.subnetId(id));
- service.removeSubnets(subnetsSet);
- }
-
-}
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
deleted file mode 100644
index b0578a1e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/SubnetUpdateCommand.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.subnet;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.IpAddress;
-import org.onlab.packet.IpAddress.Version;
-import org.onlab.packet.IpPrefix;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.AllocationPool;
-import org.onosproject.vtnrsc.DefaultSubnet;
-import org.onosproject.vtnrsc.HostRoute;
-import org.onosproject.vtnrsc.Subnet;
-import org.onosproject.vtnrsc.Subnet.Mode;
-import org.onosproject.vtnrsc.SubnetId;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.subnet.SubnetService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a subnet.
- */
-@Command(scope = "onos", name = "subnet-update", description = "Supports for updating a subnet")
-public class SubnetUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "Subnet Id", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "subnetName", description = "Subnet String name", required = true,
- multiValued = false)
- String subnetName = null;
-
- @Argument(index = 2, name = "networkId", description = "Subnet Network Id", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 3, name = "tenantId", description = "Subnet Tenant Id", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Option(name = "-i", aliases = "--ipVersion", description = "Subnet Version ipVersion",
- required = false, multiValued = false)
- Version ipVersion = null;
-
- @Option(name = "-c", aliases = "--cidr", description = "Subnet IpPrefix cidr", required = false,
- multiValued = false)
- String cidr = "0.0.0.0/0";
-
- @Option(name = "-g", aliases = "--gatewayIp", description = "Subnet IpAddress gatewayIp",
- required = false, multiValued = false)
- String gatewayIp = "0.0.0.0";
-
- @Option(name = "-d", aliases = "--dhcpEnabled", description = "Subnet boolean dhcpEnabled",
- required = false, multiValued = false)
- boolean dhcpEnabled = false;
-
- @Option(name = "-s", aliases = "--shared", description = "Subnet boolean shared", required = false,
- multiValued = false)
- boolean shared = false;
-
- @Option(name = "-m", aliases = "--ipV6AddressMode", description = "Subnet Mode ipV6AddressMode",
- required = false, multiValued = false)
- String ipV6AddressMode = null;
-
- @Option(name = "-r", aliases = "--ipV6RaMode", description = "Subnet Mode ipV6RaMode",
- required = false, multiValued = false)
- String ipV6RaMode = null;
-
- @Option(name = "-h", aliases = "--hostRoutes", description = "Subnet jsonnode hostRoutes",
- required = false, multiValued = false)
- Set<HostRoute> hostRoutes = Sets.newHashSet();
-
- @Option(name = "-a", aliases = "--allocationPools",
- description = "Subnet jsonnode allocationPools", required = false, multiValued = false)
- Set<AllocationPool> allocationPools = Sets.newHashSet();
-
- @Override
- protected void execute() {
- SubnetService service = get(SubnetService.class);
- if (id == null || networkId == null || tenantId == null) {
- print(null, "id,networkId,tenantId can not be null");
- return;
- }
- Subnet subnet = new DefaultSubnet(SubnetId.subnetId(id), subnetName,
- TenantNetworkId.networkId(networkId),
- TenantId.tenantId(tenantId), ipVersion,
- cidr == null ? null : IpPrefix.valueOf(cidr),
- gatewayIp == null ? null : IpAddress.valueOf(gatewayIp),
- dhcpEnabled, shared, hostRoutes,
- ipV6AddressMode == null ? null : Mode.valueOf(ipV6AddressMode),
- ipV6RaMode == null ? null : Mode.valueOf(ipV6RaMode),
- allocationPools);
- Set<Subnet> subnetsSet = Sets.newHashSet();
- subnetsSet.add(subnet);
- service.updateSubnets(subnetsSet);
- }
-
-}
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
deleted file mode 100644
index b3a2ff51..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/subnet/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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/VirtualPortCreateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java
deleted file mode 100644
index 4c555e33..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortCreateCommand.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for creating a virtualPort.
- */
-@Command(scope = "onos", name = "virtualport-create",
- description = "Supports for creating a virtualPort.")
-public class VirtualPortCreateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "network id.", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "name", description = "virtualPort name.", required = true,
- multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "tenantId", description = "tenant id.", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Argument(index = 4, name = "deviceId", description = "device id.", required = true,
- multiValued = false)
- String deviceId = null;
-
- @Option(name = "-a", aliases = "--adminStateUp",
- description = "administrative status of the virtualPort which is true or false.",
- required = false, multiValued = false)
- Boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "virtualPort state.", required = false,
- multiValued = false)
- String state = null;
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = false,
- multiValued = false)
- String macAddress = "";
-
- @Option(name = "-d", aliases = "--deviceOwner", description = "ID of the entity that uses this "
- + "virtualPort.", required = false, multiValued = false)
- String deviceOwner = null;
-
- @Option(name = "-f", aliases = "--fixedIp",
- description = "The IP address for the port,include the IP address "
- + "and subnet identity.", required = false, multiValued = false)
- FixedIp fixedIp = null;
-
- @Option(name = "-i", aliases = "--bindingHostId", description = "virtualPort bindingHostId.",
- required = false, multiValued = false)
- String bindingHostId = null;
-
- @Option(name = "-t", aliases = "--bindingvnicType", description = "virtualPort bindingvnicType.",
- required = false, multiValued = false)
- String bindingvnicType = null;
-
- @Option(name = "-v", aliases = "--bindingvifType", description = "virtualPort bindingvifType.",
- required = false, multiValued = false)
- String bindingvifType = null;
-
- @Option(name = "-b", aliases = "--bindingvnicDetails",
- description = "virtualPort bindingvnicDetails.", required = false, multiValued = false)
- String bindingvnicDetails = null;
-
- @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
- required = false, multiValued = false)
- Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
-
- @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
- required = false, multiValued = false)
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- @Override
- protected void execute() {
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", name);
- strMap.putIfAbsent("deviceOwner", deviceOwner);
- strMap.putIfAbsent("bindingvnicType", bindingvnicType);
- strMap.putIfAbsent("bindingvifType", bindingvifType);
- strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
- VirtualPortService service = get(VirtualPortService.class);
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
- TenantNetworkId.networkId(networkId),
- false, strMap, VirtualPort.State.ACTIVE,
- MacAddress.valueOf(macAddress),
- TenantId.tenantId(tenantId),
- DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
- BindingHostId.bindingHostId(bindingHostId),
- allowedAddressPairs, securityGroups);
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.createPorts(virtualPorts);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java
deleted file mode 100644
index 47126d1b..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortQueryCommand.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Collection;
-
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-/**
- * Supports for querying virtualPorts.
- */
-@Command(scope = "onos", name = "virtualports", description = "Supports for querying virtualPorts.")
-public class VirtualPortQueryCommand extends AbstractShellCommand {
-
- @Option(name = "-v", aliases = "--vPortId", description = "virtualPort ID.", required = false,
- multiValued = false)
- String vPortId;
-
- @Option(name = "-n", aliases = "--networkId", description = "network ID.", required = false,
- multiValued = false)
- String networkId;
-
- @Option(name = "-d", aliases = "--deviceId", description = "device ID.", required = false,
- multiValued = false)
- String deviceId;
-
- @Option(name = "-t", aliases = "--tenantId", description = "tenant ID.", required = false,
- multiValued = false)
- String tenantId;
-
- private static final String FMT = "virtualPortId=%s, networkId=%s, name=%s,"
- + " tenantId=%s, deviceId=%s, adminStateUp=%s, state=%s,"
- + " macAddress=%s, deviceOwner=%s, fixedIp=%s, bindingHostId=%s,"
- + " bindingvnicType=%s, bindingvifType=%s, bindingvnicDetails=%s,"
- + " allowedAddress=%s, securityGroups=%s";
-
- @Override
- protected void execute() {
- VirtualPortService service = get(VirtualPortService.class);
- if (vPortId != null && networkId == null && deviceId == null && tenantId == null) {
- VirtualPort port = service.getPort(VirtualPortId.portId(vPortId));
- printPort(port);
- } else if (vPortId == null && networkId != null && deviceId == null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts(TenantNetworkId.networkId(networkId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId != null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts(DeviceId.deviceId(deviceId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId == null && tenantId != null) {
- Collection<VirtualPort> ports = service.getPorts(DeviceId.deviceId(tenantId));
- printPorts(ports);
- } else if (vPortId == null && networkId == null && deviceId == null && tenantId == null) {
- Collection<VirtualPort> ports = service.getPorts();
- printPorts(ports);
- } else {
- print("cannot input more than one parameter");
- }
-
- }
-
- private void printPorts(Collection<VirtualPort> ports) {
- for (VirtualPort port : ports) {
- printPort(port);
- }
- }
-
- private void printPort(VirtualPort port) {
- print(FMT, port.portId(), port.networkId(), port.name(), port.tenantId(), port.deviceId(),
- port.adminStateUp(), port.state(), port.macAddress(), port.deviceOwner(), port
- .fixedIps(), port.bindingHostId(), port.bindingVnicType(),
- port.bindingVifType(), port.bindingVifDetails(), port.allowedAddressPairs(),
- port.securityGroups());
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java
deleted file mode 100644
index 1a3cb4f0..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortRemoveCommand.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Sets;
-
-/**
- * Supports for removing a virtualPort.
- */
-@Command(scope = "onos", name = "virtualport-remove",
- description = "Supports for removing a virtualPort.")
-public class VirtualPortRemoveCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Override
- protected void execute() {
- VirtualPortService service = get(VirtualPortService.class);
- Set<VirtualPortId> virtualPorts = Sets.newHashSet(VirtualPortId.portId(id));
- service.removePorts(virtualPorts);
- }
-}
diff --git a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java
deleted file mode 100644
index 6df4b23c..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/VirtualPortUpdateCommand.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.cli.virtualport;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.apache.karaf.shell.commands.Option;
-import org.onlab.packet.MacAddress;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.vtnrsc.AllowedAddressPair;
-import org.onosproject.vtnrsc.BindingHostId;
-import org.onosproject.vtnrsc.DefaultVirtualPort;
-import org.onosproject.vtnrsc.FixedIp;
-import org.onosproject.vtnrsc.SecurityGroup;
-import org.onosproject.vtnrsc.TenantId;
-import org.onosproject.vtnrsc.TenantNetworkId;
-import org.onosproject.vtnrsc.VirtualPort;
-import org.onosproject.vtnrsc.VirtualPortId;
-import org.onosproject.vtnrsc.virtualport.VirtualPortService;
-
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-
-/**
- * Supports for updating a virtualPort.
- */
-@Command(scope = "onos", name = "virtualport-update",
- description = "Supports for updating a virtualPort.")
-public class VirtualPortUpdateCommand extends AbstractShellCommand {
-
- @Argument(index = 0, name = "id", description = "virtualPort id.", required = true,
- multiValued = false)
- String id = null;
-
- @Argument(index = 1, name = "networkId", description = "network id.", required = true,
- multiValued = false)
- String networkId = null;
-
- @Argument(index = 2, name = "name", description = "virtualPort name.", required = true,
- multiValued = false)
- String name = null;
-
- @Argument(index = 3, name = "tenantId", description = "tenant id.", required = true,
- multiValued = false)
- String tenantId = null;
-
- @Argument(index = 4, name = "deviceId", description = "device id.", required = true,
- multiValued = false)
- String deviceId = null;
-
- @Option(name = "-a", aliases = "--adminStateUp",
- description = "administrative status of the virtualPort which is true or false.",
- required = false, multiValued = false)
- Boolean adminStateUp = false;
-
- @Option(name = "-s", aliases = "--state", description = "virtualPort state.", required = false,
- multiValued = false)
- String state = null;
-
- @Option(name = "-m", aliases = "--macAddress", description = "MAC address.", required = false,
- multiValued = false)
- String macAddress = "";
-
- @Option(name = "-d", aliases = "--deviceOwner",
- description = "ID of the entity that uses this " + "virtualPort.", required = false,
- multiValued = false)
- String deviceOwner = null;
-
- @Option(name = "-f", aliases = "--fixedIp",
- description = "The IP address for the port,include the IP address "
- + "and subnet identity.", required = false, multiValued = false)
- FixedIp fixedIp = null;
-
- @Option(name = "-i", aliases = "--bindingHostId", description = "virtualPort bindingHostId.",
- required = false, multiValued = false)
- String bindingHostId = "";
-
- @Option(name = "-t", aliases = "--bindingvnicType",
- description = "virtualPort bindingvnicType.", required = false, multiValued = false)
- String bindingvnicType = null;
-
- @Option(name = "-v", aliases = "--bindingvifType", description = "virtualPort bindingvifType.",
- required = false, multiValued = false)
- String bindingvifType = null;
-
- @Option(name = "-b", aliases = "--bindingvnicDetails",
- description = "virtualPort bindingvnicDetails.", required = false, multiValued = false)
- String bindingvnicDetails = null;
-
- @Option(name = "-l", aliases = "--allowedAddress", description = "virtual allowedAddressPair.",
- required = false, multiValued = false)
- Set<AllowedAddressPair> allowedAddressPairs = Sets.newHashSet();
-
- @Option(name = "-e", aliases = "--securityGroups", description = "virtualPort securityGroups.",
- required = false, multiValued = false)
- Set<SecurityGroup> securityGroups = Sets.newHashSet();
-
- @Override
- protected void execute() {
- VirtualPortService service = get(VirtualPortService.class);
- Map<String, String> strMap = Maps.newHashMap();
- strMap.putIfAbsent("name", name);
- strMap.putIfAbsent("deviceOwner", deviceOwner);
- strMap.putIfAbsent("bindingvnicType", bindingvnicType);
- strMap.putIfAbsent("bindingvifType", bindingvifType);
- strMap.putIfAbsent("bindingvnicDetails", bindingvnicDetails);
- VirtualPort virtualPort = new DefaultVirtualPort(VirtualPortId.portId(id),
- TenantNetworkId.networkId(networkId),
- false, strMap, VirtualPort.State.ACTIVE,
- MacAddress.valueOf(macAddress),
- TenantId.tenantId(tenantId),
- DeviceId.deviceId(deviceId), Sets.newHashSet(fixedIp),
- BindingHostId.bindingHostId(bindingHostId),
- allowedAddressPairs, securityGroups);
- Set<VirtualPort> virtualPorts = Sets.newHashSet(virtualPort);
- service.updatePorts(virtualPorts);
- }
-}
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
deleted file mode 100644
index fac214a1..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/cli/virtualport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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/package-info.java b/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java
deleted file mode 100644
index b245fb14..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN resources that used by virtual tenant network.
- */
-package org.onosproject.vtnrsc;
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
deleted file mode 100644
index 82eb9611..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/SubnetService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 890beb29..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/SubnetManager.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.subnet.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
deleted file mode 100644
index 79040d8d..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 7b2bdb90..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/subnet/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with 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
deleted file mode 100644
index e246cc4e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/TenantNetworkService.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tenantnetwork;
-
-import 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
deleted file mode 100644
index 0dfc99e2..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/TenantNetworkManager.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.tenantnetwork.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
deleted file mode 100644
index f381fda6..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 1489c973..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tenantnetwork/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with 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
deleted file mode 100644
index 6f3cf653..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 3a84e6e3..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with 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
deleted file mode 100644
index 05ebccf9..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/VirtualPortService.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport;
-
-import 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
deleted file mode 100644
index bea0fd55..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.virtualport.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
deleted file mode 100644
index 24eb0d3f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * 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
deleted file mode 100644
index 06a01a04..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Service for interacting with 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
deleted file mode 100644
index 57c97c1c..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 7960808f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 96c9bb4e..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 69ca6b3f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index c2ded196..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 122b75a9..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 48ba3b97..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index e57d56bc..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.vtnrsc.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
deleted file mode 100644
index 34636a9f..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Codecs for virtual tenant objects.
- */
-package org.onosproject.vtnrsc.web;
diff --git a/framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml
deleted file mode 100644
index c6a9c81b..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-<!--
- ~ Copyright 2015 Open Networking Laboratory
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0">
-
- <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkCreateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkQueryCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.network.TenantNetworkUpdateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetCreateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetQueryCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.subnet.SubnetUpdateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortCreateCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortQueryCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortRemoveCommand"/>
- </command>
- <command>
- <action class="org.onosproject.vtnrsc.cli.virtualport.VirtualPortUpdateCommand"/>
- </command>
- </command-bundle>
-</blueprint>
diff --git a/framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml b/framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 9c0c69bb..00000000
--- a/framework/src/onos/apps/vtnrsc/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="ONOS" version="2.5">
- <display-name>Vtnrsc Routing REST API v1.0</display-name>
-
- <servlet>
- <servlet-name>JAX-RS Service</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
- <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.config.property.classnames</param-name>
- <param-value>
- org.onosproject.app.vtnrsc.web.SubnetWebResource,
- org.onosproject.app.vtnrsc.web.NeutronNetworkWebResource,
- org.onosproject.app.vtnrsc.web.VirtualPortWebResource
- </param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAX-RS Service</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
diff --git a/framework/src/onos/apps/vtnweb/pom.xml b/framework/src/onos/apps/vtnweb/pom.xml
deleted file mode 100644
index 543bcfbb..00000000
--- a/framework/src/onos/apps/vtnweb/pom.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?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.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>
-
- <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
deleted file mode 100644
index 3979e1e3..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/SubnetWebResource.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.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
deleted file mode 100644
index b3888db1..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/TenantNetworkWebResource.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.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
deleted file mode 100644
index d0b7ed2d..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/VirtualPortWebResource.java
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.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/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java b/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java
deleted file mode 100644
index c81fc3d8..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/java/org/onosproject/vtnweb/resources/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright 2015 Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * VTN web that used rest to creat vtn resources.
- */
-package org.onosproject.vtnweb.resources;
diff --git a/framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml b/framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index 4cc12455..00000000
--- a/framework/src/onos/apps/vtnweb/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~ 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.
- -->
-<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee"
- xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
- id="ONOS" version="2.5">
- <display-name>VTNRSC REST API v1.0</display-name>
-
- <servlet>
- <servlet-name>JAX-RS Service</servlet-name>
- <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
- <init-param>
- <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name>
- <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value>
- </init-param>
- <init-param>
- <param-name>com.sun.jersey.config.property.classnames</param-name>
- <param-value>
- org.onosproject.vtnweb.resources.TenantNetworkWebResource,
- org.onosproject.vtnweb.resources.SubnetWebResource,
- org.onosproject.vtnweb.resources.VirtualPortWebResource
- </param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <servlet-mapping>
- <servlet-name>JAX-RS Service</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>