minor formatting changes

Change-Id: I361955b820489793ffb8f6b9b9ff24d429e1dd99
This commit is contained in:
andrea 2015-10-06 15:51:25 -07:00 committed by Gerrit Code Review
parent 82fd63255c
commit fe3308fa13
4 changed files with 47 additions and 11 deletions

View File

@ -25,8 +25,10 @@ package org.onosproject.net;
*/ */
public final class AnnotationKeys { public final class AnnotationKeys {
// Prohibit instantiation // Prohibit instantiation
private AnnotationKeys() {} private AnnotationKeys() {
}
/** /**
* Annotation key for instance name. * Annotation key for instance name.
@ -124,13 +126,23 @@ public final class AnnotationKeys {
*/ */
public static final String OWNER = "owner"; public static final String OWNER = "owner";
/**
* Annotation key for the channel id.
*/
public static final String CHANNEL_ID = "channelId";
/**
* Annotation key for the management address.
*/
public static final String MANAGEMENT_ADDRESS = "managementAddress";
/** /**
* Returns the value annotated object for the specified annotation key. * Returns the value annotated object for the specified annotation key.
* The annotated value is expected to be String that can be parsed as double. * The annotated value is expected to be String that can be parsed as double.
* If parsing fails, the returned value will be 1.0. * If parsing fails, the returned value will be 1.0.
* *
* @param annotated annotated object whose annotated value is obtained * @param annotated annotated object whose annotated value is obtained
* @param key key of annotation * @param key key of annotation
* @return double value of annotated object for the specified key * @return double value of annotated object for the specified key
*/ */
public static double getAnnotatedValue(Annotated annotated, String key) { public static double getAnnotatedValue(Annotated annotated, String key) {

View File

@ -25,6 +25,7 @@ public class BasicDeviceConfig extends BasicElementConfig<DeviceId> {
public static final String TYPE = "type"; public static final String TYPE = "type";
public static final String DRIVER = "driver"; public static final String DRIVER = "driver";
public static final String MANAGEMENT_ADDRESS = "managementAddress";
/** /**
* Returns the device type. * Returns the device type.
@ -64,6 +65,25 @@ public class BasicDeviceConfig extends BasicElementConfig<DeviceId> {
return (BasicElementConfig) setOrClear(DRIVER, driverName); return (BasicElementConfig) setOrClear(DRIVER, driverName);
} }
/**
* Returns the device management ip (ip:port).
*
* @return device management address (ip:port) or null if not set
*/
public String managementAddress() {
return get(MANAGEMENT_ADDRESS, null);
}
/**
* Sets the driver name.
*
* @param managementAddress new device management address (ip:port); null to clear
* @return self
*/
public BasicElementConfig managementAddress(String managementAddress) {
return (BasicElementConfig) setOrClear(MANAGEMENT_ADDRESS, managementAddress);
}
// TODO: device port meta-data to be configured via BasicPortsConfig // TODO: device port meta-data to be configured via BasicPortsConfig
// TODO: device credentials/keys // TODO: device credentials/keys

View File

@ -15,21 +15,21 @@
*/ */
package org.onosproject.net.device.impl; package org.onosproject.net.device.impl;
import static org.slf4j.LoggerFactory.getLogger;
import static com.google.common.base.Preconditions.checkNotNull;
import org.onosproject.net.config.ConfigOperator;
import org.onosproject.net.config.basics.BasicDeviceConfig;
import org.onosproject.net.AnnotationKeys; import org.onosproject.net.AnnotationKeys;
import org.onosproject.net.DefaultAnnotations; import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device; import org.onosproject.net.Device;
import org.onosproject.net.SparseAnnotations; import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.config.ConfigOperator;
import org.onosproject.net.config.basics.BasicDeviceConfig;
import org.onosproject.net.device.DefaultDeviceDescription; import org.onosproject.net.device.DefaultDeviceDescription;
import org.onosproject.net.device.DeviceDescription; import org.onosproject.net.device.DeviceDescription;
import org.slf4j.Logger; import org.slf4j.Logger;
import java.util.Objects; import java.util.Objects;
import static com.google.common.base.Preconditions.checkNotNull;
import static org.slf4j.LoggerFactory.getLogger;
/** /**
* Implementations of merge policies for various sources of device configuration * Implementations of merge policies for various sources of device configuration
* information. This includes applications, provides, and network configurations. * information. This includes applications, provides, and network configurations.
@ -46,7 +46,7 @@ public final class BasicDeviceOperator implements ConfigOperator {
* Generates a DeviceDescription containing fields from a DeviceDescription and * Generates a DeviceDescription containing fields from a DeviceDescription and
* a DeviceConfig. * a DeviceConfig.
* *
* @param bdc the device config entity from network config * @param bdc the device config entity from network config
* @param descr a DeviceDescription * @param descr a DeviceDescription
* @return DeviceDescription based on both sources * @return DeviceDescription based on both sources
*/ */
@ -70,7 +70,7 @@ public final class BasicDeviceOperator implements ConfigOperator {
* Generates an annotation from an existing annotation and DeviceConfig. * Generates an annotation from an existing annotation and DeviceConfig.
* *
* @param bdc the device config entity from network config * @param bdc the device config entity from network config
* @param an the annotation * @param an the annotation
* @return annotation combining both sources * @return annotation combining both sources
*/ */
public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) { public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) {
@ -93,6 +93,9 @@ public final class BasicDeviceOperator implements ConfigOperator {
if (bdc.owner() != null) { if (bdc.owner() != null) {
newBuilder.set(AnnotationKeys.OWNER, bdc.owner()); newBuilder.set(AnnotationKeys.OWNER, bdc.owner());
} }
if (bdc.managementAddress() != null) {
newBuilder.set(AnnotationKeys.MANAGEMENT_ADDRESS, bdc.managementAddress());
}
DefaultAnnotations newAnnotations = newBuilder.build(); DefaultAnnotations newAnnotations = newBuilder.build();
return DefaultAnnotations.union(an, newAnnotations); return DefaultAnnotations.union(an, newAnnotations);
} }

View File

@ -323,8 +323,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
ChassisId cId = new ChassisId(dpid.value()); ChassisId cId = new ChassisId(dpid.value());
SparseAnnotations annotations = DefaultAnnotations.builder() SparseAnnotations annotations = DefaultAnnotations.builder()
.set("protocol", sw.factory().getVersion().toString()) .set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString())
.set("channelId", sw.channelId()) .set(AnnotationKeys.CHANNEL_ID, sw.channelId())
.set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0])
.build(); .build();
DeviceDescription description = DeviceDescription description =