ONOS-5784: Empty latitude/longitude in ONOS Web UI
- (part one)
- Enhanced HostManager to react to NetworkConfigEvents such that
it applies annotations to relevant host instances from the
config data.
- A little refactoring in DeviceManager.
- Updated topoModel.js to use updated field names latOrY/longOrX.
Change-Id: I06536a6b2279291ffe638549a80b56a9fe94f48a
(cherry picked from commit 78193fd06661a7fa524c8b3a8fa7ddb69d7437c9)
diff --git a/core/net/src/main/java/org/onosproject/net/host/impl/BasicHostOperator.java b/core/net/src/main/java/org/onosproject/net/host/impl/BasicHostOperator.java
index 97b87f0..dd56217 100644
--- a/core/net/src/main/java/org/onosproject/net/host/impl/BasicHostOperator.java
+++ b/core/net/src/main/java/org/onosproject/net/host/impl/BasicHostOperator.java
@@ -18,6 +18,7 @@
import org.onlab.packet.IpAddress;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Host;
import org.onosproject.net.HostLocation;
import org.onosproject.net.SparseAnnotations;
import org.onosproject.net.config.basics.BasicHostConfig;
@@ -27,6 +28,8 @@
import java.util.Set;
+import static com.google.common.base.Preconditions.checkNotNull;
+
/**
* Implementations of merge policies for various sources of host configuration
* information. This includes applications, providers, and network configurations.
@@ -46,7 +49,7 @@
*/
public static HostDescription combine(BasicHostConfig cfg,
HostDescription descr) {
- if (cfg == null) {
+ if (cfg == null || descr == null) {
return descr;
}
@@ -64,8 +67,8 @@
SparseAnnotations sa = combine(cfg, descr.annotations());
return new DefaultHostDescription(descr.hwAddress(), descr.vlan(),
- location, ipAddresses,
- descr.configured(), sa);
+ location, ipAddresses,
+ descr.configured(), sa);
}
/**
@@ -82,4 +85,17 @@
return DefaultAnnotations.union(an, builder.build());
}
+
+ /**
+ * Returns a description of the given host.
+ *
+ * @param host the host
+ * @return a description of the host
+ */
+ public static HostDescription descriptionOf(Host host) {
+ checkNotNull(host, "Must supply a non-null Host");
+ return new DefaultHostDescription(host.mac(), host.vlan(), host.location(),
+ host.ipAddresses(), host.configured(),
+ (SparseAnnotations) host.annotations());
+ }
}