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
This commit is contained in:
@@ -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")
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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',
|
||||
|
@@ -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',
|
||||
|
Reference in New Issue
Block a user