Add odtn-port-type attribute
Change-Id: Iecb2da0c1fa8fc3ead576ddef3f9fe2ac384c270
diff --git a/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
index 8030950..96d3b4e 100644
--- a/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
+++ b/apps/odtn/api/src/main/java/org/onosproject/odtn/behaviour/OdtnDeviceDescriptionDiscovery.java
@@ -15,6 +15,8 @@
*/
package org.onosproject.odtn.behaviour;
+import static com.google.common.base.Preconditions.checkNotNull;
+
import java.util.List;
import org.onosproject.net.device.DeviceDescriptionDiscovery;
@@ -33,11 +35,15 @@
/**
* Annotations key intended for a Port, which stores OpenConfig component name.
+ * <p>
+ * Optional; only for purpose of debugging.
*/
String OC_NAME = "oc-name";
/**
* Annotations key intended for a Port, which stores OpenConfig component type.
+ * <p>
+ * Optional; only for purpose of debugging.
*/
String OC_TYPE = "oc-type";
@@ -48,10 +54,59 @@
*/
String CONNECTION_ID = "odtn-connection-id";
+ /**
+ * Annotations key for a Port,
+ * which describes role of the port annotated.
+ * Value must be one of “client” or “line”.
+ *
+ * @see OdtnPortType
+ */
+ String PORT_TYPE = "odtn-port-type";
+
+ enum OdtnPortType {
+ CLIENT("client"),
+ LINE("line");
+
+ private final String value;
+
+ OdtnPortType(String value) {
+ this.value = value;
+ }
+
+ /**
+ * Returns the value to be used as Annotations value.
+ * @return value
+ */
+ public String value() {
+ return value;
+ }
+
+ /**
+ * Returns the corresponding enum value from a string value.
+ * @param value to look up
+ * @return OdtnPortType
+ *
+ * @throws NullPointerException if {@code value} was null
+ * @throws IllegalArgumentException if non-OdtnPortValue was given
+ */
+ public static OdtnPortType fromValue(String value) {
+ checkNotNull(value);
+ if (value.equalsIgnoreCase(CLIENT.value())) {
+ return CLIENT;
+ } else if (value.equalsIgnoreCase(LINE.value())) {
+ return LINE;
+ } else {
+ throw new IllegalArgumentException("Invalid value: " + value);
+ }
+ }
+ }
/**
* OpenConfig component property name to store,
* decimal integer index to be used when creating PortNumber.
+ * <p>
+ * Optional if providing original implementation other than
+ * odtn-driver supplied driver.
*/
String ONOS_PORT_INDEX = "onos-index";
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 ba98641..d59d5c0 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
@@ -179,17 +179,21 @@
// for now we just need a Port with annotations
builder.type(Type.OCH);
+ props.putIfAbsent(PORT_TYPE, OdtnPortType.LINE.value());
+
// Just a heuristics to deal with simple transponder
// if the device declare odtn-connection-id, just use them
// if not assign same value to relevant ports types
props.putIfAbsent(CONNECTION_ID, "the-only-one");
break;
+
case "oc-platform-types:TRANSCEIVER":
- //case "oc-opt-types:OPTICAL_CHANNEL":
// TODO assign appropriate port type & annotations at some point
// for now we just need a Port with annotations
builder.type(Type.PACKET);
+ props.putIfAbsent(PORT_TYPE, OdtnPortType.CLIENT.value());
+
// Just a heuristics to deal with simple transponder
// if the device declare odtn-connection-id, just use them
// if not assign same value to relevant ports types