[ODTN] Interface of a new driver behavior for checking internal connectivity in a device.

This would be used mostly for optical devices which typically have many connectivity constraints.

The patch also includes a CLI command to using driver behavior and an empty driver implementation.

patch 1: first draft: behaviour, CLI, empty driver, xml.

patch 2,3,4,6: checkstyle.

patch 5: comments by Andrea.

Change-Id: Ia1573a9f14b49c39c96fa3351ccc37988f1526ec
diff --git a/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/FullMeshInternalConnectivity.java b/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/FullMeshInternalConnectivity.java
new file mode 100644
index 0000000..c279def
--- /dev/null
+++ b/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/FullMeshInternalConnectivity.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2020-present Open Networking Foundation
+ *
+ * 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.
+
+ * This work was partially supported by EC H2020 project METRO-HAUL (761727).
+ */
+
+package org.onosproject.drivers.odtn;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.behaviour.InternalConnectivity;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+
+public class FullMeshInternalConnectivity
+    extends AbstractHandlerBehaviour implements InternalConnectivity {
+
+    /**
+     * Returnung true for all pairs this implements a device with full connectivity.
+     *
+     * @param inputPort in port
+     * @param outputPort out port
+     * @return true if connectivity is allowed
+     */
+    @Override
+    public boolean testConnectivity(PortNumber inputPort, PortNumber outputPort) {
+        //It is not allowed touse the same port as input and output
+        if (inputPort.equals(outputPort)) {
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * To be implemented.
+     *
+     * @param inputPort in port
+     * @return Set of out ports that can be connected to specified in port
+     */
+    @Override
+    public Set<PortNumber> getOutputPorts(PortNumber inputPort) {
+        Set<PortNumber> ports;
+
+        //Returns all the device ports, not including input port itself
+        DeviceService deviceService = this.handler().get(DeviceService.class);
+        ports = deviceService.getPorts(did()).stream()
+                .filter(p -> !p.equals(inputPort))
+                .map(p -> p.number())
+                .collect(Collectors.toSet());
+
+        return ports;
+    }
+
+    /**
+     * To be implemented.
+     *
+     * @param outputPort out port
+     * @return Set of in ports that can be connected to specified out port
+     */
+    @Override
+    public Set<PortNumber> getInputPorts(PortNumber outputPort) {
+        Set<PortNumber> ports;
+
+        //Returns all the device ports, not including output port itself
+        DeviceService deviceService = this.handler().get(DeviceService.class);
+        ports = deviceService.getPorts(did()).stream()
+                .filter(p -> !p.equals(outputPort))
+                .map(p -> p.number())
+                .collect(Collectors.toSet());
+
+        return ports;
+    }
+
+    /**
+     * Get the deviceId for which the methods apply.
+     *
+     * @return The deviceId as contained in the handler data
+     */
+    private DeviceId did() {
+        return handler().data().deviceId();
+    }
+}