From 62b18ebb683ece2e0366f754157a89f67e8532ab Mon Sep 17 00:00:00 2001 From: Brent Eagles Date: Fri, 22 Feb 2013 17:57:33 -0330 Subject: Change nova-dhcpbridge FLAGFILE to a list of files This patch adds support to linux_net and nova-dhcpbridge for specifying and conveying multiple dhcpbridge_flagfile values. The support is implemented as follows: dhcpbridge_flagfile is now a "MultiStr" configuration file option allowing the flag files to be defined over multiple configuration files. The configured files are concatenated into a comma separated string and assigned to the FLAGFILE environment variable when invoking nova-dhcpbridge. nova-dhcpbridge splits the value of the environment variable on the comma an initializes its configuration with the provided files (the configuration system already supports loading configuration from multiple files) Fixes bug 1131932 Change-Id: Ic9cc57b8f7d9356606b9134ef5b63ab07b6099d9 --- bin/nova-dhcpbridge | 4 +++- etc/nova/nova.conf.sample | 2 +- nova/network/linux_net.py | 9 +++++---- nova/tests/network/test_linux_net.py | 3 ++- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bin/nova-dhcpbridge b/bin/nova-dhcpbridge index c00578821..1acaf4cd1 100755 --- a/bin/nova-dhcpbridge +++ b/bin/nova-dhcpbridge @@ -42,6 +42,7 @@ from nova import context from nova import db from nova.network import rpcapi as network_rpcapi from nova.openstack.common import importutils +from nova.openstack.common import jsonutils from nova.openstack.common import log as logging from nova.openstack.common import rpc @@ -121,7 +122,8 @@ def main(): except KeyError: config_file = os.environ['FLAGFILE'] - config.parse_args(sys.argv, default_config_files=[config_file]) + config.parse_args(sys.argv, + default_config_files=jsonutils.loads(config_file)) logging.setup("nova") diff --git a/etc/nova/nova.conf.sample b/etc/nova/nova.conf.sample index 9cbb8c1a5..a094469f7 100644 --- a/etc/nova/nova.conf.sample +++ b/etc/nova/nova.conf.sample @@ -970,7 +970,7 @@ # Options defined in nova.network.linux_net # -# location of flagfile for dhcpbridge (string value) +# location of flagfile(s) for dhcpbridge (multi valued) #dhcpbridge_flagfile=/etc/nova/nova-dhcpbridge.conf # Location to keep network config files (string value) diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 29b882a02..5c20f9ce8 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -31,6 +31,7 @@ from nova import db from nova import exception from nova.openstack.common import fileutils from nova.openstack.common import importutils +from nova.openstack.common import jsonutils from nova.openstack.common import lockutils from nova.openstack.common import log as logging from nova.openstack.common import timeutils @@ -41,9 +42,9 @@ LOG = logging.getLogger(__name__) linux_net_opts = [ - cfg.StrOpt('dhcpbridge_flagfile', - default='/etc/nova/nova-dhcpbridge.conf', - help='location of flagfile for dhcpbridge'), + cfg.MultiStrOpt('dhcpbridge_flagfile', + default=['/etc/nova/nova-dhcpbridge.conf'], + help='location of flagfiles for dhcpbridge'), cfg.StrOpt('networks_path', default=paths.state_path_def('networks'), help='Location to keep network config files'), @@ -994,7 +995,7 @@ def restart_dhcp(context, dev, network_ref): LOG.debug(_('Pid %d is stale, relaunching dnsmasq'), pid) cmd = ['env', - 'CONFIG_FILE=%s' % CONF.dhcpbridge_flagfile, + 'CONFIG_FILE=%s' % jsonutils.dumps(CONF.dhcpbridge_flagfile), 'NETWORK_ID=%s' % str(network_ref['id']), 'dnsmasq', '--strict-order', diff --git a/nova/tests/network/test_linux_net.py b/nova/tests/network/test_linux_net.py index cba08d9ce..4eac0c88c 100644 --- a/nova/tests/network/test_linux_net.py +++ b/nova/tests/network/test_linux_net.py @@ -26,6 +26,7 @@ from nova import db from nova.network import driver from nova.network import linux_net from nova.openstack.common import fileutils +from nova.openstack.common import jsonutils from nova.openstack.common import log as logging from nova.openstack.common import timeutils from nova import test @@ -496,7 +497,7 @@ class LinuxNetworkTestCase(test.TestCase): dev = 'br100' linux_net.restart_dhcp(self.context, dev, network_ref) expected = ['env', - 'CONFIG_FILE=%s' % CONF.dhcpbridge_flagfile, + 'CONFIG_FILE=%s' % jsonutils.dumps(CONF.dhcpbridge_flagfile), 'NETWORK_ID=fake', 'dnsmasq', '--strict-order', -- cgit