[ONOS-6463] general device Provider

Change-Id: Ibc045bffe14c24068adc7f0adc96366d0f1807a0
diff --git a/core/api/src/main/java/org/onosproject/net/behaviour/PortAdmin.java b/core/api/src/main/java/org/onosproject/net/behaviour/PortAdmin.java
index 04c4449..7f469b1 100644
--- a/core/api/src/main/java/org/onosproject/net/behaviour/PortAdmin.java
+++ b/core/api/src/main/java/org/onosproject/net/behaviour/PortAdmin.java
@@ -15,19 +15,44 @@
  */
 package org.onosproject.net.behaviour;
 
-import org.onosproject.net.device.PortDescription;
+import com.google.common.annotations.Beta;
+import org.onosproject.net.PortNumber;
 import org.onosproject.net.driver.HandlerBehaviour;
 
+import java.util.concurrent.CompletableFuture;
+
 /**
- * Means to administratively enable/disable a logical port at the device.
+ * Means to administratively enable,disable and query the state
+ * of a port on a device.
  */
+@Beta
 public interface PortAdmin extends HandlerBehaviour {
 
     /**
-     * Enable/disable administratively a port.
+     * Enable administratively a port.
      *
-     * @param port a port description containing the desired port state
+     * @param number the port to be enabled
+     * @return CompletableFuture with true if the operation was successful
      */
-    void enable(PortDescription port);
+    CompletableFuture<Boolean> enable(PortNumber number);
+
+    /**
+     * Disable administratively a port.
+     *
+     * @param number the port to be disabled
+     * @return CompletableFuture with true if the operation was successful
+     */
+    CompletableFuture<Boolean> disable(PortNumber number);
+
+    /**
+     * Retrieves the information about the administrative state of a port.
+     *
+     * @param number identifier of the port to be queried about its state
+     * @return CompletableFuture containing, when completed, true if the port isEnabled.
+     */
+    CompletableFuture<Boolean> isEnabled(PortNumber number);
+
+    //TODO this behaviour can be augmented or others can be created for
+    // LED and Speed configuration
 
 }
diff --git a/core/api/src/main/java/org/onosproject/net/device/DeviceHandshaker.java b/core/api/src/main/java/org/onosproject/net/device/DeviceHandshaker.java
new file mode 100644
index 0000000..abfb237
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/device/DeviceHandshaker.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2017-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.net.device;
+
+import com.google.common.annotations.Beta;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.driver.DeviceConnect;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Behavior to test device's reachability and change the mastership role on that
+ * device.
+ */
+@Beta
+public interface DeviceHandshaker extends DeviceConnect {
+
+    /**
+     * Checks the reachability (connectivity) of a device.
+     * Reachability, unlike availability, denotes whether THIS particular node
+     * can send messages and receive replies from the specified device.
+     *
+     * @return CompletableFuture eventually true if reachable, false otherwise
+     */
+    CompletableFuture<Boolean> isReachable();
+
+    /**
+     * Applies on the device a mastership role change as decided by the core.
+     *
+     * @param newRole newly determined mastership role
+     * @return CompletableFuture with the mastership role accepted from the device
+     */
+    CompletableFuture<MastershipRole> roleChanged(MastershipRole newRole);
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DeviceConnect.java b/core/api/src/main/java/org/onosproject/net/driver/DeviceConnect.java
new file mode 100644
index 0000000..7b28f0b
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/driver/DeviceConnect.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2015-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.net.driver;
+
+import com.google.common.annotations.Beta;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Abstraction of handler behaviour used to set-up and tear-down
+ * connection with a device.
+ */
+@Beta
+public interface DeviceConnect extends HandlerBehaviour {
+
+    /**
+     * Connects to the device.
+     * It's supposed to initiate the transport sessions, channel and also,
+     * if applicable, store them in the proper protocol specific
+     * controller (e.g. GrpcController).
+     *
+     * @return CompletableFuture with true if the operation was successful
+     */
+    CompletableFuture<Boolean> connect();
+
+    /**
+     * Disconnects from the device.
+     * It's supposed to destroy the transport sessions and channel and also,
+     * if applicable, remove them in the proper protocol specific
+     * controller (e.g. GrpcController).
+     *
+     * @return CompletableFuture with true if the operation was successful
+     */
+    CompletableFuture<Boolean> disconnect();
+
+}
diff --git a/core/api/src/main/java/org/onosproject/net/driver/DriverConnect.java b/core/api/src/main/java/org/onosproject/net/driver/DriverConnect.java
deleted file mode 100644
index 34a91ea..0000000
--- a/core/api/src/main/java/org/onosproject/net/driver/DriverConnect.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2015-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.net.driver;
-
-/**
- * Abstraction of handler behaviour used to set-up and tear-down driver
- * connection with a device.
- */
-public interface DriverConnect extends HandlerBehaviour {
-
-    /**
-     * Connects to the device.
-     *
-     * @param credentials optional login credentials in string form
-     */
-    void connect(String... credentials);
-
-    /**
-     * Disconnects from the device.
-     */
-    void disconnect();
-
-}