Move global path opts in nova.paths

Move the global path config options (i.e. state_path, pybasedir and
bindir) into a new nova.paths module. A new module may seem like
overkill but some utility methods associated with these options follow
in a later commit.

Moving them to nova.paths means they are no longer globally defined
and it's more obvious which modules require these options.

Change-Id: I381d23f1bbe36dc6967a38a65062b0983e1661aa
This commit is contained in:
Mark McLoughlin
2013-01-04 17:32:36 +00:00
parent 904814e51f
commit 2553b4a221
16 changed files with 53 additions and 28 deletions

View File

@@ -58,7 +58,7 @@ CONF.import_opt('ec2_dmz_host', 'nova.api.ec2.cloud')
CONF.import_opt('ec2_port', 'nova.api.ec2.cloud')
CONF.import_opt('vpn_image_id', 'nova.config')
CONF.import_opt('vpn_key_suffix', 'nova.config')
CONF.import_opt('pybasedir', 'nova.config')
CONF.import_opt('pybasedir', 'nova.paths')
CONF.import_opt('cnt_vpn_clients', 'nova.network.manager')
LOG = logging.getLogger(__name__)

View File

@@ -177,7 +177,7 @@ CONF.import_opt('network_manager', 'nova.config')
CONF.import_opt('reclaim_instance_interval', 'nova.config')
CONF.import_opt('vpn_image_id', 'nova.config')
CONF.import_opt('my_ip', 'nova.config')
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
QUOTAS = quota.QUOTAS

View File

@@ -43,21 +43,6 @@ def _get_my_ip():
return "127.0.0.1"
core_opts = [
cfg.StrOpt('pybasedir',
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
'../')),
help='Directory where the nova python module is installed'),
cfg.StrOpt('bindir',
default='$pybasedir/bin',
help='Directory where nova binaries are installed'),
cfg.StrOpt('state_path',
default='$pybasedir',
help="Top-level directory for maintaining nova's state"),
]
cfg.CONF.register_cli_opts(core_opts)
global_opts = [
cfg.StrOpt('my_ip',
default=_get_my_ip(),

View File

@@ -51,7 +51,7 @@ xvp_opts = [
CONF = cfg.CONF
CONF.register_opts(xvp_opts)
CONF.import_opt('host', 'nova.config')
CONF.import_opt('pybasedir', 'nova.config')
CONF.import_opt('pybasedir', 'nova.paths')
LOG = logging.getLogger(__name__)

View File

@@ -73,7 +73,7 @@ crypto_opts = [
CONF = cfg.CONF
CONF.register_opts(crypto_opts)
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
def ca_folder(project_id=None):

View File

@@ -290,7 +290,7 @@ sql_opts = [
CONF = cfg.CONF
CONF.register_opts(sql_opts)
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
LOG = logging.getLogger(__name__)
_ENGINE = None

View File

@@ -94,12 +94,12 @@ linux_net_opts = [
CONF = cfg.CONF
CONF.register_opts(linux_net_opts)
CONF.import_opt('bindir', 'nova.config')
CONF.import_opt('fake_network', 'nova.network.manager')
CONF.import_opt('host', 'nova.config')
CONF.import_opt('use_ipv6', 'nova.config')
CONF.import_opt('my_ip', 'nova.config')
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('bindir', 'nova.paths')
CONF.import_opt('state_path', 'nova.paths')
# NOTE(vish): Iptables supports chain names of up to 28 characters, and we

View File

@@ -64,7 +64,7 @@ s3_opts = [
CONF = cfg.CONF
CONF.register_opts(s3_opts)
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
def get_wsgi_server():

38
nova/paths.py Normal file
View File

@@ -0,0 +1,38 @@
# vim: tabstop=4 shiftwidth=4 softtabstop=4
# Copyright 2010 United States Government as represented by the
# Administrator of the National Aeronautics and Space Administration.
# All Rights Reserved.
# Copyright 2012 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import os
from nova.openstack.common import cfg
path_opts = [
cfg.StrOpt('pybasedir',
default=os.path.abspath(os.path.join(os.path.dirname(__file__),
'../')),
help='Directory where the nova python module is installed'),
cfg.StrOpt('bindir',
default='$pybasedir/bin',
help='Directory where nova binaries are installed'),
cfg.StrOpt('state_path',
default='$pybasedir',
help="Top-level directory for maintaining nova's state"),
]
CONF = cfg.CONF
CONF.register_opts(path_opts)

View File

@@ -57,7 +57,7 @@ CONF = cfg.CONF
CONF.register_opts(test_opts)
CONF.import_opt('sql_connection', 'nova.db.sqlalchemy.session')
CONF.import_opt('sqlite_db', 'nova.db.sqlalchemy.session')
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
CONF.set_override('use_stderr', False)
logging.setup('nova')

View File

@@ -24,7 +24,7 @@ from nova.openstack.common import cfg
from nova.tests.utils import cleanup_dns_managers
CONF = cfg.CONF
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
CONF.import_opt('scheduler_driver', 'nova.scheduler.manager')
CONF.import_opt('fake_network', 'nova.network.manager')
CONF.import_opt('network_size', 'nova.network.manager')

View File

@@ -37,7 +37,7 @@ CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.import_opt('sqlite_db', 'nova.db.sqlalchemy.session')
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
_ENGINE = None
_MAKER = None

View File

@@ -72,6 +72,7 @@ baremetal_group = cfg.OptGroup(name='baremetal',
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.import_opt('pybasedir', 'nova.paths')
DEFAULT_FIREWALL_DRIVER = "%s.%s" % (
firewall.__name__,

View File

@@ -54,6 +54,7 @@ baremetal_group = cfg.OptGroup(name='baremetal',
CONF = cfg.CONF
CONF.register_group(baremetal_group)
CONF.register_opts(opts, baremetal_group)
CONF.import_opt('state_path', 'nova.paths')
LOG = logging.getLogger(__name__)

View File

@@ -73,7 +73,7 @@ disk_opts = [
CONF = cfg.CONF
CONF.register_opts(disk_opts)
CONF.import_opt('pybasedir', 'nova.config')
CONF.import_opt('pybasedir', 'nova.paths')
_MKFS_COMMAND = {}
_DEFAULT_MKFS_COMMAND = None

View File

@@ -35,7 +35,7 @@ volume_opts = [
]
CONF = cfg.CONF
CONF.register_opts(volume_opts)
CONF.import_opt('state_path', 'nova.config')
CONF.import_opt('state_path', 'nova.paths')
class NfsVolumeDriver(volume.LibvirtVolumeDriver):