aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/vtn/vtnrsc/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/onos/apps/vtn/vtnrsc/src/main')
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java413
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java201
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java198
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java183
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java259
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java91
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java148
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java95
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java139
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java126
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java95
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java95
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/FlowClassifierService.java72
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java108
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/package-info.java (renamed from framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java)4
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java80
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java80
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java20
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java72
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java40
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java40
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java40
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java40
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java134
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java40
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java39
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java53
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java47
-rw-r--r--framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java57
31 files changed, 2597 insertions, 452 deletions
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
new file mode 100644
index 00000000..39df2cff
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultFlowClassifier.java
@@ -0,0 +1,413 @@
+/*
+ * 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 org.onlab.packet.IpPrefix;
+
+import com.google.common.base.MoreObjects;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * Provides Default flow classifier.
+ */
+public final class DefaultFlowClassifier implements FlowClassifier {
+
+ private final FlowClassifierId flowClassifierId;
+ private final TenantId tenantId;
+ private final String name;
+ private final String description;
+ private final String etherType;
+ private final String protocol;
+ private final int minSrcPortRange;
+ private final int maxSrcPortRange;
+ private final int minDstPortRange;
+ private final int maxDstPortRange;
+ private final IpPrefix srcIpPrefix;
+ private final IpPrefix dstIpPrefix;
+ private final VirtualPortId srcPort;
+ private final VirtualPortId dstPort;
+ private static final int NULL_PORT = 0;
+ private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "FlowClassifier id can not be null.";
+ private static final String TENANT_ID_NOT_NULL = "Tenant id can not be null.";
+
+ /**
+ * Constructor to create default flow classifier.
+ *
+ * @param flowClassifierId flow classifier Id
+ * @param tenantId Tenant ID
+ * @param name flow classifier name
+ * @param description flow classifier description
+ * @param etherType etherType
+ * @param protocol IP protocol
+ * @param minSrcPortRange Minimum Source port range
+ * @param maxSrcPortRange Maximum Source port range
+ * @param minDstPortRange Minimum destination port range
+ * @param maxDstPortRange Maximum destination port range
+ * @param srcIpPrefix Source IP prefix
+ * @param dstIpPrefix destination IP prefix
+ * @param srcPort Source VirtualPort
+ * @param dstPort destination VirtualPort
+ */
+ private DefaultFlowClassifier(FlowClassifierId flowClassifierId, TenantId tenantId, String name,
+ String description, String etherType, String protocol, int minSrcPortRange, int maxSrcPortRange,
+ int minDstPortRange, int maxDstPortRange, IpPrefix srcIpPrefix, IpPrefix dstIpPrefix,
+ VirtualPortId srcPort, VirtualPortId dstPort) {
+ this.flowClassifierId = flowClassifierId;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.etherType = etherType;
+ this.protocol = protocol;
+ this.minSrcPortRange = minSrcPortRange;
+ this.maxSrcPortRange = maxSrcPortRange;
+ this.minDstPortRange = minDstPortRange;
+ this.maxDstPortRange = maxDstPortRange;
+ this.srcIpPrefix = srcIpPrefix;
+ this.dstIpPrefix = dstIpPrefix;
+ this.srcPort = srcPort;
+ this.dstPort = dstPort;
+ }
+
+ @Override
+ public FlowClassifierId flowClassifierId() {
+ return flowClassifierId;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public String description() {
+ return description;
+ }
+
+ @Override
+ public String etherType() {
+ return etherType;
+ }
+
+ @Override
+ public String protocol() {
+ return protocol;
+ }
+
+ @Override
+ public int minSrcPortRange() {
+ return minSrcPortRange;
+ }
+
+ @Override
+ public int maxSrcPortRange() {
+ return maxSrcPortRange;
+ }
+
+ @Override
+ public int minDstPortRange() {
+ return minDstPortRange;
+ }
+
+ @Override
+ public int maxDstPortRange() {
+ return maxDstPortRange;
+ }
+
+ @Override
+ public IpPrefix srcIpPrefix() {
+ return srcIpPrefix;
+ }
+
+ @Override
+ public IpPrefix dstIpPrefix() {
+ return dstIpPrefix;
+ }
+
+ @Override
+ public VirtualPortId srcPort() {
+ return srcPort;
+ }
+
+ @Override
+ public VirtualPortId dstPort() {
+ return dstPort;
+ }
+
+ /**
+ * Builder class for constructing Flow classifier.
+ */
+ public static class Builder implements FlowClassifier.Builder {
+
+ private FlowClassifierId flowClassifierId;
+ private TenantId tenantId;
+ private String name;
+ private boolean isFlowClassifierNameSet = false;
+ private String description;
+ private boolean isFlowClassifierDescriptionSet = false;
+ private String etherType;
+ private boolean isEtherTypeSet = false;
+ private String protocol;
+ private boolean isProtocolSet = false;
+ private int minSrcPortRange;
+ private boolean isMinSrcPortRangeSet = false;
+ private int maxSrcPortRange;
+ private boolean isMaxSrcPortRangeSet = false;
+ private int minDstPortRange;
+ private boolean isMinDstPortRangeSet = false;
+ private int maxDstPortRange;
+ private boolean isMaxDstPortRangeSet = false;
+ private IpPrefix srcIpPrefix;
+ private boolean isSrcIpPrefixSet = false;
+ private IpPrefix dstIpPrefix;
+ private boolean isDstIpPrefixSet = false;
+ private VirtualPortId srcPort;
+ private boolean isSrcPortSet = false;
+ private VirtualPortId dstPort;
+ private boolean isDstPortSet = false;
+
+ @Override
+ public FlowClassifier build() {
+
+ checkNotNull(flowClassifierId, FLOW_CLASSIFIER_ID_NOT_NULL);
+ checkNotNull(tenantId, TENANT_ID_NOT_NULL);
+ String name = null;
+ String description = null;
+ String etherType = null;
+ String protocol = null;
+ int minSrcPortRange = NULL_PORT;
+ int maxSrcPortRange = NULL_PORT;
+ int minDstPortRange = NULL_PORT;
+ int maxDstPortRange = NULL_PORT;
+ IpPrefix srcIpPrefix = null;
+ IpPrefix dstIpPrefix = null;
+ VirtualPortId srcPort = null;
+ VirtualPortId dstPort = null;
+
+ if (isFlowClassifierNameSet) {
+ name = this.name;
+ }
+ if (isFlowClassifierDescriptionSet) {
+ description = this.description;
+ }
+ if (isEtherTypeSet) {
+ etherType = this.etherType;
+ }
+ if (isProtocolSet) {
+ protocol = this.protocol;
+ }
+ if (isMinSrcPortRangeSet) {
+ minSrcPortRange = this.minSrcPortRange;
+ }
+ if (isMaxSrcPortRangeSet) {
+ maxSrcPortRange = this.maxSrcPortRange;
+ }
+ if (isMinDstPortRangeSet) {
+ minDstPortRange = this.minDstPortRange;
+ }
+ if (isMaxDstPortRangeSet) {
+ maxDstPortRange = this.maxDstPortRange;
+ }
+ if (isSrcIpPrefixSet) {
+ srcIpPrefix = this.srcIpPrefix;
+ }
+ if (isDstIpPrefixSet) {
+ dstIpPrefix = this.dstIpPrefix;
+ }
+ if (isSrcPortSet) {
+ srcPort = this.srcPort;
+ }
+ if (isDstPortSet) {
+ dstPort = this.dstPort;
+ }
+
+ return new DefaultFlowClassifier(flowClassifierId, tenantId, name, description, etherType, protocol,
+ minSrcPortRange, maxSrcPortRange, minDstPortRange, maxDstPortRange, srcIpPrefix, dstIpPrefix,
+ srcPort, dstPort);
+ }
+
+ @Override
+ public Builder setFlowClassifierId(FlowClassifierId flowClassifierId) {
+ this.flowClassifierId = flowClassifierId;
+ return this;
+ }
+
+ @Override
+ public Builder setTenantId(TenantId tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ @Override
+ public Builder setName(String name) {
+ this.name = name;
+ this.isFlowClassifierNameSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setDescription(String description) {
+ this.description = description;
+ this.isFlowClassifierDescriptionSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setEtherType(String etherType) {
+ this.etherType = etherType;
+ this.isEtherTypeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setProtocol(String protocol) {
+ this.protocol = protocol;
+ this.isProtocolSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setMinSrcPortRange(int minSrcPortRange) {
+ this.minSrcPortRange = minSrcPortRange;
+ this.isMinSrcPortRangeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setMaxSrcPortRange(int maxSrcPortRange) {
+ this.maxSrcPortRange = maxSrcPortRange;
+ this.isMaxSrcPortRangeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setMinDstPortRange(int minDstPortRange) {
+ this.minDstPortRange = minDstPortRange;
+ this.isMinDstPortRangeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setMaxDstPortRange(int maxDstPortRange) {
+ this.maxDstPortRange = maxDstPortRange;
+ this.isMaxDstPortRangeSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setSrcIpPrefix(IpPrefix srcIpPrefix) {
+ this.srcIpPrefix = srcIpPrefix;
+ this.isSrcIpPrefixSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setDstIpPrefix(IpPrefix dstIpPrefix) {
+ this.dstIpPrefix = dstIpPrefix;
+ this.isDstIpPrefixSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setSrcPort(VirtualPortId srcPort) {
+ this.srcPort = srcPort;
+ this.isSrcPortSet = true;
+ return this;
+ }
+
+ @Override
+ public Builder setDstPort(VirtualPortId dstPort) {
+ this.dstPort = dstPort;
+ this.isDstPortSet = true;
+ return this;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(flowClassifierId, tenantId, name, description, etherType, protocol, minSrcPortRange,
+ maxSrcPortRange, minDstPortRange, maxDstPortRange, srcIpPrefix, dstIpPrefix, srcPort, dstPort);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultFlowClassifier) {
+ DefaultFlowClassifier other = (DefaultFlowClassifier) obj;
+ return Objects.equals(this.flowClassifierId, other.flowClassifierId)
+ && Objects.equals(this.tenantId, other.tenantId)
+ && Objects.equals(this.name, other.name)
+ && Objects.equals(this.description, other.description)
+ && Objects.equals(this.etherType, other.etherType)
+ && Objects.equals(this.protocol, other.protocol)
+ && Objects.equals(this.minSrcPortRange, other.minSrcPortRange)
+ && Objects.equals(this.maxSrcPortRange, other.maxSrcPortRange)
+ && Objects.equals(this.minDstPortRange, other.minDstPortRange)
+ && Objects.equals(this.maxDstPortRange, other.maxDstPortRange)
+ && Objects.equals(this.srcIpPrefix, other.srcIpPrefix)
+ && Objects.equals(this.dstIpPrefix, other.dstIpPrefix)
+ && Objects.equals(this.srcPort, other.srcPort)
+ && Objects.equals(this.dstPort, other.dstPort);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean exactMatch(FlowClassifier flowClassifier) {
+ return this.equals(flowClassifier)
+ && Objects.equals(this.flowClassifierId, flowClassifier.flowClassifierId())
+ && Objects.equals(this.tenantId, flowClassifier.tenantId())
+ && Objects.equals(this.name, flowClassifier.name())
+ && Objects.equals(this.description, flowClassifier.description())
+ && Objects.equals(this.etherType, flowClassifier.etherType())
+ && Objects.equals(this.protocol, flowClassifier.protocol())
+ && Objects.equals(this.minSrcPortRange, flowClassifier.minSrcPortRange())
+ && Objects.equals(this.maxSrcPortRange, flowClassifier.maxSrcPortRange())
+ && Objects.equals(this.minDstPortRange, flowClassifier.minDstPortRange())
+ && Objects.equals(this.maxDstPortRange, flowClassifier.maxDstPortRange())
+ && Objects.equals(this.srcIpPrefix, flowClassifier.srcIpPrefix())
+ && Objects.equals(this.dstIpPrefix, flowClassifier.dstIpPrefix())
+ && Objects.equals(this.srcPort, flowClassifier.srcPort())
+ && Objects.equals(this.dstPort, flowClassifier.dstPort());
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("FlowClassifierId", flowClassifierId)
+ .add("TenantId", tenantId)
+ .add("Name", name)
+ .add("Description", description)
+ .add("String", etherType)
+ .add("Protocol", protocol)
+ .add("MinSrcPortRange", minSrcPortRange)
+ .add("MaxSrcPortRange", maxSrcPortRange)
+ .add("MinDstPortRange", minDstPortRange)
+ .add("MaxDstPortRange", maxDstPortRange)
+ .add("SrcIpPrefix", srcIpPrefix)
+ .add("DstIpPrefix", dstIpPrefix)
+ .add("SrcPort", srcPort)
+ .add("DstPort", dstPort)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
new file mode 100644
index 00000000..89b94b3e
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortChain.java
@@ -0,0 +1,201 @@
+/*
+ * 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.List;
+import java.util.Objects;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Implementation of port chain.
+ */
+public final class DefaultPortChain implements PortChain {
+
+ private final PortChainId portChainId;
+ private final TenantId tenantId;
+ private final String name;
+ private final String description;
+ private final List<PortPairGroupId> portPairGroupList;
+ private final List<FlowClassifierId> flowClassifierList;
+
+ /**
+ * Default constructor to create port chain.
+ *
+ * @param portChainId port chain id
+ * @param tenantId tenant id
+ * @param name name of port chain
+ * @param description description of port chain
+ * @param portPairGroupList port pair group list
+ * @param flowClassifierList flow classifier list
+ */
+ private DefaultPortChain(PortChainId portChainId, TenantId tenantId,
+ String name, String description,
+ List<PortPairGroupId> portPairGroupList,
+ List<FlowClassifierId> flowClassifierList) {
+
+ this.portChainId = portChainId;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.portPairGroupList = portPairGroupList;
+ this.flowClassifierList = flowClassifierList;
+ }
+
+ @Override
+ public PortChainId portChainId() {
+ return portChainId;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public String description() {
+ return description;
+ }
+
+ @Override
+ public List<PortPairGroupId> portPairGroups() {
+ return ImmutableList.copyOf(portPairGroupList);
+ }
+
+ @Override
+ public List<FlowClassifierId> flowClassifiers() {
+ return ImmutableList.copyOf(flowClassifierList);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(portChainId, tenantId, name, description,
+ portPairGroupList, flowClassifierList);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultPortChain) {
+ DefaultPortChain that = (DefaultPortChain) obj;
+ return Objects.equals(portChainId, that.portChainId) &&
+ Objects.equals(tenantId, that.tenantId) &&
+ Objects.equals(name, that.name) &&
+ Objects.equals(description, that.description) &&
+ Objects.equals(portPairGroupList, that.portPairGroupList) &&
+ Objects.equals(flowClassifierList, that.flowClassifierList);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean exactMatch(PortChain portChain) {
+ return this.equals(portChain) &&
+ Objects.equals(this.portChainId, portChain.portChainId()) &&
+ Objects.equals(this.tenantId, portChain.tenantId());
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", portChainId.toString())
+ .add("tenantId", tenantId.toString())
+ .add("name", name)
+ .add("description", description)
+ .add("portPairGroupList", portPairGroupList)
+ .add("flowClassifier", flowClassifierList)
+ .toString();
+ }
+
+ /**
+ * To create an instance of the builder.
+ *
+ * @return instance of builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder class for Port chain.
+ */
+ public static final class Builder implements PortChain.Builder {
+
+ private PortChainId portChainId;
+ private TenantId tenantId;
+ private String name;
+ private String description;
+ private List<PortPairGroupId> portPairGroupList;
+ private List<FlowClassifierId> flowClassifierList;
+
+ @Override
+ public Builder setId(PortChainId portChainId) {
+ this.portChainId = portChainId;
+ return this;
+ }
+
+ @Override
+ public Builder setTenantId(TenantId tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ @Override
+ public Builder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public Builder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ @Override
+ public Builder setPortPairGroups(List<PortPairGroupId> portPairGroups) {
+ this.portPairGroupList = portPairGroups;
+ return this;
+ }
+
+ @Override
+ public Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers) {
+ this.flowClassifierList = flowClassifiers;
+ return this;
+ }
+
+ @Override
+ public PortChain build() {
+
+ checkNotNull(portChainId, "Port chain id cannot be null");
+ checkNotNull(tenantId, "Tenant id cannot be null");
+ checkNotNull(portPairGroupList, "Port pair groups cannot be null");
+
+ return new DefaultPortChain(portChainId, tenantId, name, description,
+ portPairGroupList, flowClassifierList);
+ }
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java
new file mode 100644
index 00000000..4b3b7cf3
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPair.java
@@ -0,0 +1,198 @@
+/*
+ * 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;
+
+/**
+ * Implementation of port pair.
+ */
+public final class DefaultPortPair implements PortPair {
+
+ private final PortPairId portPairId;
+ private final TenantId tenantId;
+ private final String name;
+ private final String description;
+ private final String ingress;
+ private final String egress;
+
+ /**
+ * Default constructor to create Port Pair.
+ *
+ * @param portPairId port pair id
+ * @param tenantId tenant id
+ * @param name name of port pair
+ * @param description description of port pair
+ * @param ingress ingress port
+ * @param egress egress port
+ */
+ private DefaultPortPair(PortPairId portPairId, TenantId tenantId,
+ String name, String description,
+ String ingress, String egress) {
+
+ this.portPairId = portPairId;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.ingress = ingress;
+ this.egress = egress;
+ }
+
+ @Override
+ public PortPairId portPairId() {
+ return portPairId;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public String description() {
+ return description;
+ }
+
+ @Override
+ public String ingress() {
+ return ingress;
+ }
+
+ @Override
+ public String egress() {
+ return egress;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(portPairId, tenantId, name, description,
+ ingress, egress);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultPortPair) {
+ DefaultPortPair that = (DefaultPortPair) obj;
+ return Objects.equals(portPairId, that.portPairId) &&
+ Objects.equals(tenantId, that.tenantId) &&
+ Objects.equals(name, that.name) &&
+ Objects.equals(description, that.description) &&
+ Objects.equals(ingress, that.ingress) &&
+ Objects.equals(egress, that.egress);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean exactMatch(PortPair portPair) {
+ return this.equals(portPair) &&
+ Objects.equals(this.portPairId, portPair.portPairId()) &&
+ Objects.equals(this.tenantId, portPair.tenantId());
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", portPairId.toString())
+ .add("tenantId", tenantId.tenantId())
+ .add("name", name)
+ .add("description", description)
+ .add("ingress", ingress)
+ .add("egress", egress)
+ .toString();
+ }
+
+ /**
+ * To create an instance of the builder.
+ *
+ * @return instance of builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder class for Port pair.
+ */
+ public static final class Builder implements PortPair.Builder {
+
+ private PortPairId portPairId;
+ private TenantId tenantId;
+ private String name;
+ private String description;
+ private String ingress;
+ private String egress;
+
+ @Override
+ public Builder setId(PortPairId portPairId) {
+ this.portPairId = portPairId;
+ return this;
+ }
+
+ @Override
+ public Builder setTenantId(TenantId tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ @Override
+ public Builder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public Builder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ @Override
+ public Builder setIngress(String ingress) {
+ this.ingress = ingress;
+ return this;
+ }
+
+ @Override
+ public Builder setEgress(String egress) {
+ this.egress = egress;
+ return this;
+ }
+
+ @Override
+ public PortPair build() {
+
+ checkNotNull(portPairId, "Port pair id cannot be null");
+ checkNotNull(tenantId, "Tenant id cannot be null");
+ checkNotNull(ingress, "Ingress of a port pair cannot be null");
+ checkNotNull(egress, "Egress of a port pair cannot be null");
+
+ return new DefaultPortPair(portPairId, tenantId, name, description,
+ ingress, egress);
+ }
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java
new file mode 100644
index 00000000..877cc6c9
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/DefaultPortPairGroup.java
@@ -0,0 +1,183 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.List;
+import java.util.Objects;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Implementation of port pair group.
+ */
+public final class DefaultPortPairGroup implements PortPairGroup {
+
+ private final PortPairGroupId portPairGroupId;
+ private final TenantId tenantId;
+ private final String name;
+ private final String description;
+ private final List<PortPairId> portPairList;
+
+ /**
+ * Default constructor to create Port Pair Group.
+ *
+ * @param portPairGroupId port pair group id
+ * @param tenantId tenant id
+ * @param name name of port pair group
+ * @param description description of port pair group
+ * @param portPairList list of port pairs
+ */
+ private DefaultPortPairGroup(PortPairGroupId portPairGroupId, TenantId tenantId,
+ String name, String description,
+ List<PortPairId> portPairList) {
+
+ this.portPairGroupId = portPairGroupId;
+ this.tenantId = tenantId;
+ this.name = name;
+ this.description = description;
+ this.portPairList = portPairList;
+ }
+
+ @Override
+ public PortPairGroupId portPairGroupId() {
+ return portPairGroupId;
+ }
+
+ @Override
+ public TenantId tenantId() {
+ return tenantId;
+ }
+
+ @Override
+ public String name() {
+ return name;
+ }
+
+ @Override
+ public String description() {
+ return description;
+ }
+
+ @Override
+ public List<PortPairId> portPairs() {
+ return ImmutableList.copyOf(portPairList);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(portPairGroupId, tenantId, name, description,
+ portPairList);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultPortPairGroup) {
+ DefaultPortPairGroup that = (DefaultPortPairGroup) obj;
+ return Objects.equals(portPairGroupId, that.portPairGroupId) &&
+ Objects.equals(tenantId, that.tenantId) &&
+ Objects.equals(name, that.name) &&
+ Objects.equals(description, that.description) &&
+ Objects.equals(portPairList, that.portPairList);
+ }
+ return false;
+ }
+
+ @Override
+ public boolean exactMatch(PortPairGroup portPairGroup) {
+ return this.equals(portPairGroup) &&
+ Objects.equals(this.portPairGroupId, portPairGroup.portPairGroupId()) &&
+ Objects.equals(this.tenantId, portPairGroup.tenantId());
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("id", portPairGroupId.toString())
+ .add("tenantId", tenantId.toString())
+ .add("name", name)
+ .add("description", description)
+ .add("portPairGroupList", portPairList)
+ .toString();
+ }
+
+ /**
+ * To create an instance of the builder.
+ *
+ * @return instance of builder
+ */
+ public static Builder builder() {
+ return new Builder();
+ }
+
+ /**
+ * Builder class for Port pair group.
+ */
+ public static final class Builder implements PortPairGroup.Builder {
+
+ private PortPairGroupId portPairGroupId;
+ private TenantId tenantId;
+ private String name;
+ private String description;
+ private List<PortPairId> portPairList;
+
+ @Override
+ public Builder setId(PortPairGroupId portPairGroupId) {
+ this.portPairGroupId = portPairGroupId;
+ return this;
+ }
+
+ @Override
+ public Builder setTenantId(TenantId tenantId) {
+ this.tenantId = tenantId;
+ return this;
+ }
+
+ @Override
+ public Builder setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @Override
+ public Builder setDescription(String description) {
+ this.description = description;
+ return this;
+ }
+
+ @Override
+ public Builder setPortPairs(List<PortPairId> portPairs) {
+ this.portPairList = portPairs;
+ return this;
+ }
+
+ @Override
+ public PortPairGroup build() {
+
+ checkNotNull(portPairGroupId, "Port pair group id cannot be null");
+ checkNotNull(tenantId, "Tenant id cannot be null");
+ checkNotNull(portPairList, "Port pairs cannot be null");
+
+ return new DefaultPortPairGroup(portPairGroupId, tenantId, name, description,
+ portPairList);
+ }
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java
new file mode 100644
index 00000000..7b4108dc
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifier.java
@@ -0,0 +1,259 @@
+/*
+ * 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.IpPrefix;
+
+/**
+ * Abstraction of an entity which provides flow classifier for service function chain.
+ * FlowClassifier classify the traffic based on the criteria defined in the request.
+ * The classification can be based on port range or source and destination IP address or
+ * other flow classifier elements.
+ */
+public interface FlowClassifier {
+
+ /**
+ * Returns flow classifier ID.
+ *
+ * @return flow classifier id
+ */
+ FlowClassifierId flowClassifierId();
+
+ /**
+ * Returns Tenant ID.
+ *
+ * @return tenant Id
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns flow classifier name.
+ *
+ * @return flow classifier name
+ */
+ String name();
+
+ /**
+ * Returns flow classifier description.
+ *
+ * @return flow classifier description
+ */
+ String description();
+
+ /**
+ * Returns EtherType.
+ *
+ * @return EtherType
+ */
+ String etherType();
+
+ /**
+ * Returns IP Protocol.
+ *
+ * @return IP protocol
+ */
+ String protocol();
+
+ /**
+ * Returns minimum source port range.
+ *
+ * @return minimum source port range
+ */
+ int minSrcPortRange();
+
+ /**
+ * Returns maximum source port range.
+ *
+ * @return maximum source port range
+ */
+ int maxSrcPortRange();
+
+ /**
+ * Returns minimum destination port range.
+ *
+ * @return minimum destination port range
+ */
+ int minDstPortRange();
+
+ /**
+ * Returns maximum destination port range.
+ *
+ * @return maximum destination port range.
+ */
+ int maxDstPortRange();
+
+ /**
+ * Returns Source IP prefix.
+ *
+ * @return Source IP prefix
+ */
+ IpPrefix srcIpPrefix();
+
+ /**
+ * Returns Destination IP prefix.
+ *
+ * @return Destination IP prefix
+ */
+ IpPrefix dstIpPrefix();
+
+ /**
+ * Returns Source virtual port.
+ *
+ * @return Source virtual port
+ */
+ VirtualPortId srcPort();
+
+ /**
+ * Returns Destination virtual port.
+ *
+ * @return Destination virtual port
+ */
+ VirtualPortId dstPort();
+
+ /**
+ * Returns whether this Flow classifier is an exact match to the
+ * Flow classifier given in the argument.
+ *
+ * @param flowClassifier other flowClassifier to match against
+ * @return true if the flowClassifiers are an exact match, otherwise false
+ */
+ boolean exactMatch(FlowClassifier flowClassifier);
+
+ /**
+ * Builder for flow Classifier.
+ */
+ interface Builder {
+
+ /**
+ * Returns Flow Classifier.
+ *
+ * @return flow classifier.
+ */
+ FlowClassifier build();
+
+ /**
+ * Sets Flow Classifier ID.
+ *
+ * @param flowClassifierId flow classifier id.
+ * @return Builder object by setting flow classifier Id.
+ */
+ Builder setFlowClassifierId(FlowClassifierId flowClassifierId);
+
+ /**
+ * Sets Tenant ID.
+ *
+ * @param tenantId tenant id.
+ * @return Builder object by setting Tenant ID.
+ */
+ Builder setTenantId(TenantId tenantId);
+
+ /**
+ * Sets Flow classifier name.
+ *
+ * @param name flow classifier name
+ * @return builder object by setting flow classifier name
+ */
+ Builder setName(String name);
+
+ /**
+ * Sets flow classifier description.
+ *
+ * @param description flow classifier description
+ * @return flow classifier description
+ */
+ Builder setDescription(String description);
+
+ /**
+ * Sets EtherType.
+ *
+ * @param etherType EtherType
+ * @return EtherType
+ */
+ Builder setEtherType(String etherType);
+
+ /**
+ * Sets IP protocol.
+ *
+ * @param protocol IP protocol
+ * @return builder object by setting IP protocol
+ */
+ Builder setProtocol(String protocol);
+
+ /**
+ * Set minimum source port range.
+ *
+ * @param minRange minimum source port range
+ * @return builder object by setting minimum source port range
+ */
+ Builder setMinSrcPortRange(int minRange);
+
+ /**
+ * Sets maximum source port range.
+ *
+ * @param maxRange maximum source port range
+ * @return builder object by setting maximum source port range
+ */
+ Builder setMaxSrcPortRange(int maxRange);
+
+ /**
+ * Sets minimum destination port range.
+ *
+ * @param minRange minimum destination port range
+ * @return builder object by setting minimum destination port range
+ */
+ Builder setMinDstPortRange(int minRange);
+
+ /**
+ * Sets maximum destination port range.
+ *
+ * @param maxRange maximum destination port range.
+ * @return builder object by setting maximum destination port range.
+ */
+ Builder setMaxDstPortRange(int maxRange);
+
+ /**
+ * Sets Source IP prefix.
+ *
+ * @param srcIpPrefix Source IP prefix
+ * @return builder object by setting Source IP prefix
+ */
+ Builder setSrcIpPrefix(IpPrefix srcIpPrefix);
+
+ /**
+ * Sets Destination IP prefix.
+ *
+ * @param dstIpPrefix Destination IP prefix
+ * @return builder object by setting Destination IP prefix
+ */
+ Builder setDstIpPrefix(IpPrefix dstIpPrefix);
+
+ /**
+ * Sets Source virtual port.
+ *
+ * @param srcPort Source virtual port
+ * @return builder object by setting Source virtual port
+ */
+ Builder setSrcPort(VirtualPortId srcPort);
+
+ /**
+ * Sets Destination virtual port.
+ *
+ * @param dstPort Destination virtual port
+ * @return builder object by setting Destination virtual port
+ */
+ Builder setDstPort(VirtualPortId dstPort);
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java
new file mode 100644
index 00000000..b789abe3
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/FlowClassifierId.java
@@ -0,0 +1,91 @@
+/*
+ * 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 com.google.common.base.MoreObjects;
+
+import java.util.UUID;
+import java.util.Objects;
+
+/**
+ * Flow classification identifier.
+ */
+public final class FlowClassifierId {
+
+ private final UUID flowClassifierId;
+
+ /**
+ * Constructor to create flow classifier id.
+ *
+ * @param flowClassifierId flow classifier id.
+ */
+ private FlowClassifierId(final UUID flowClassifierId) {
+ this.flowClassifierId = flowClassifierId;
+ }
+
+ /**
+ * Returns new flow classifier id.
+ *
+ * @param flowClassifierId flow classifier id
+ * @return new flow classifier id
+ */
+ public static FlowClassifierId flowClassifierId(final UUID flowClassifierId) {
+ return new FlowClassifierId(flowClassifierId);
+ }
+
+ /**
+ * Returns new flow classifier id.
+ *
+ * @param flowClassifierId flow classifier id
+ * @return new flow classifier id
+ */
+ public static FlowClassifierId flowClassifierId(final String flowClassifierId) {
+ return new FlowClassifierId(UUID.fromString(flowClassifierId));
+ }
+
+ /**
+ * Returns the value of flow classifier id.
+ *
+ * @return flow classifier id.
+ */
+ public UUID value() {
+ return flowClassifierId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.flowClassifierId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof FlowClassifierId) {
+ final FlowClassifierId other = (FlowClassifierId) obj;
+ return Objects.equals(this.flowClassifierId, other.flowClassifierId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass())
+ .add("FlowClassifierId", flowClassifierId)
+ .toString();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
new file mode 100644
index 00000000..d147eaaa
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChain.java
@@ -0,0 +1,148 @@
+/*
+ * 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.List;
+
+/**
+ * Abstraction of an entity providing Port Chain information.
+ * A Port Chain (Service Function Path) consists of
+ * a set of Neutron ports, to define the sequence of service functions
+ * a set of flow classifiers, to specify the classified traffic flows to enter the chain
+ */
+public interface PortChain {
+
+ /**
+ * Returns the ID of this port chain.
+ *
+ * @return the port chain id
+ */
+ PortChainId portChainId();
+
+ /**
+ * Returns the tenant id of this port chain.
+ *
+ * @return the tenant id
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the name of this port chain.
+ *
+ * @return name of port chain
+ */
+ String name();
+
+ /**
+ * Returns the description of this port chain.
+ *
+ * @return description of port chain
+ */
+ String description();
+
+ /**
+ * Returns the list of port pair groups associated with
+ * this port chain.
+ *
+ * @return list of port pair groups
+ */
+ List<PortPairGroupId> portPairGroups();
+
+ /**
+ * Returns the list of flow classifiers associated with
+ * this port chain.
+ *
+ * @return list of flow classifiers
+ */
+ List<FlowClassifierId> flowClassifiers();
+
+ /**
+ * Returns whether this port chain is an exact match to the port chain given
+ * in the argument.
+ * <p>
+ * Exact match means the port pair groups and flow classifiers match
+ * with the given port chain. It does not consider the port chain id, name
+ * and description.
+ * </p>
+ *
+ * @param portChain other port chain to match against
+ * @return true if the port chains are an exact match, otherwise false
+ */
+ boolean exactMatch(PortChain portChain);
+
+ /**
+ * A port chain builder..
+ */
+ interface Builder {
+
+ /**
+ * Assigns the port chain id to this object.
+ *
+ * @param portChainId the port chain id
+ * @return this the builder object
+ */
+ Builder setId(PortChainId portChainId);
+
+ /**
+ * Assigns tenant id to this object.
+ *
+ * @param tenantId tenant id of the port chain
+ * @return this the builder object
+ */
+ Builder setTenantId(TenantId tenantId);
+
+ /**
+ * Assigns the name to this object.
+ *
+ * @param name name of the port chain
+ * @return this the builder object
+ */
+ Builder setName(String name);
+
+ /**
+ * Assigns the description to this object.
+ *
+ * @param description description of the port chain
+ * @return this the builder object
+ */
+ Builder setDescription(String description);
+
+ /**
+ * Assigns the port pair groups associated with the port chain
+ * to this object.
+ *
+ * @param portPairGroups list of port pair groups
+ * @return this the builder object
+ */
+ Builder setPortPairGroups(List<PortPairGroupId> portPairGroups);
+
+ /**
+ * Assigns the flow classifiers associated with the port chain
+ * to this object.
+ *
+ * @param flowClassifiers list of flow classifiers
+ * @return this the builder object
+ */
+ Builder setFlowClassifiers(List<FlowClassifierId> flowClassifiers);
+
+ /**
+ * Builds a port chain object.
+ *
+ * @return a port chain.
+ */
+ PortChain build();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
new file mode 100644
index 00000000..66edbdcc
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortChainId.java
@@ -0,0 +1,95 @@
+/*
+ * 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.UUID;
+
+import com.google.common.base.Objects;
+
+/**
+ * Representation of a Port Chain ID.
+ */
+public final class PortChainId {
+
+ private final UUID portChainId;
+
+ /**
+ * Private constructor for port chain id.
+ *
+ * @param id UUID id of port chain
+ */
+ private PortChainId(UUID id) {
+ checkNotNull(id, "Port chain id can not be null");
+ this.portChainId = id;
+ }
+
+ /**
+ * Constructor to create port chain id from UUID.
+ *
+ * @param id UUID of port chain
+ * @return object of port chain id
+ */
+ public static PortChainId portChainId(UUID id) {
+ return new PortChainId(id);
+ }
+
+ /**
+ * Constructor to create port chain id from string.
+ *
+ * @param id port chain id in string
+ * @return object of port chain id
+ */
+ public static PortChainId portChainId(String id) {
+ return new PortChainId(UUID.fromString(id));
+ }
+
+ /**
+ * Returns the value of port chain id.
+ *
+ * @return port chain id
+ */
+ public UUID value() {
+ return portChainId;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj.getClass() == this.getClass()) {
+ PortChainId that = (PortChainId) obj;
+ return Objects.equal(this.portChainId, that.portChainId);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.portChainId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("portChainId", portChainId.toString())
+ .toString();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java
new file mode 100644
index 00000000..f6285e61
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPair.java
@@ -0,0 +1,139 @@
+/*
+ * 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;
+
+
+/**
+ * Abstraction of an entity providing Port Pair information.
+ * A port pair represents a service function instance.
+ */
+public interface PortPair {
+
+ /**
+ * Returns the ID of this port Pair.
+ *
+ * @return the port pair id
+ */
+ PortPairId portPairId();
+
+ /**
+ * Returns the tenant id of this port pair.
+ *
+ * @return an tenant id
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the description of this port pair.
+ *
+ * @return description of port pair
+ */
+ String name();
+
+ /**
+ * Returns the description of this port pair.
+ *
+ * @return description of port pair
+ */
+ String description();
+
+ /**
+ * Returns the ingress port of this port pair.
+ *
+ * @return ingress of port pair
+ */
+ String ingress();
+
+ /**
+ * Returns the egress port of this port pair.
+ *
+ * @return egress of port pair
+ */
+ String egress();
+
+ /**
+ * Returns whether this port pair is an exact match to the port pair given
+ * in the argument.
+ * <p>
+ * Exact match means the Port port pairs match with the given port pair.
+ * It does not consider the port pair id, name and description.
+ * </p>
+ * @param portPair other port pair to match against
+ * @return true if the port pairs are an exact match, otherwise false
+ */
+ boolean exactMatch(PortPair portPair);
+
+ /**
+ * A port pair builder..
+ */
+ interface Builder {
+
+ /**
+ * Assigns the port pair id to this object.
+ *
+ * @param portPairId the port pair id
+ * @return this the builder object
+ */
+ Builder setId(PortPairId portPairId);
+
+ /**
+ * Assigns tenant id to this object.
+ *
+ * @param tenantId tenant id of the port pair
+ * @return this the builder object
+ */
+ Builder setTenantId(TenantId tenantId);
+
+ /**
+ * Assigns the name to this object.
+ *
+ * @param name name of the port pair
+ * @return this the builder object
+ */
+ Builder setName(String name);
+
+ /**
+ * Assigns the description to this object.
+ *
+ * @param description description of the port pair
+ * @return this the builder object
+ */
+ Builder setDescription(String description);
+
+ /**
+ * Assigns the ingress port to this object.
+ *
+ * @param port ingress port of the port pair
+ * @return this the builder object
+ */
+ Builder setIngress(String port);
+
+ /**
+ * Assigns the egress port to this object.
+ *
+ * @param port egress port of the port pair
+ * @return this the builder object
+ */
+ Builder setEgress(String port);
+
+ /**
+ * Builds a port pair object.
+ *
+ * @return a port pair.
+ */
+ PortPair build();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java
new file mode 100644
index 00000000..f647b57f
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroup.java
@@ -0,0 +1,126 @@
+/*
+ * 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.List;
+
+/**
+ * Abstraction of an entity providing Port Pair Group information.
+ * A port pair group consists of one or more port pairs.
+ */
+public interface PortPairGroup {
+
+ /**
+ * Returns the ID of this port pair group.
+ *
+ * @return the port pair group id
+ */
+ PortPairGroupId portPairGroupId();
+
+ /**
+ * Returns the tenant id of this port pair group.
+ *
+ * @return the tenant id
+ */
+ TenantId tenantId();
+
+ /**
+ * Returns the name of this port pair group.
+ *
+ * @return name of port pair group
+ */
+ String name();
+
+ /**
+ * Returns the description of this port pair group.
+ *
+ * @return description of port pair group
+ */
+ String description();
+
+ /**
+ * Returns the list of port pairs associated with this port pair group.
+ *
+ * @return list of port pairs
+ */
+ List<PortPairId> portPairs();
+
+ /**
+ * Returns whether this port pair group is an exact match to the
+ * port pair group given in the argument.
+ * <p>
+ * Exact match means the Port pairs match with the given port pair group.
+ * It does not consider the port pair group id, name and description.
+ * </p>
+ * @param portPairGroup other port pair group to match against
+ * @return true if the port pairs are an exact match, otherwise false
+ */
+ boolean exactMatch(PortPairGroup portPairGroup);
+
+ /**
+ * A port pair group builder..
+ */
+ interface Builder {
+
+ /**
+ * Assigns the port pair group id to this object.
+ *
+ * @param portPairGroupId the port pair group id
+ * @return this the builder object
+ */
+ Builder setId(PortPairGroupId portPairGroupId);
+
+ /**
+ * Assigns tenant id to this object.
+ *
+ * @param tenantId tenant id of port pair group
+ * @return this the builder object
+ */
+ Builder setTenantId(TenantId tenantId);
+
+ /**
+ * Assigns the name to this object.
+ *
+ * @param name name of the port pair group
+ * @return this the builder object
+ */
+ Builder setName(String name);
+
+ /**
+ * Assigns the description to this object.
+ *
+ * @param description description of the port pair group
+ * @return this the builder object
+ */
+ Builder setDescription(String description);
+
+ /**
+ * Assigns the port pairs associated with the port pair group
+ * to this object.
+ *
+ * @param portPairs list of port pairs
+ * @return this the builder object
+ */
+ Builder setPortPairs(List<PortPairId> portPairs);
+
+ /**
+ * Builds a port pair group object.
+ *
+ * @return a port pair group object.
+ */
+ PortPairGroup build();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java
new file mode 100644
index 00000000..0474901c
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairGroupId.java
@@ -0,0 +1,95 @@
+/*
+ * 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.UUID;
+
+import com.google.common.base.Objects;
+
+/**
+ * Representation of a Port Pair Group ID.
+ */
+public final class PortPairGroupId {
+
+ private final UUID portPairGroupId;
+
+ /**
+ * Private constructor for port pair group id.
+ *
+ * @param id UUID id of port pair group
+ */
+ private PortPairGroupId(UUID id) {
+ checkNotNull(id, "Port pair group id can not be null");
+ this.portPairGroupId = id;
+ }
+
+ /**
+ * Constructor to create port pair group id from UUID.
+ *
+ * @param id UUID of port pair group id
+ * @return object of port pair group id
+ */
+ public static PortPairGroupId portPairGroupId(UUID id) {
+ return new PortPairGroupId(id);
+ }
+
+ /**
+ * Constructor to create port pair group id from string.
+ *
+ * @param id port pair group id in string
+ * @return object of port pair group id
+ */
+ public static PortPairGroupId portPairGroupId(String id) {
+ return new PortPairGroupId(UUID.fromString(id));
+ }
+
+ /**
+ * Returns the value of port pair group id.
+ *
+ * @return port pair group id
+ */
+ public UUID value() {
+ return portPairGroupId;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj.getClass() == this.getClass()) {
+ PortPairGroupId that = (PortPairGroupId) obj;
+ return Objects.equal(this.portPairGroupId, that.portPairGroupId);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.portPairGroupId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("portPairGroupId", portPairGroupId.toString())
+ .toString();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java
new file mode 100644
index 00000000..05c31aac
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/PortPairId.java
@@ -0,0 +1,95 @@
+/*
+ * 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.UUID;
+
+import com.google.common.base.Objects;
+
+/**
+ * Representation of a Port Pair ID.
+ */
+public final class PortPairId {
+
+ private final UUID portPairId;
+
+ /**
+ * Private constructor for port pair id.
+ *
+ * @param id UUID id of port pair
+ */
+ private PortPairId(UUID id) {
+ checkNotNull(id, "Port chain id can not be null");
+ this.portPairId = id;
+ }
+
+ /**
+ * Constructor to create port pair id from UUID.
+ *
+ * @param id UUID of port pair id
+ * @return object of port pair id
+ */
+ public static PortPairId portPairId(UUID id) {
+ return new PortPairId(id);
+ }
+
+ /**
+ * Constructor to create port pair id from string.
+ *
+ * @param id port pair id in string
+ * @return object of port pair id
+ */
+ public static PortPairId portPairId(String id) {
+ return new PortPairId(UUID.fromString(id));
+ }
+
+ /**
+ * Returns teh value of port pair id.
+ *
+ * @return port pair id
+ */
+ public UUID value() {
+ return portPairId;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj.getClass() == this.getClass()) {
+ PortPairId that = (PortPairId) obj;
+ return Objects.equal(this.portPairId, that.portPairId);
+ }
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hashCode(this.portPairId);
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this)
+ .add("portPairId", portPairId.toString())
+ .toString();
+ }
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/FlowClassifierService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/FlowClassifierService.java
new file mode 100644
index 00000000..e379be81
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/FlowClassifierService.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc.flowClassifier;
+
+import org.onosproject.vtnrsc.FlowClassifier;
+import org.onosproject.vtnrsc.FlowClassifierId;
+
+/**
+ * Provides Services for Flow Classifier.
+ */
+public interface FlowClassifierService {
+
+ /**
+ * Store Flow Classifier.
+ *
+ * @param flowClassifier Flow Classifier
+ * @return true if adding Flow Classifier into store is success otherwise return false.
+ */
+ boolean createFlowClassifier(FlowClassifier flowClassifier);
+
+ /**
+ * Return the existing collection of Flow Classifier.
+ *
+ * @return Flow Classifier collections.
+ */
+ Iterable<FlowClassifier> getFlowClassifiers();
+
+ /**
+ * Check whether Flow Classifier is present based on given Flow Classifier Id.
+ *
+ * @param id Flow Classifier.
+ * @return true if Flow Classifier is present otherwise return false.
+ */
+ boolean hasFlowClassifier(FlowClassifierId id);
+
+ /**
+ * Retrieve the Flow Classifier based on given Flow Classifier id.
+ *
+ * @param id Flow Classifier Id.
+ * @return Flow Classifier if present otherwise returns null.
+ */
+ FlowClassifier getFlowClassifier(FlowClassifierId id);
+
+ /**
+ * Update Flow Classifier based on given Flow Classifier Id.
+ *
+ * @param flowClassifier Flow Classifier.
+ * @return true if update is success otherwise return false.
+ */
+ boolean updateFlowClassifier(FlowClassifier flowClassifier);
+
+ /**
+ * Remove Flow Classifier from store based on given Flow Classifier Id.
+ *
+ * @param id Flow Classifier Id.
+ * @return true if Flow Classifier removal is success otherwise return false.
+ */
+ boolean removeFlowClassifier(FlowClassifierId id);
+} \ No newline at end of file
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java
new file mode 100644
index 00000000..7238558a
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/FlowClassifierManager.java
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc.flowClassifier.impl;
+
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Service;
+import org.onosproject.vtnrsc.FlowClassifierId;
+import org.onosproject.vtnrsc.FlowClassifier;
+import org.onosproject.vtnrsc.flowClassifier.FlowClassifierService;
+
+import org.slf4j.Logger;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Provides implementation of the Flow Classifier Service.
+ */
+@Component(immediate = true)
+@Service
+public class FlowClassifierManager implements FlowClassifierService {
+
+ private final Logger log = getLogger(FlowClassifierManager.class);
+
+ private static final String FLOW_CLASSIFIER_NOT_NULL = "Flow Classifier cannot be null";
+ private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow Classifier Id cannot be null";
+
+ private ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore
+ = new ConcurrentHashMap<FlowClassifierId, FlowClassifier>();
+
+ @Activate
+ private void activate() {
+ log.info("Flow Classifier service activated");
+ }
+
+ @Deactivate
+ private void deactivate() {
+ log.info("Flow Classifier service deactivated");
+ }
+
+ @Override
+ public boolean createFlowClassifier(FlowClassifier flowClassifier) {
+ log.debug("createFlowClassifier");
+ checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL);
+ FlowClassifierId id = flowClassifier.flowClassifierId();
+
+ flowClassifierStore.put(id, flowClassifier);
+ if (!flowClassifierStore.containsKey(id)) {
+ log.debug("Flow Classifier creation is failed whose identifier is {}.", id.toString());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Iterable<FlowClassifier> getFlowClassifiers() {
+ return ImmutableList.copyOf(flowClassifierStore.values());
+ }
+
+ @Override
+ public boolean hasFlowClassifier(FlowClassifierId id) {
+ checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL);
+ return flowClassifierStore.containsKey(id);
+ }
+
+ @Override
+ public FlowClassifier getFlowClassifier(FlowClassifierId id) {
+ checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL);
+ return flowClassifierStore.get(id);
+ }
+
+ @Override
+ public boolean updateFlowClassifier(FlowClassifier flowClassifier) {
+ checkNotNull(flowClassifier, FLOW_CLASSIFIER_NOT_NULL);
+ FlowClassifierId id = flowClassifier.flowClassifierId();
+ return flowClassifierStore.replace(id, flowClassifierStore.get(id), flowClassifier);
+ }
+
+ @Override
+ public boolean removeFlowClassifier(FlowClassifierId id) {
+ checkNotNull(id, FLOW_CLASSIFIER_ID_NOT_NULL);
+ flowClassifierStore.remove(id);
+ if (flowClassifierStore.containsKey(id)) {
+ log.debug("The Flow Classifier removal is failed whose identifier is {}", id.toString());
+ return false;
+ }
+ return true;
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/package-info.java
new file mode 100644
index 00000000..4ea050b3
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/impl/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Provides implementation of the flow Classifier service.
+ */
+package org.onosproject.vtnrsc.flowClassifier.impl;
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/package-info.java
index 3a84e6e3..07584170 100644
--- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/package-info.java
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/flowClassifier/package-info.java
@@ -15,6 +15,6 @@
*/
/**
- * Service for interacting with the inventory of subnets.
+ * Service for interacting with flow Classifier of SFC.
*/
-package org.onosproject.vtnrsc.tunnel;
+package org.onosproject.vtnrsc.flowClassifier;
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java
new file mode 100644
index 00000000..b4ff917e
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/PortChainService.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc.portchain;
+
+import org.onosproject.vtnrsc.PortChain;
+import org.onosproject.vtnrsc.PortChainId;
+
+/**
+ * Service for interacting with the inventory of port chains.
+ */
+public interface PortChainService {
+
+ /**
+ * Returns if the port chain is existed.
+ *
+ * @param portChainId port chain identifier
+ * @return true or false if one with the given identifier exists.
+ */
+ boolean exists(PortChainId portChainId);
+
+ /**
+ * Returns the number of port chains known to the system.
+ *
+ * @return number of port chains.
+ */
+ int getPortChainCount();
+
+ /**
+ * Returns an iterable collection of the currently known port chains.
+ *
+ * @return collection of port chains.
+ */
+ Iterable<PortChain> getPortChains();
+
+ /**
+ * Returns the portChain with the given identifier.
+ *
+ * @param portChainId port chain identifier
+ * @return PortChain or null if port chain with the given identifier is not
+ * known.
+ */
+ PortChain getPortChain(PortChainId portChainId);
+
+ /**
+ * Creates a PortChain in the store.
+ *
+ * @param portChain the port chain to create
+ * @return true if given port chain is created successfully.
+ */
+ boolean createPortChain(PortChain portChain);
+
+ /**
+ * Updates the portChain in the store.
+ *
+ * @param portChain the port chain to update
+ * @return true if given port chain is updated successfully.
+ */
+ boolean updatePortChain(PortChain portChain);
+
+ /**
+ * Deletes portChain by given portChainId.
+ *
+ * @param portChainId id of port chain to remove
+ * @return true if the give port chain is deleted successfully.
+ */
+ boolean removePortChain(PortChainId portChainId);
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java
new file mode 100644
index 00000000..74642bc3
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portchain/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Service for interacting with the inventory of port chains.
+ */
+package org.onosproject.vtnrsc.portchain;
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java
new file mode 100644
index 00000000..77f483fc
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/PortPairGroupService.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.vtnrsc.portpairgroup;
+
+import org.onosproject.vtnrsc.PortPairGroup;
+import org.onosproject.vtnrsc.PortPairGroupId;
+
+/**
+ * Service for interacting with the inventory of port pair groups.
+ */
+public interface PortPairGroupService {
+
+ /**
+ * Returns if the port pair group is existed.
+ *
+ * @param portPairGroupId port pair group identifier
+ * @return true or false if one with the given identifier exists.
+ */
+ boolean exists(PortPairGroupId portPairGroupId);
+
+ /**
+ * Returns the number of port pair groups known to the system.
+ *
+ * @return number of port pair groups.
+ */
+ int getPortPairGroupCount();
+
+ /**
+ * Returns an iterable collection of the currently known port pair groups.
+ *
+ * @return collection of port pair groups.
+ */
+ Iterable<PortPairGroup> getPortPairGroups();
+
+ /**
+ * Returns the portPairGroup with the given identifier.
+ *
+ * @param portPairGroupId port pair group identifier
+ * @return PortPairGroup or null if port pair group with the given identifier is not
+ * known.
+ */
+ PortPairGroup getPortPairGroup(PortPairGroupId portPairGroupId);
+
+ /**
+ * Creates a PortPairGroup in the store.
+ *
+ * @param portPairGroup the port pair group to create
+ * @return true if given port pair group is created successfully.
+ */
+ boolean createPortPairGroup(PortPairGroup portPairGroup);
+
+ /**
+ * Updates the portPairGroup in the store.
+ *
+ * @param portPairGroup the port pair group to update
+ * @return true if given port pair group is updated successfully.
+ */
+ boolean updatePortPairGroup(PortPairGroup portPairGroup);
+
+ /**
+ * Deletes portPairGroup by given portPairGroupId.
+ *
+ * @param portPairGroupId id of port pair group to remove
+ * @return true if the give port pair group is deleted successfully.
+ */
+ boolean removePortPairGroup(PortPairGroupId portPairGroupId);
+}
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java
new file mode 100644
index 00000000..8a79fe97
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/portpairgroup/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2015 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Service for interacting with the inventory of port pair groups.
+ */
+package org.onosproject.vtnrsc.portpairgroup;
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/tunnel/TunnelConfigService.java
deleted file mode 100644
index 6f3cf653..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
index c45373b9..daec7839 100644
--- a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/virtualport/impl/VirtualPortManager.java
@@ -191,22 +191,20 @@ public class VirtualPortManager implements VirtualPortService {
@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;
- }
+ 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);
+ 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;
- }
+ if (!vPort.equals(vPortStore.get(vPort.portId()))) {
+ log.debug("The virtualPort is updated failed whose identifier is {}",
+ vPort.portId().toString());
+ return false;
}
}
return true;
@@ -215,14 +213,12 @@ public class VirtualPortManager implements VirtualPortService {
@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;
- }
+ 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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllocationPoolsCodec.java
deleted file mode 100644
index 57c97c1c..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/AllowedAddressPairCodec.java
deleted file mode 100644
index 7960808f..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FixedIpCodec.java
deleted file mode 100644
index 96c9bb4e..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java
new file mode 100644
index 00000000..fd5b1ee4
--- /dev/null
+++ b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/FlowClassifierCodec.java
@@ -0,0 +1,134 @@
+/*
+ * 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 static org.onlab.util.Tools.nullIsIllegal;
+
+import java.util.UUID;
+
+import org.onlab.packet.IpPrefix;
+import org.onosproject.codec.CodecContext;
+import org.onosproject.codec.JsonCodec;
+import org.onosproject.vtnrsc.DefaultFlowClassifier;
+import org.onosproject.vtnrsc.FlowClassifier;
+import org.onosproject.vtnrsc.FlowClassifierId;
+import org.onosproject.vtnrsc.VirtualPortId;
+import org.onosproject.vtnrsc.TenantId;
+
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+/**
+ * Flow Classifier JSON codec.
+ */
+public final class FlowClassifierCodec extends JsonCodec<FlowClassifier> {
+
+ private static final String FLOW_CLASSIFIER_ID = "id";
+ private static final String TENANT_ID = "tenant_id";
+ private static final String NAME = "name";
+ private static final String DESCRIPTION = "description";
+ private static final String ETHER_TYPE = "etherType";
+ private static final String PROTOCOL = "protocol";
+ private static final String MIN_SRC_PORT_RANGE = "source_port_range_min";
+ private static final String MAX_SRC_PORT_RANGE = "source_port_range_max";
+ private static final String MIN_DST_PORT_RANGE = "destination_port_range_min";
+ private static final String MAX_DST_PORT_RANGE = "destination_port_range_max";
+ private static final String SRC_IP_PREFIX = "source_ip_prefix";
+ private static final String DST_IP_PREFIX = "destination_ip_prefix";
+ private static final String SRC_PORT = "logical_source_port";
+ private static final String DST_PORT = "logical_destination_port";
+ private static final String MISSING_MEMBER_MESSAGE = " member is required in Flow Classifier.";
+
+ @Override
+ public FlowClassifier decode(ObjectNode json, CodecContext context) {
+ if (json == null || !json.isObject()) {
+ return null;
+ }
+
+ FlowClassifier.Builder resultBuilder = new DefaultFlowClassifier.Builder();
+
+ String flowClassifierId = nullIsIllegal(json.get(FLOW_CLASSIFIER_ID),
+ FLOW_CLASSIFIER_ID + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setFlowClassifierId(FlowClassifierId.flowClassifierId(UUID.fromString(flowClassifierId)));
+
+ String tenantId = nullIsIllegal(json.get(TENANT_ID), TENANT_ID + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setTenantId(TenantId.tenantId(tenantId));
+
+ String flowClassiferName = nullIsIllegal(json.get(NAME), NAME + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setName(flowClassiferName);
+
+ String flowClassiferDescription = nullIsIllegal(json.get(DESCRIPTION), DESCRIPTION + MISSING_MEMBER_MESSAGE)
+ .asText();
+ resultBuilder.setDescription(flowClassiferDescription);
+
+ String etherType = nullIsIllegal(json.get(ETHER_TYPE), ETHER_TYPE + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setEtherType(etherType);
+
+ String protocol = nullIsIllegal(json.get(PROTOCOL), PROTOCOL + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setProtocol(protocol);
+
+ int minSrcPortRange = nullIsIllegal(json.get(MIN_SRC_PORT_RANGE), MIN_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE)
+ .asInt();
+ resultBuilder.setMinSrcPortRange(minSrcPortRange);
+
+ int maxSrcPortRange = nullIsIllegal(json.get(MAX_SRC_PORT_RANGE), MAX_SRC_PORT_RANGE + MISSING_MEMBER_MESSAGE)
+ .asInt();
+ resultBuilder.setMaxSrcPortRange(maxSrcPortRange);
+
+ int minDstPortRange = nullIsIllegal(json.get(MIN_DST_PORT_RANGE), MIN_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE)
+ .asInt();
+ resultBuilder.setMinDstPortRange(minDstPortRange);
+
+ int maxDstPortRange = nullIsIllegal(json.get(MAX_DST_PORT_RANGE), MAX_DST_PORT_RANGE + MISSING_MEMBER_MESSAGE)
+ .asInt();
+ resultBuilder.setMaxDstPortRange(maxDstPortRange);
+
+ String srcIpPrefix = nullIsIllegal(json.get(SRC_IP_PREFIX), SRC_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setSrcIpPrefix(IpPrefix.valueOf(srcIpPrefix));
+
+ String dstIpPrefix = nullIsIllegal(json.get(DST_IP_PREFIX), DST_IP_PREFIX + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setDstIpPrefix(IpPrefix.valueOf(dstIpPrefix));
+
+ String srcPort = nullIsIllegal(json.get(SRC_PORT), SRC_PORT + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setSrcPort(VirtualPortId.portId(srcPort));
+
+ String dstPort = nullIsIllegal(json.get(DST_PORT), DST_PORT + MISSING_MEMBER_MESSAGE).asText();
+ resultBuilder.setDstPort(VirtualPortId.portId(dstPort));
+
+ return resultBuilder.build();
+ }
+
+ @Override
+ public ObjectNode encode(FlowClassifier flowClassifier, CodecContext context) {
+ checkNotNull(flowClassifier, "flowClassifier cannot be null");
+ ObjectNode result = context.mapper().createObjectNode()
+ .put("FLOW_CLASSIFIER_ID", flowClassifier.flowClassifierId().toString())
+ .put("TENANT_ID", flowClassifier.tenantId().toString())
+ .put("NAME", flowClassifier.name())
+ .put("DESCRIPTION", flowClassifier.description())
+ .put("ETHER_TYPE", flowClassifier.etherType())
+ .put("PROTOCOL", flowClassifier.protocol())
+ .put("MIN_SRC_PORT_RANGE", flowClassifier.minSrcPortRange())
+ .put("MAX_SRC_PORT_RANGE", flowClassifier.maxSrcPortRange())
+ .put("MIN_DST_PORT_RANGE", flowClassifier.minDstPortRange())
+ .put("MAX_DST_PORT_RANGE", flowClassifier.maxDstPortRange())
+ .put("SRC_IP_PREFIX", flowClassifier.srcIpPrefix().toString())
+ .put("DST_IP_PREFIX", flowClassifier.dstIpPrefix().toString())
+ .put("SRC_PORT", flowClassifier.srcPort().toString())
+ .put("DST_PORT", flowClassifier.dstPort().toString());
+ return result;
+ }
+} \ No newline at end of file
diff --git a/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/HostRoutesCodec.java
deleted file mode 100644
index 69ca6b3f..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SecurityGroupCodec.java
deleted file mode 100644
index c2ded196..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/SubnetCodec.java
deleted file mode 100644
index 122b75a9..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/TenantNetworkCodec.java
deleted file mode 100644
index 48ba3b97..00000000
--- a/framework/src/onos/apps/vtn/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/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java b/framework/src/onos/apps/vtn/vtnrsc/src/main/java/org/onosproject/vtnrsc/web/VirtualPortCodec.java
deleted file mode 100644
index e57d56bc..00000000
--- a/framework/src/onos/apps/vtn/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;
- }
-}