Edward Haas has uploaded a new change for review.

Change subject: net: Delete an OVS bridge when the last SB is detached.
......................................................................

net: Delete an OVS bridge when the last SB is detached.

Moving the action of deleting unused OVS bridges from
ovs_switch.cleanup() to the same location that the SB iface is detached.
As the topology defines a single SB per bridge, this approach is clean
and straightforward.

Change-Id: If1c3ba116be59e3e8716bfc949e2c7ee5b9990f8
Signed-off-by: Edward Haas <edwa...@redhat.com>
---
M lib/vdsm/network/netswitch.py
M lib/vdsm/network/ovs/switch.py
2 files changed, 2 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/92/64192/1

diff --git a/lib/vdsm/network/netswitch.py b/lib/vdsm/network/netswitch.py
index 529957a..787c687 100644
--- a/lib/vdsm/network/netswitch.py
+++ b/lib/vdsm/network/netswitch.py
@@ -177,7 +177,6 @@
             _setup_bonds(bonds2add, bonds2edit, bonds2remove, config, acq)
             _add_networks(nets2add, _ovs_info, config, acq)
 
-            ovs_switch.cleanup()
             setup_ipv6autoconf(networks)
             set_ovs_links_up(nets2add, bonds2add, bonds2edit)
             setup_ovs_ip_config(nets2add, nets2remove)
diff --git a/lib/vdsm/network/ovs/switch.py b/lib/vdsm/network/ovs/switch.py
index 1e16a88..7f84168 100644
--- a/lib/vdsm/network/ovs/switch.py
+++ b/lib/vdsm/network/ovs/switch.py
@@ -47,12 +47,6 @@
             bond, attrs, nets, ovs_networks, kernel_nics)
 
 
-def cleanup():
-    ovsdb = driver.create()
-    with ovsdb.transaction() as t:
-        t.add(*_cleanup_unused_bridges(ovsdb))
-
-
 def create_network_removal_setup(ovs_info):
     ovsdb = driver.create()
     return NetsRemovalSetup(ovsdb, ovs_info)
@@ -85,9 +79,10 @@
     def _detach_unused_southbound(self, sb):
         if sb and not self._ovs_info.northbounds_by_sb[sb]:
             self._ovs_info.northbounds_by_sb.pop(sb)
-            self._ovs_info.bridges_by_sb.pop(sb)
+            bridge_without_sb = self._ovs_info.bridges_by_sb.pop(sb)
 
             self._transaction.add(self._ovsdb.del_port(sb))
+            self._transaction.add(self._ovsdb.del_br(bridge_without_sb))
 
     @staticmethod
     def _get_southbound(net, running_networks):
@@ -187,26 +182,3 @@
 
 def _get_mac(iface):
     return link.get_link(iface)['address']
-
-
-def _cleanup_unused_bridges(ovsdb):
-    """
-    Remove bridges with no ports. Southbound ports are detached from bridge by
-    Setup.remove_bonds() and Setup.detach_unused_sb_nics(). Northbound ports
-    are detached by Setup.remove_nets().
-    """
-    return [ovsdb.del_br(bridge) for bridge in _unused_bridges()]
-
-
-# TODO: we can just check for bridges with no NB port
-def _unused_bridges():
-    unused_bridges = set()
-    ovs_info = info.OvsInfo()
-    for bridge, attrs in six.iteritems(ovs_info.bridges):
-        ports = attrs['ports']
-        northbound_ports = ovs_info.northbound_ports(ports)
-        southbound_port = ovs_info.southbound_port(ports)
-        if (bridge.startswith(BRIDGE_PREFIX) and not list(northbound_ports) and
-                not southbound_port):
-            unused_bridges.add(bridge)
-    return unused_bridges


-- 
To view, visit https://gerrit.ovirt.org/64192
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If1c3ba116be59e3e8716bfc949e2c7ee5b9990f8
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Edward Haas <edwa...@redhat.com>
_______________________________________________
vdsm-patches mailing list -- vdsm-patches@lists.fedorahosted.org
To unsubscribe send an email to vdsm-patches-le...@lists.fedorahosted.org

Reply via email to