summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrent Eagles <beagles@redhat.com>2013-02-22 17:57:33 -0330
committerBrent Eagles <beagles@redhat.com>2013-02-24 23:41:56 -0330
commit62b18ebb683ece2e0366f754157a89f67e8532ab (patch)
tree72fe3fd305322cf6e48f7927ee063bba73be6605
parent95b7d2c06eaebfd974eae3cd7ddf707bed332f47 (diff)
downloadnova-62b18ebb683ece2e0366f754157a89f67e8532ab.tar.gz
nova-62b18ebb683ece2e0366f754157a89f67e8532ab.tar.xz
nova-62b18ebb683ece2e0366f754157a89f67e8532ab.zip
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
-rwxr-xr-xbin/nova-dhcpbridge4
-rw-r--r--etc/nova/nova.conf.sample2
-rw-r--r--nova/network/linux_net.py9
-rw-r--r--nova/tests/network/test_linux_net.py3
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',