andrea
Committed by Gerrit Code Review

minor formatting changes

Change-Id: I361955b820489793ffb8f6b9b9ff24d429e1dd99
...@@ -25,8 +25,10 @@ package org.onosproject.net; ...@@ -25,8 +25,10 @@ package org.onosproject.net;
25 */ 25 */
26 public final class AnnotationKeys { 26 public final class AnnotationKeys {
27 27
28 +
28 // Prohibit instantiation 29 // Prohibit instantiation
29 - private AnnotationKeys() {} 30 + private AnnotationKeys() {
31 + }
30 32
31 /** 33 /**
32 * Annotation key for instance name. 34 * Annotation key for instance name.
...@@ -125,12 +127,22 @@ public final class AnnotationKeys { ...@@ -125,12 +127,22 @@ public final class AnnotationKeys {
125 public static final String OWNER = "owner"; 127 public static final String OWNER = "owner";
126 128
127 /** 129 /**
130 + * Annotation key for the channel id.
131 + */
132 + public static final String CHANNEL_ID = "channelId";
133 +
134 + /**
135 + * Annotation key for the management address.
136 + */
137 + public static final String MANAGEMENT_ADDRESS = "managementAddress";
138 +
139 + /**
128 * Returns the value annotated object for the specified annotation key. 140 * Returns the value annotated object for the specified annotation key.
129 * The annotated value is expected to be String that can be parsed as double. 141 * The annotated value is expected to be String that can be parsed as double.
130 * If parsing fails, the returned value will be 1.0. 142 * If parsing fails, the returned value will be 1.0.
131 * 143 *
132 * @param annotated annotated object whose annotated value is obtained 144 * @param annotated annotated object whose annotated value is obtained
133 - * @param key key of annotation 145 + * @param key key of annotation
134 * @return double value of annotated object for the specified key 146 * @return double value of annotated object for the specified key
135 */ 147 */
136 public static double getAnnotatedValue(Annotated annotated, String key) { 148 public static double getAnnotatedValue(Annotated annotated, String key) {
......
...@@ -25,6 +25,7 @@ public class BasicDeviceConfig extends BasicElementConfig<DeviceId> { ...@@ -25,6 +25,7 @@ public class BasicDeviceConfig extends BasicElementConfig<DeviceId> {
25 25
26 public static final String TYPE = "type"; 26 public static final String TYPE = "type";
27 public static final String DRIVER = "driver"; 27 public static final String DRIVER = "driver";
28 + public static final String MANAGEMENT_ADDRESS = "managementAddress";
28 29
29 /** 30 /**
30 * Returns the device type. 31 * Returns the device type.
...@@ -64,6 +65,25 @@ public class BasicDeviceConfig extends BasicElementConfig<DeviceId> { ...@@ -64,6 +65,25 @@ public class BasicDeviceConfig extends BasicElementConfig<DeviceId> {
64 return (BasicElementConfig) setOrClear(DRIVER, driverName); 65 return (BasicElementConfig) setOrClear(DRIVER, driverName);
65 } 66 }
66 67
68 + /**
69 + * Returns the device management ip (ip:port).
70 + *
71 + * @return device management address (ip:port) or null if not set
72 + */
73 + public String managementAddress() {
74 + return get(MANAGEMENT_ADDRESS, null);
75 + }
76 +
77 + /**
78 + * Sets the driver name.
79 + *
80 + * @param managementAddress new device management address (ip:port); null to clear
81 + * @return self
82 + */
83 + public BasicElementConfig managementAddress(String managementAddress) {
84 + return (BasicElementConfig) setOrClear(MANAGEMENT_ADDRESS, managementAddress);
85 + }
86 +
67 // TODO: device port meta-data to be configured via BasicPortsConfig 87 // TODO: device port meta-data to be configured via BasicPortsConfig
68 // TODO: device credentials/keys 88 // TODO: device credentials/keys
69 89
......
...@@ -15,21 +15,21 @@ ...@@ -15,21 +15,21 @@
15 */ 15 */
16 package org.onosproject.net.device.impl; 16 package org.onosproject.net.device.impl;
17 17
18 -import static org.slf4j.LoggerFactory.getLogger;
19 -import static com.google.common.base.Preconditions.checkNotNull;
20 -
21 -import org.onosproject.net.config.ConfigOperator;
22 -import org.onosproject.net.config.basics.BasicDeviceConfig;
23 import org.onosproject.net.AnnotationKeys; 18 import org.onosproject.net.AnnotationKeys;
24 import org.onosproject.net.DefaultAnnotations; 19 import org.onosproject.net.DefaultAnnotations;
25 import org.onosproject.net.Device; 20 import org.onosproject.net.Device;
26 import org.onosproject.net.SparseAnnotations; 21 import org.onosproject.net.SparseAnnotations;
22 +import org.onosproject.net.config.ConfigOperator;
23 +import org.onosproject.net.config.basics.BasicDeviceConfig;
27 import org.onosproject.net.device.DefaultDeviceDescription; 24 import org.onosproject.net.device.DefaultDeviceDescription;
28 import org.onosproject.net.device.DeviceDescription; 25 import org.onosproject.net.device.DeviceDescription;
29 import org.slf4j.Logger; 26 import org.slf4j.Logger;
30 27
31 import java.util.Objects; 28 import java.util.Objects;
32 29
30 +import static com.google.common.base.Preconditions.checkNotNull;
31 +import static org.slf4j.LoggerFactory.getLogger;
32 +
33 /** 33 /**
34 * Implementations of merge policies for various sources of device configuration 34 * Implementations of merge policies for various sources of device configuration
35 * information. This includes applications, provides, and network configurations. 35 * information. This includes applications, provides, and network configurations.
...@@ -46,7 +46,7 @@ public final class BasicDeviceOperator implements ConfigOperator { ...@@ -46,7 +46,7 @@ public final class BasicDeviceOperator implements ConfigOperator {
46 * Generates a DeviceDescription containing fields from a DeviceDescription and 46 * Generates a DeviceDescription containing fields from a DeviceDescription and
47 * a DeviceConfig. 47 * a DeviceConfig.
48 * 48 *
49 - * @param bdc the device config entity from network config 49 + * @param bdc the device config entity from network config
50 * @param descr a DeviceDescription 50 * @param descr a DeviceDescription
51 * @return DeviceDescription based on both sources 51 * @return DeviceDescription based on both sources
52 */ 52 */
...@@ -70,7 +70,7 @@ public final class BasicDeviceOperator implements ConfigOperator { ...@@ -70,7 +70,7 @@ public final class BasicDeviceOperator implements ConfigOperator {
70 * Generates an annotation from an existing annotation and DeviceConfig. 70 * Generates an annotation from an existing annotation and DeviceConfig.
71 * 71 *
72 * @param bdc the device config entity from network config 72 * @param bdc the device config entity from network config
73 - * @param an the annotation 73 + * @param an the annotation
74 * @return annotation combining both sources 74 * @return annotation combining both sources
75 */ 75 */
76 public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) { 76 public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) {
...@@ -93,6 +93,9 @@ public final class BasicDeviceOperator implements ConfigOperator { ...@@ -93,6 +93,9 @@ public final class BasicDeviceOperator implements ConfigOperator {
93 if (bdc.owner() != null) { 93 if (bdc.owner() != null) {
94 newBuilder.set(AnnotationKeys.OWNER, bdc.owner()); 94 newBuilder.set(AnnotationKeys.OWNER, bdc.owner());
95 } 95 }
96 + if (bdc.managementAddress() != null) {
97 + newBuilder.set(AnnotationKeys.MANAGEMENT_ADDRESS, bdc.managementAddress());
98 + }
96 DefaultAnnotations newAnnotations = newBuilder.build(); 99 DefaultAnnotations newAnnotations = newBuilder.build();
97 return DefaultAnnotations.union(an, newAnnotations); 100 return DefaultAnnotations.union(an, newAnnotations);
98 } 101 }
......
...@@ -323,8 +323,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr ...@@ -323,8 +323,9 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr
323 ChassisId cId = new ChassisId(dpid.value()); 323 ChassisId cId = new ChassisId(dpid.value());
324 324
325 SparseAnnotations annotations = DefaultAnnotations.builder() 325 SparseAnnotations annotations = DefaultAnnotations.builder()
326 - .set("protocol", sw.factory().getVersion().toString()) 326 + .set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString())
327 - .set("channelId", sw.channelId()) 327 + .set(AnnotationKeys.CHANNEL_ID, sw.channelId())
328 + .set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0])
328 .build(); 329 .build();
329 330
330 DeviceDescription description = 331 DeviceDescription description =
......