Config options: centralize base path configuration

This change moves all of the configuration options previously defined
in "nova/paths" to the new centralized "nova/conf" directory.
A subsequent patch will then improve the help texts.

As the helper functions to create specific directories are only used
for the default values of other config options, they got moved too.

The default value of the config option "pybasedir" gets determined by
the directory which contains it. The old directory was "nova/" and
new directory is "nova/conf/". That made it necessary to move one
additional directory upwards with "../../" to preserve the correct
default value.

bp centralize-config-options-newton

Change-Id: I65fc8d83da660e131e89ce5849e7535e969adcb2
This commit is contained in:
Markus Zoeller 2016-01-25 14:31:27 +01:00
parent a9459d3c41
commit c47b4299a0
18 changed files with 43 additions and 32 deletions

View File

@ -81,7 +81,6 @@ import nova.network.rpcapi
import nova.network.security_group.openstack_driver
import nova.notifications
import nova.objects.network
import nova.paths
import nova.pci.request
import nova.pci.whitelist
import nova.quota

View File

@ -67,6 +67,7 @@ from nova.compute import utils as compute_utils
from nova.compute import vm_states
from nova import conductor
import nova.conf
from nova.conf import paths
from nova import consoleauth
import nova.context
from nova import exception
@ -86,7 +87,6 @@ from nova import objects
from nova.objects import base as obj_base
from nova.objects import instance as obj_instance
from nova.objects import migrate_data as migrate_data_obj
from nova import paths
from nova import rpc
from nova import safe_utils
from nova.scheduler import client as scheduler_client

View File

@ -62,6 +62,7 @@ from nova.conf import neutron
from nova.conf import notifications
from nova.conf import novnc
# from nova.conf import osapi_v21
from nova.conf import paths
from nova.conf import pci
from nova.conf import quota
from nova.conf import rdp
@ -130,6 +131,7 @@ neutron.register_opts(CONF)
notifications.register_opts(CONF)
novnc.register_opts(CONF)
# osapi_v21.register_opts(CONF)
paths.register_opts(CONF)
pci.register_opts(CONF)
quota.register_opts(CONF)
rdp.register_opts(CONF)

View File

