Implementing region hosts for topology 2
Change-Id: I6d1e45b1152b2387d4ff981dc0666868235eb1c3
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
index 8c5107e..ff22116 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiHost.java
@@ -20,6 +20,7 @@
import org.onosproject.net.Host;
import org.onosproject.net.HostId;
import org.onosproject.net.PortNumber;
+import org.onosproject.net.region.RegionId;
import static com.google.common.base.MoreObjects.toStringHelper;
@@ -36,6 +37,7 @@
private PortNumber locPort;
private UiLinkId edgeLinkId;
+ private RegionId regionId;
/**
* Creates a new UI host.
@@ -70,6 +72,15 @@
return host.id();
}
+ /**
+ * Sets the ID of the region to which this device belongs.
+ *
+ * @param regionId region identifier
+ */
+ public void setRegionId(RegionId regionId) {
+ this.regionId = regionId;
+ }
+
@Override
public String idAsString() {
return id().toString();
diff --git a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
index 40dec55..7cd0da9 100644
--- a/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
+++ b/core/api/src/main/java/org/onosproject/ui/model/topo/UiRegion.java
@@ -241,6 +241,17 @@
return topology.deviceSet(deviceIds);
}
+
+ /**
+ * Make sure we have only these hosts in the region.
+ *
+ * @param hosts hosts in the region
+ */
+ public void reconcileHosts(Set<HostId> hosts) {
+ hostIds.clear();
+ hostIds.addAll(hosts);
+ }
+
/**
* Returns the set of host identifiers for this region.
*
@@ -260,6 +271,15 @@
}
/**
+ * Returns the count of devices in this region.
+ *
+ * @return the device count
+ */
+ public int hostCount() {
+ return hostIds.size();
+ }
+
+ /**
* Returns the order in which layers should be rendered. Lower layers
* come earlier in the list. For example, to indicate that nodes in the
* optical layer should be rendered "below" nodes in the packet layer,