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 80309509f3..96d3b4ed44 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 @@ public interface OdtnDeviceDescriptionDiscovery /** * Annotations key intended for a Port, which stores OpenConfig component name. + *
+ * Optional; only for purpose of debugging. */ String OC_NAME = "oc-name"; /** * Annotations key intended for a Port, which stores OpenConfig component type. + *
+ * Optional; only for purpose of debugging. */ String OC_TYPE = "oc-type"; @@ -48,10 +54,59 @@ public interface OdtnDeviceDescriptionDiscovery */ 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. + *
+ * 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 ba9864188f..d59d5c0050 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 @@ public class OpenConfigDeviceDiscovery // 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