ONOS-4075 - Distributed virtual network store implementation,
and virtual network manager Junit tests.
Change-Id: Ic1f82822c894e3c394aa95df1e76ae59fe218120
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java
index e3339a9..06225ff 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualDevice.java
@@ -27,7 +27,7 @@
/**
* Default representation of a virtual device.
*/
-public class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice {
+public final class DefaultVirtualDevice extends DefaultDevice implements VirtualDevice {
private static final String VIRTUAL = "virtual";
private static final ProviderId PID = new ProviderId(VIRTUAL, VIRTUAL);
@@ -53,7 +53,7 @@
@Override
public int hashCode() {
- return 31 * super.hashCode() + networkId.hashCode();
+ return Objects.hash(networkId);
}
@Override
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualLink.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualLink.java
new file mode 100644
index 0000000..89374d4
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualLink.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.incubator.net.virtual;
+
+import org.onosproject.incubator.net.tunnel.TunnelId;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultLink;
+import org.onosproject.net.provider.ProviderId;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Default representation of a virtual link.
+ */
+public final class DefaultVirtualLink extends DefaultLink implements VirtualLink {
+
+ private static final String VIRTUAL = "virtual";
+ private static final ProviderId PID = new ProviderId(VIRTUAL, VIRTUAL);
+
+ private final NetworkId networkId;
+ private final TunnelId tunnelId;
+
+ /**
+ * Constructor for a default virtual link.
+ *
+ * @param networkId network identifier
+ * @param src source connection point
+ * @param dst destination connection point
+ * @param tunnelId tunnel identifier
+ */
+ public DefaultVirtualLink(NetworkId networkId, ConnectPoint src, ConnectPoint dst, TunnelId tunnelId) {
+ super(PID, src, dst, Type.VIRTUAL, DefaultAnnotations.builder().build());
+ this.networkId = networkId;
+ this.tunnelId = tunnelId;
+ }
+
+ @Override
+ public NetworkId networkId() {
+ return networkId;
+ }
+
+ /**
+ * Returns the tunnel identifier.
+ *
+ * @return tunnel identifier.
+ */
+ public TunnelId tunnelId() {
+ return tunnelId;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(networkId, tunnelId);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultVirtualLink) {
+ DefaultVirtualLink that = (DefaultVirtualLink) obj;
+ return super.equals(that) &&
+ Objects.equals(this.networkId, that.networkId) &&
+ Objects.equals(this.tunnelId, that.tunnelId);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("networkId", networkId).add("tunnelId", tunnelId).toString();
+ }
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualNetwork.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualNetwork.java
index c114191..360d385 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualNetwork.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualNetwork.java
@@ -22,7 +22,7 @@
/**
* Default implementation of the virtual network descriptor.
*/
-public class DefaultVirtualNetwork implements VirtualNetwork {
+public final class DefaultVirtualNetwork implements VirtualNetwork {
private final NetworkId id;
private final TenantId tenantId;
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualPort.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualPort.java
new file mode 100644
index 0000000..ad56efb
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/DefaultVirtualPort.java
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.incubator.net.virtual;
+
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.Device;
+import org.onosproject.net.Element;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+
+import java.util.Objects;
+
+import static com.google.common.base.MoreObjects.toStringHelper;
+
+/**
+ * Default representation of a virtual port.
+ */
+public final class DefaultVirtualPort extends DefaultPort implements VirtualPort {
+
+
+ private final NetworkId networkId;
+ private final Port realizedBy;
+
+ public DefaultVirtualPort(NetworkId networkId, Device device, PortNumber portNumber, Port realizedBy) {
+ super((Element) device, portNumber, false, DefaultAnnotations.builder().build());
+ this.networkId = networkId;
+ this.realizedBy = realizedBy;
+ }
+
+ public NetworkId networkId() {
+ return networkId;
+ }
+
+ @Override
+ public Port realizedBy() {
+ return realizedBy;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(networkId, realizedBy);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof DefaultVirtualPort) {
+ DefaultVirtualPort that = (DefaultVirtualPort) obj;
+ return super.equals(that) &&
+ Objects.equals(this.networkId, that.networkId) &&
+ Objects.equals(this.realizedBy, that.realizedBy);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return toStringHelper(this).add("networkId", networkId).add("realizedBy", realizedBy).toString();
+ }
+
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java
index 01681ef..c83b2c5 100644
--- a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualNetworkService.java
@@ -27,6 +27,11 @@
public interface VirtualNetworkService {
/**
+ * The topic used for obtaining globally unique ids.
+ */
+ String VIRTUAL_NETWORK_TOPIC = "virtual-network-ids";
+
+ /**
* Returns a collection of all virtual networks created on behalf of the
* specified tenant.
*