Add state/status to Topology Element
Updated discovery to populate the status and config type
Changed status to admin status
Added to Kryo Serializer list
ONOS-1428
Change-Id: I38e5ecf2b45b95c148339d127d86592c0e9678ba
diff --git a/src/main/java/net/onrc/onos/core/topology/AdminStatus.java b/src/main/java/net/onrc/onos/core/topology/AdminStatus.java
new file mode 100644
index 0000000..be4eb0d
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/AdminStatus.java
@@ -0,0 +1,19 @@
+package net.onrc.onos.core.topology;
+
+/**
+ * Management status of this element.
+ * <p/>
+ * Note: This status only resembles ONOS's recognition of the element.
+ * This status is orthogonal to the operational state of the D-plane.
+ */
+public enum AdminStatus {
+ /**
+ * ONOS has discovered the element.
+ */
+ ACTIVE,
+ /**
+ * ONOS has not yet discovered the element
+ * or has observed that the element has disappeared.
+ */
+ INACTIVE
+}
diff --git a/src/main/java/net/onrc/onos/core/topology/ConfigState.java b/src/main/java/net/onrc/onos/core/topology/ConfigState.java
new file mode 100644
index 0000000..9d98f1a
--- /dev/null
+++ b/src/main/java/net/onrc/onos/core/topology/ConfigState.java
@@ -0,0 +1,15 @@
+package net.onrc.onos.core.topology;
+
+/**
+ * State to show configuration state of this element.
+ */
+public enum ConfigState {
+ /**
+ * Existence of the element was not configured, but discovered.
+ */
+ NOT_CONFIGURED,
+ /**
+ * Existence of the element was configured by operator.
+ */
+ CONFIGURED
+}
diff --git a/src/main/java/net/onrc/onos/core/topology/HostImpl.java b/src/main/java/net/onrc/onos/core/topology/HostImpl.java
index d0964a1..3120015 100644
--- a/src/main/java/net/onrc/onos/core/topology/HostImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/HostImpl.java
@@ -80,4 +80,24 @@
// FIXME assuming device is always in packet layer for now.
return TopologyElement.TYPE_PACKET_LAYER;
}
+
+ /**
+ * Returns the config state of topology element.
+ *
+ * @return ConfigState
+ */
+ @Override
+ public ConfigState getConfigState() {
+ return ConfigState.NOT_CONFIGURED;
+ }
+
+ /**
+ * Returns the status of topology element.
+ *
+ * @return AdminStatus
+ */
+ @Override
+ public AdminStatus getStatus() {
+ return AdminStatus.ACTIVE;
+ }
}
diff --git a/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java b/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java
index b9ce0d3..277c957 100644
--- a/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java
+++ b/src/main/java/net/onrc/onos/core/topology/ITopologyElement.java
@@ -13,4 +13,20 @@
* @return the type of the topology element
*/
public String getType();
+
+ /**
+ * Returns the config state of topology element.
+ *
+ * @return ConfigState
+ */
+ public ConfigState getConfigState();
+
+ /**
+ * Returns the status of topology element.
+ *
+ * @return AdminStatus
+ */
+ public AdminStatus getStatus();
+
+
}
diff --git a/src/main/java/net/onrc/onos/core/topology/LinkImpl.java b/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
index 8379279..dea629e 100644
--- a/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/LinkImpl.java
@@ -121,4 +121,24 @@
public String getType() {
return getStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
}
+
+ /**
+ * Returns the config state of topology element.
+ *
+ * @return ConfigState
+ */
+ @Override
+ public ConfigState getConfigState() {
+ return ConfigState.valueOf(getStringAttribute(TopologyElement.ELEMENT_CONFIG_STATE));
+ }
+
+ /**
+ * Returns the status of topology element.
+ *
+ * @return AdminStatus
+ */
+ @Override
+ public AdminStatus getStatus() {
+ return AdminStatus.valueOf(getStringAttribute(TopologyElement.ELEMENT_ADMIN_STATUS));
+ }
}
diff --git a/src/main/java/net/onrc/onos/core/topology/PortImpl.java b/src/main/java/net/onrc/onos/core/topology/PortImpl.java
index ec779e5..2521a9a 100644
--- a/src/main/java/net/onrc/onos/core/topology/PortImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/PortImpl.java
@@ -189,4 +189,25 @@
public String getType() {
return getStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
}
+
+ /**
+ * Returns the config state of topology element.
+ *
+ * @return ConfigState
+ */
+ @Override
+ public ConfigState getConfigState() {
+ return ConfigState.valueOf(getStringAttribute(TopologyElement.ELEMENT_CONFIG_STATE));
+
+ }
+
+ /**
+ * Returns the status of topology element.
+ *
+ * @return AdminStatus
+ */
+ @Override
+ public AdminStatus getStatus() {
+ return AdminStatus.valueOf(getStringAttribute(TopologyElement.ELEMENT_ADMIN_STATUS));
+ }
}
diff --git a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
index 6be8b13..de4194e 100644
--- a/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
+++ b/src/main/java/net/onrc/onos/core/topology/SwitchImpl.java
@@ -156,4 +156,24 @@
public String getType() {
return getStringAttribute(TopologyElement.TYPE, TopologyElement.TYPE_PACKET_LAYER);
}
+
+ /**
+ * Returns the config state of topology element.
+ *
+ * @return ConfigState
+ */
+ @Override
+ public ConfigState getConfigState() {
+ return ConfigState.valueOf(getStringAttribute(TopologyElement.ELEMENT_CONFIG_STATE));
+ }
+
+ /**
+ * Returns the status of topology element.
+ *
+ * @return AdminStatus
+ */
+ @Override
+ public AdminStatus getStatus() {
+ return AdminStatus.valueOf(getStringAttribute(TopologyElement.ELEMENT_ADMIN_STATUS));
+ }
}
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyElement.java b/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
index 685bc98..a9cfbf8 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyElement.java
@@ -34,6 +34,9 @@
*/
public static final String TYPE_OPTICAL_LAYER = "optical";
+ public static final String ELEMENT_CONFIG_STATE = "ConfigState";
+
+ public static final String ELEMENT_ADMIN_STATUS = "AdminStatus";
private boolean isFrozen = false;
@@ -59,6 +62,7 @@
public TopologyElement(TopologyElement<T> original) {
this.isFrozen = false;
this.stringAttributes = new ConcurrentHashMap<>(original.stringAttributes);
+
}
@@ -171,4 +175,25 @@
public String getType() {
return getStringAttribute(TYPE, TYPE_PACKET_LAYER);
}
+
+ /**
+ * Returns the config state of topology element.
+ *
+ * @return ConfigState
+ */
+ @Override
+ public ConfigState getConfigState() {
+ return ConfigState.valueOf(getStringAttribute(ELEMENT_CONFIG_STATE));
+ }
+
+ /**
+ * Returns the status of topology element.
+ *
+ * @return AdminStatus
+ */
+ @Override
+ public AdminStatus getStatus() {
+ return AdminStatus.valueOf(getStringAttribute(ELEMENT_ADMIN_STATUS));
+ }
+
}
diff --git a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
index 186aafb..f11c06d 100644
--- a/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
+++ b/src/main/java/net/onrc/onos/core/topology/TopologyPublisher.java
@@ -143,7 +143,10 @@
// TODO populate appropriate attributes.
linkEvent.createStringAttribute(TopologyElement.TYPE,
TopologyElement.TYPE_PACKET_LAYER);
-
+ linkEvent.createStringAttribute(TopologyElement.ELEMENT_CONFIG_STATE,
+ ConfigState.NOT_CONFIGURED.toString());
+ linkEvent.createStringAttribute(TopologyElement.ELEMENT_ADMIN_STATUS,
+ AdminStatus.ACTIVE.toString());
linkEvent.freeze();
if (!registryService.hasControl(link.getDst())) {
@@ -234,7 +237,10 @@
TopologyElement.TYPE_PACKET_LAYER);
switchEvent.createStringAttribute("ConnectedSince",
sw.getConnectedSince().toString());
-
+ switchEvent.createStringAttribute(TopologyElement.ELEMENT_CONFIG_STATE,
+ ConfigState.NOT_CONFIGURED.toString());
+ switchEvent.createStringAttribute(TopologyElement.ELEMENT_ADMIN_STATUS,
+ AdminStatus.ACTIVE.toString());
switchEvent.freeze();
// TODO Not very robust
@@ -253,6 +259,10 @@
portEvent.createStringAttribute("name", port.getName());
portEvent.createStringAttribute(TopologyElement.TYPE,
TopologyElement.TYPE_PACKET_LAYER);
+ portEvent.createStringAttribute(TopologyElement.ELEMENT_CONFIG_STATE,
+ ConfigState.NOT_CONFIGURED.toString());
+ portEvent.createStringAttribute(TopologyElement.ELEMENT_ADMIN_STATUS,
+ AdminStatus.ACTIVE.toString());
portEvent.freeze();
portEvents.add(portEvent);
diff --git a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
index 18de585..d5482ec 100644
--- a/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
+++ b/src/main/java/net/onrc/onos/core/util/serializers/KryoFactory.java
@@ -25,12 +25,14 @@
import net.onrc.onos.core.packetservice.BroadcastPacketOutNotification;
import net.onrc.onos.core.packetservice.PacketOutNotification;
import net.onrc.onos.core.packetservice.SinglePacketOutNotification;
+import net.onrc.onos.core.topology.AdminStatus;
+import net.onrc.onos.core.topology.ConfigState;
import net.onrc.onos.core.topology.HostEvent;
import net.onrc.onos.core.topology.LinkEvent;
import net.onrc.onos.core.topology.PortEvent;
import net.onrc.onos.core.topology.SwitchEvent;
-import net.onrc.onos.core.topology.TopologyEvent;
import net.onrc.onos.core.topology.TopologyElement;
+import net.onrc.onos.core.topology.TopologyEvent;
import net.onrc.onos.core.util.CallerId;
import net.onrc.onos.core.util.DataPath;
import net.onrc.onos.core.util.Dpid;
@@ -205,6 +207,8 @@
kryo.register(TopologyEvent.class);
kryo.register(TopologyElement.class);
kryo.register(ConcurrentHashMap.class);
+ kryo.register(ConfigState.class);
+ kryo.register(AdminStatus.class);
// Intent-related classes
kryo.register(Path.class);