@ -14,8 +14,8 @@
from oslo_config import cfg
from nova.conf import paths
from nova.i18n import _
from nova import paths
cloudpipe_opts = [
cfg.StrOpt(

View File

@ -16,8 +16,8 @@ import os
from oslo_config import cfg
from nova.conf import paths
from nova.i18n import _
from nova import paths
crypto_opts_group = cfg.OptGroup(
'crypto',

View File

@ -15,7 +15,7 @@
from oslo_config import cfg
from nova import paths
from nova.conf import paths
network_opts = [

View File

@ -23,7 +23,7 @@ from oslo_config 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=os.path.join(sys.prefix, 'local', 'bin'),
@ -33,9 +33,6 @@ path_opts = [
help="Top-level directory for maintaining nova's state"),
]
CONF = cfg.CONF
CONF.register_opts(path_opts)
def basedir_def(*args):
"""Return an uninterpolated path relative to $pybasedir."""
@ -52,16 +49,27 @@ def state_path_def(*args):
return os.path.join('$state_path', *args)
# TODO(markus_z): This needs to be removed in a new patch. No one uses this.
def basedir_rel(*args):
"""Return a path relative to $pybasedir."""
return os.path.join(CONF.pybasedir, *args)
return os.path.join(cfg.CONF.pybasedir, *args)
# TODO(markus_z): This needs to be removed in a new patch. No one uses this.
def bindir_rel(*args):
"""Return a path relative to $bindir."""
return os.path.join(CONF.bindir, *args)
return os.path.join(cfg.CONF.bindir, *args)
# TODO(markus_z): This needs to be removed in a new patch. No one uses this.
def state_path_rel(*args):
"""Return a path relative to $state_path."""
return os.path.join(CONF.state_path, *args)
return os.path.join(cfg.CONF.state_path, *args)
def register_opts(conf):
conf.register_opts(path_opts)
def list_opts():
return {"DEFAULT": path_opts}

View File

@ -14,7 +14,7 @@
from oslo_config import cfg
from nova import paths
from nova.conf import paths
vcpu_pin_set = cfg.StrOpt(
'vcpu_pin_set',

View File

@ -13,7 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
from nova import paths
from nova.conf import paths
from oslo_config import cfg

View File

@ -21,8 +21,8 @@ from oslo_log import log
from nova.common import config
import nova.conf
from nova.conf import paths
from nova.db.sqlalchemy import api as sqlalchemy_api
from nova import paths
from nova import rpc
from nova import version

View File

@ -28,7 +28,6 @@ import nova.db.sqlalchemy.api
import nova.exception
import nova.image.download.file
import nova.netconf
import nova.paths
import nova.servicegroup.api
import nova.spice
import nova.volume
@ -46,7 +45,6 @@ def list_opts():
nova.db.sqlalchemy.api.db_opts,
nova.exception.exc_log_opts,
nova.netconf.netconf_opts,
nova.paths.path_opts,
nova.volume._volume_opts,
)),
('cinder', nova.volume.cinder.cinder_opts),

View File

@ -15,12 +15,12 @@
import os
import fixtures
from oslo_config import cfg
from nova import paths
import nova.conf
from nova.conf import paths
CONF = cfg.CONF
CONF = nova.conf.CONF
class ApiPasteV21Fixture(fixtures.Fixture):

View File

@ -18,9 +18,9 @@ from oslo_config import fixture as config_fixture
from oslo_policy import opts as policy_opts
import nova.conf
from nova.conf import paths
from nova import config
from nova import ipv6
from nova import paths
from nova.tests.unit import utils
CONF = nova.conf.CONF

View File

@ -15,16 +15,16 @@
import os
import fixtures
from oslo_config import cfg
from oslo_policy import policy as oslo_policy
from oslo_serialization import jsonutils
import six
from nova import paths
import nova.conf
from nova.conf import paths
import nova.policy
from nova.tests.unit import fake_policy
CONF = cfg.CONF
CONF = nova.conf.CONF
class RealPolicyFixture(fixtures.Fixture):

View File

@ -16,13 +16,14 @@ from oslo_config import cfg
from oslo_log import log as logging
import six
import nova.conf
from nova.conf import paths
from nova.i18n import _LE, _LW
from nova import paths
from nova import utils
from nova.virt.libvirt import utils as libvirt_utils
from nova.virt.libvirt.volume import fs
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.import_opt('qemu_allowed_storage_drivers',
'nova.virt.libvirt.volume.volume',
group='libvirt')

View File

@ -16,8 +16,9 @@ from oslo_config import cfg
from oslo_log import log as logging
import six
import nova.conf
from nova.conf import paths
from nova.i18n import _LE, _LW
from nova import paths
from nova import utils
from nova.virt.libvirt import utils as libvirt_utils
from nova.virt.libvirt.volume import fs
@ -34,7 +35,7 @@ volume_opts = [
'of the nfs man page for details'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(volume_opts, 'libvirt')

View File

@ -22,11 +22,12 @@ from oslo_log import log as logging
from oslo_utils import fileutils
import six
import nova.conf
from nova.conf import paths
from nova import exception as nova_exception
from nova.i18n import _
from nova.i18n import _LE
from nova.i18n import _LI
from nova import paths
from nova import utils
from nova.virt.libvirt import utils as libvirt_utils
from nova.virt.libvirt.volume import fs
@ -42,7 +43,7 @@ volume_opts = [
help='Path to a Quobyte Client configuration file.'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(volume_opts, 'libvirt')
SOURCE_PROTOCOL = 'quobyte'

View File

@ -14,7 +14,8 @@ import re
from oslo_config import cfg
from nova import paths
import nova.conf
from nova.conf import paths
from nova.virt.libvirt import utils as libvirt_utils
from nova.virt.libvirt.volume import fs
from nova.virt.libvirt.volume import remotefs
@ -31,7 +32,7 @@ volume_opts = [
'libvirt-qemu uid and gid must be specified.'),
]
CONF = cfg.CONF
CONF = nova.conf.CONF
CONF.register_opts(volume_opts, 'libvirt')
USERNAME_REGEX = re.compile(r"(user(?:name)?)=(?:[^ ,]+\\)?([^ ,]+)")