odtn driver, don't search for onos-index while device discovery;
don't expect full element name "oc-platform-types:xxxx"
adapt integration tests to code change
Change-Id: I2f6c1e6ac75cf1ee564c3506c6065d8f8b8d3fde
diff --git a/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java b/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java
index 086c5ab..337a8a3 100644
--- a/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java
+++ b/drivers/odtn-driver/src/main/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscovery.java
@@ -24,6 +24,7 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import org.apache.commons.configuration.ConfigurationException;
@@ -61,6 +62,8 @@
 
     private static final Logger log = getLogger(OpenConfigDeviceDiscovery.class);
 
+    private static final AtomicInteger COUNTER = new AtomicInteger();
+
     @Override
     public DeviceDescription discoverDeviceDetails() {
         return new DefaultDeviceDescription(handler().data().deviceId().uri(),
@@ -165,18 +168,24 @@
             props.put(pName, pValue);
         });
 
+        PortNumber number = null;
+
         if (!props.containsKey(ONOS_PORT_INDEX)) {
             log.info("DEBUG: Component {} does not include onos-index, skipping", name);
             // ODTN: port must have onos-index property
-            return null;
+            number = PortNumber.portNumber(COUNTER.getAndIncrement(), name);
+        } else {
+            number = PortNumber.portNumber(Long.parseLong(props.get(ONOS_PORT_INDEX)), name);
         }
 
         Builder builder = DefaultPortDescription.builder();
-        builder.withPortNumber(PortNumber.portNumber(Long.parseLong(props.get(ONOS_PORT_INDEX)), name));
+        builder.withPortNumber(number);
 
         switch (type) {
-        case "oc-platform-types:PORT":
-        case "oc-opt-types:OPTICAL_CHANNEL":
+          case "oc-platform-types:PORT": case "PORT":
+
+
+          case "oc-opt-types:OPTICAL_CHANNEL": case "OPTICAL CHANNEL":
             // TODO assign appropriate port type & annotations at some point
             // for now we just need a Port with annotations
             builder.type(Type.OCH);
@@ -189,7 +198,7 @@
             props.putIfAbsent(CONNECTION_ID, "the-only-one");
             break;
 
-        case "oc-platform-types:TRANSCEIVER":
+          case "oc-platform-types:TRANSCEIVER": case "TRANSCEIVER":
             // TODO assign appropriate port type & annotations at some point
             // for now we just need a Port with annotations
             builder.type(Type.PACKET);
diff --git a/drivers/odtn-driver/src/test/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscoveryTest.java b/drivers/odtn-driver/src/test/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscoveryTest.java
index 4b2e1c4..64eb4e2 100644
--- a/drivers/odtn-driver/src/test/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscoveryTest.java
+++ b/drivers/odtn-driver/src/test/java/org/onosproject/drivers/odtn/OpenConfigDeviceDiscoveryTest.java
@@ -135,8 +135,8 @@
 
         List<PortDescription> ports = sut.discoverPorts(cfg);
 
-        assertThat(ports, hasSize(1));
-        PortDescription portDescription = ports.get(0);
+        assertThat(ports, hasSize(4));
+        PortDescription portDescription = ports.get(2);
         assertThat(portDescription.portNumber().toLong(), is(42L));
         assertThat(portDescription.portNumber().name(), is("TRANSCEIVER_1_1_4_1"));