Add/Deactivate Switch, Port, Link
Change-Id: Iec8d5401eef0bdb1a3cad845f78f4e8fef7de856
diff --git a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/PortImpl.java b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/PortImpl.java
index 97ee8b5..de18631 100644
--- a/src/main/java/net/onrc/onos/ofcontroller/networkgraph/PortImpl.java
+++ b/src/main/java/net/onrc/onos/ofcontroller/networkgraph/PortImpl.java
@@ -1,5 +1,9 @@
package net.onrc.onos.ofcontroller.networkgraph;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
/**
* Port Object stored in In-memory Topology.
*
@@ -12,11 +16,13 @@
private Long number;
protected Link outgoingLink;
protected Link incomingLink;
+ protected Set<Device> devices;
public PortImpl(NetworkGraph graph, Switch parentSwitch, Long number) {
super(graph);
this.sw = parentSwitch;
this.number = number;
+ this.devices = new HashSet<>();
}
@Override
@@ -45,6 +51,11 @@
return incomingLink;
}
+ @Override
+ public Iterable<Device> getDevices() {
+ return Collections.unmodifiableSet(this.devices);
+ }
+
public void setOutgoingLink(Link link) {
outgoingLink = link;
}
@@ -53,6 +64,24 @@
incomingLink = link;
}
+ /**
+ *
+ * @param d
+ * @return true if successfully added
+ */
+ public boolean addDevice(Device d) {
+ return this.devices.add(d);
+ }
+
+ /**
+ *
+ * @param d
+ * @return true if device existed and was removed
+ */
+ public boolean removeDevice(Device d) {
+ return this.devices.remove(d);
+ }
+
@Override
public String toString() {
return String.format("%d:%d",