Add odtn-port-type attribute

Change-Id: Iecb2da0c1fa8fc3ead576ddef3f9fe2ac384c270
This commit is contained in:
Yuta HIGUCHI 2018-05-18 17:17:34 -07:00 committed by Yuta HIGUCHI
parent b0bc9da0b5
commit e4702afa63
2 changed files with 60 additions and 1 deletions

View File

@ -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.
* <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 @@ 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.
* <p>
* Optional if providing original implementation other than
* odtn-driver supplied driver.
*/
String ONOS_PORT_INDEX = "onos-index";

View File

@ -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