And make Network.remove_network more robust.
Signed-off-by: Isaku Yamahata <[email protected]>
---
Changes v2 -> v3:
- new patch
---
ryu/controller/network.py | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/ryu/controller/network.py b/ryu/controller/network.py
index b029507..cf0772f 100644
--- a/ryu/controller/network.py
+++ b/ryu/controller/network.py
@@ -79,14 +79,15 @@ class Networks(dict):
def remove_network(self, network_id):
try:
- network = self[network_id]
+ ports = self[network_id]
except KeyError:
raise NetworkNotFound(network_id=network_id)
- for (dpid, port_no) in network:
- self.send_event(EventNetworkPort(network_id, dpid, port_no, False))
- self.send_event(EventNetworkDel(network_id))
- del self[network_id]
+ while ports:
+ (dpid, port_no) = ports.pop()
+ self._remove_event(network_id, dpid, port_no)
+ if self.pop(network_id, None) is not None:
+ self.send_event(EventNetworkDel(network_id))
def list_ports(self, network_id):
try:
@@ -107,11 +108,14 @@ class Networks(dict):
# self.add_raw(network_id, dpid, port_no)
# self.add_event(network_id, dpid, port_no)
+ def _remove_event(self, network_id, dpid, port_no):
+ self.send_event(EventNetworkPort(network_id, dpid, port_no, False))
+
def remove_raw(self, network_id, dpid, port_no):
ports = self[network_id]
if (dpid, port_no) in ports:
ports.remove((dpid, port_no))
- self.send_event(EventNetworkPort(network_id, dpid, port_no, False))
+ self._remove_event(network_id, dpid, port_no)
def remove(self, network_id, dpid, port_no):
try:
--
1.7.10.4
------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel