[ONOS-5474] (SBI) Define VirtualDeviceProvider
- add interface virtual port description
- add interface virtual device Provider/ProviderService

Change-Id: I47894d6eb50fa59c75cc7956a216f95f40c078e1
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualPortDescription.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualPortDescription.java
new file mode 100644
index 0000000..4f2bdc4
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/VirtualPortDescription.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.device.PortDescription;
+
+/**
+ * Information about a virtual port.
+ */
+public interface VirtualPortDescription extends PortDescription {
+
+    // TODO: Add something about a requirement of virtual port.
+
+    /**
+     * Representation of the virtual port.
+     */
+    enum State {
+        /**
+         * Signifies that a virtual port is currently start.
+         */
+        START,
+
+        /**
+         * Signifies that a virtual port is currently stop.
+         */
+        STOP,
+
+        /**
+         * Signifies that a virtual port is pause for a moment.
+         */
+        PAUSE
+    }
+
+    /**
+     * Starts the virtual port.
+     */
+    void start();
+
+    /**
+     * Stops the virtual port.
+     */
+    void stop();
+
+    /**
+     * Pauses the virtual port for stopping a network or device.
+     * e.g. snapshot.
+     */
+    void pause();
+
+    /**
+     * Returns the virtual port state.
+     *
+     * @return state of virtual port
+     */
+    State state();
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualDeviceProvider.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualDeviceProvider.java
new file mode 100644
index 0000000..b60d5e0
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualDeviceProvider.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.provider;
+
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.PortNumber;
+
+/**
+ * Abstraction of a virtual device information provider.
+ */
+public interface VirtualDeviceProvider extends VirtualProvider {
+
+    /**
+     * Notifies the provider of a mastership role change for the specified
+     * device as decided by the core.
+     *
+     * @param deviceId  device identifier
+     * @param newRole newly determined mastership role
+     */
+    void roleChanged(DeviceId deviceId, MastershipRole newRole);
+
+    /**
+     * Indicates whether or not the specified connect points on the underlying
+     * network are traversable.
+     *
+     * @param src source connection point
+     * @param dst destination connection point
+     * @return true if the destination is reachable from the source
+     */
+    boolean isTraversable(ConnectPoint src, ConnectPoint dst);
+
+    /**
+     * Indicates whether or not the all physical devices mapped by the given
+     * virtual device are reachable.
+     *
+     * @param deviceId  device identifier
+     * @return true if the all physical devices are reachable, false otherwise
+     */
+    boolean isReachable(DeviceId deviceId);
+
+    /**
+     * Administratively enables or disables a port.
+     *
+     * @param deviceId device identifier
+     * @param portNumber port number
+     * @param enable true if port is to be enabled, false to disable
+     */
+    void changePortState(DeviceId deviceId, PortNumber portNumber,
+                         boolean enable);
+}
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualDeviceProviderService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualDeviceProviderService.java
new file mode 100644
index 0000000..b99259d
--- /dev/null
+++ b/incubator/api/src/main/java/org/onosproject/incubator/net/virtual/provider/VirtualDeviceProviderService.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT 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.provider;
+
+import org.onosproject.incubator.net.virtual.VirtualPortDescription;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.device.PortStatistics;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * Service through which virtual device providers can inject virtual device
+ * information into the core.
+ */
+public interface VirtualDeviceProviderService
+        extends VirtualProviderService<VirtualDeviceProvider> {
+
+    /**
+     * Updates information about all ports of a device. It is up to the core to
+     * determine what has changed.
+     *
+     * @param deviceId         identity of the device
+     * @param portDescs list of virtual device ports
+     */
+    void updatePorts(DeviceId deviceId, List<VirtualPortDescription> portDescs);
+
+    /**
+     * Notifies the core about port status change of a single port.
+     *
+     * @param deviceId        identity of the device
+     * @param portDesc description of the virtual port that changed
+     */
+    void portStatusChanged(DeviceId deviceId, VirtualPortDescription portDesc);
+
+    /**
+     * Notifies the core about the result of a RoleRequest sent to a device.
+     *
+     * @param deviceId identity of the device
+     * @param requested mastership role that was requested by the node
+     * @param response mastership role the switch accepted
+     */
+    void receivedRoleReply(DeviceId deviceId, MastershipRole requested,
+                           MastershipRole response);
+
+    /**
+     * Updates statistics about all ports of a device.
+     *
+     * @param deviceId          identity of the device
+     * @param portStatistics  list of device port statistics
+     */
+    void updatePortStatistics(DeviceId deviceId,
+                              Collection<PortStatistics> portStatistics);
+}