minor formatting changes
Change-Id: I361955b820489793ffb8f6b9b9ff24d429e1dd99
diff --git a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
index 4949bc4..8c5fb79 100644
--- a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
+++ b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
@@ -25,8 +25,10 @@
*/
public final class AnnotationKeys {
+
// Prohibit instantiation
- private AnnotationKeys() {}
+ private AnnotationKeys() {
+ }
/**
* Annotation key for instance name.
@@ -125,12 +127,22 @@
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.
* The annotated value is expected to be String that can be parsed as double.
* If parsing fails, the returned value will be 1.0.
*
* @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
*/
public static double getAnnotatedValue(Annotated annotated, String key) {
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
index fd8bfa3..afde9a9 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
@@ -25,6 +25,7 @@
public static final String TYPE = "type";
public static final String DRIVER = "driver";
+ public static final String MANAGEMENT_ADDRESS = "managementAddress";
/**
* Returns the device type.
@@ -64,6 +65,25 @@
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 credentials/keys
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java b/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java
index 7900d18..fa90eb6 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/BasicDeviceOperator.java
@@ -15,21 +15,21 @@
*/
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.DefaultAnnotations;
import org.onosproject.net.Device;
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.DeviceDescription;
import org.slf4j.Logger;
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
* information. This includes applications, provides, and network configurations.
@@ -46,7 +46,7 @@
* Generates a DeviceDescription containing fields from a DeviceDescription and
* a DeviceConfig.
*
- * @param bdc the device config entity from network config
+ * @param bdc the device config entity from network config
* @param descr a DeviceDescription
* @return DeviceDescription based on both sources
*/
@@ -70,7 +70,7 @@
* Generates an annotation from an existing annotation and DeviceConfig.
*
* @param bdc the device config entity from network config
- * @param an the annotation
+ * @param an the annotation
* @return annotation combining both sources
*/
public static SparseAnnotations combine(BasicDeviceConfig bdc, SparseAnnotations an) {
@@ -93,6 +93,9 @@
if (bdc.owner() != null) {
newBuilder.set(AnnotationKeys.OWNER, bdc.owner());
}
+ if (bdc.managementAddress() != null) {
+ newBuilder.set(AnnotationKeys.MANAGEMENT_ADDRESS, bdc.managementAddress());
+ }
DefaultAnnotations newAnnotations = newBuilder.build();
return DefaultAnnotations.union(an, newAnnotations);
}
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 2108ba4..4fa961f 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -323,8 +323,9 @@
ChassisId cId = new ChassisId(dpid.value());
SparseAnnotations annotations = DefaultAnnotations.builder()
- .set("protocol", sw.factory().getVersion().toString())
- .set("channelId", sw.channelId())
+ .set(AnnotationKeys.PROTOCOL, sw.factory().getVersion().toString())
+ .set(AnnotationKeys.CHANNEL_ID, sw.channelId())
+ .set(AnnotationKeys.MANAGEMENT_ADDRESS, sw.channelId().split(":")[0])
.build();
DeviceDescription description =