Created
September 8, 2015 20:33
-
-
Save mgagne/cbc9762cec9fa24294be to your computer and use it in GitHub Desktop.
neutron-linuxbridge-cleanup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From: =?UTF-8?q?Mathieu=20Gagn=C3=A9?= <mgagne@iweb.com> | |
Date: Mon, 11 May 2015 15:36:19 -0400 | |
Subject: Add empty bridge cleanup util | |
--- | |
neutron.egg-info/SOURCES.txt | 1 + | |
neutron/agent/lb_cleanup_util.py | 49 ++++++++++++++++++++++++++++++++++++++ | |
setup.cfg | 1 + | |
3 files changed, 51 insertions(+) | |
create mode 100644 neutron/agent/lb_cleanup_util.py | |
diff --git a/neutron.egg-info/SOURCES.txt b/neutron.egg-info/SOURCES.txt | |
index 97ed4e1..2f3178d 100644 | |
--- a/neutron.egg-info/SOURCES.txt | |
+++ b/neutron.egg-info/SOURCES.txt | |
@@ -231,6 +231,7 @@ neutron/agent/dhcp_agent.py | |
neutron/agent/firewall.py | |
neutron/agent/l2population_rpc.py | |
neutron/agent/l3_agent.py | |
+neutron/agent/lb_cleanup_util.py | |
neutron/agent/metadata_agent.py | |
neutron/agent/rpc.py | |
neutron/agent/securitygroups_rpc.py | |
diff --git a/neutron/agent/lb_cleanup_util.py b/neutron/agent/lb_cleanup_util.py | |
new file mode 100644 | |
index 0000000..057f829 | |
--- /dev/null | |
+++ b/neutron/agent/lb_cleanup_util.py | |
@@ -0,0 +1,49 @@ | |
+import sys | |
+ | |
+from oslo_config import cfg | |
+from oslo_log import log as logging | |
+ | |
+from neutron.common import config | |
+from neutron.common import utils as q_utils | |
+from neutron.i18n import _LE, _LI | |
+from neutron.plugins.linuxbridge.agent import linuxbridge_neutron_agent | |
+ | |
+ | |
+LOG = logging.getLogger(__name__) | |
+ | |
+ | |
+def setup_conf(): | |
+ conf = cfg.CONF | |
+ conf.import_opt('physical_interface_mappings', | |
+ 'neutron.plugins.linuxbridge.common.config', | |
+ group='LINUX_BRIDGE') | |
+ return conf | |
+ | |
+ | |
+def main(): | |
+ conf = setup_conf() | |
+ conf() | |
+ config.setup_logging() | |
+ | |
+ try: | |
+ interface_mappings = q_utils.parse_mappings( | |
+ conf.LINUX_BRIDGE.physical_interface_mappings) | |
+ except ValueError as e: | |
+ LOG.error(_LE("Parsing physical_interface_mappings failed: %s."), e) | |
+ sys.exit(1) | |
+ LOG.info(_LI("Interface mappings: %s"), interface_mappings) | |
+ | |
+ lb_manager = linuxbridge_neutron_agent.LinuxBridgeManager( | |
+ interface_mappings) | |
+ LOG.info(_LI("Agent initialized successfully, now running... ")) | |
+ | |
+ bridges = lb_manager.get_all_neutron_bridges() | |
+ for bridge in bridges: | |
+ if not lb_manager.get_tap_devices_count(bridge): | |
+ lb_manager.delete_vlan_bridge(bridge) | |
+ LOG.info(_LI("LinuxBridge cleanup completed successfully")) | |
+ sys.exit(0) | |
+ | |
+ | |
+if __name__ == "__main__": | |
+ main() | |
diff --git a/setup.cfg b/setup.cfg | |
index aa416c3..8404ff7 100644 | |
--- a/setup.cfg | |
+++ b/setup.cfg | |
@@ -100,6 +100,7 @@ console_scripts = | |
neutron-ibm-agent = neutron.plugins.ibm.agent.sdnve_neutron_agent:main | |
neutron-l3-agent = neutron.cmd.eventlet.agents.l3:main | |
neutron-linuxbridge-agent = neutron.plugins.linuxbridge.agent.linuxbridge_neutron_agent:main | |
+ neutron-linuxbridge-cleanup = neutron.agent.lb_cleanup_util:main | |
neutron-metadata-agent = neutron.cmd.eventlet.agents.metadata:main | |
neutron-mlnx-agent = neutron.cmd.eventlet.plugins.mlnx_neutron_agent:main | |
neutron-nec-agent = neutron.cmd.eventlet.plugins.nec_neutron_agent:main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment