Merge "Add helper methods to nova.paths"

This commit is contained in:
Jenkins 2013-01-08 05:51:56 +00:00 committed by Gerrit Code Review
commit 2f5a9ae471
15 changed files with 65 additions and 37 deletions

View File

@ -34,6 +34,7 @@ from nova import exception
from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
@ -42,7 +43,7 @@ cloudpipe_opts = [
default='m1.tiny',
help=_('Instance type for vpn instances')),
cfg.StrOpt('boot_script_template',
default='$pybasedir/nova/cloudpipe/bootscript.template',
default=paths.basedir_def('nova/cloudpipe/bootscript.template'),
help=_('Template for cloudpipe instance boot script')),
cfg.StrOpt('dmz_net',
default='10.0.0.0',
@ -58,7 +59,6 @@ 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.paths')
CONF.import_opt('cnt_vpn_clients', 'nova.network.manager')
LOG = logging.getLogger(__name__)

View File

@ -68,6 +68,7 @@ from nova.openstack.common.notifier import api as notifier
from nova.openstack.common import rpc
from nova.openstack.common.rpc import common as rpc_common
from nova.openstack.common import timeutils
from nova import paths
from nova import quota
from nova.scheduler import rpcapi as scheduler_rpcapi
from nova import utils
@ -91,7 +92,7 @@ compute_opts = [
' during a host restart and apply all at the end of the'
' init phase'),
cfg.StrOpt('instances_path',
default='$state_path/instances',
default=paths.state_path_def('instances'),
help='where instances are stored on disk'),
cfg.BoolOpt('instance_usage_audit',
default=False,
@ -178,7 +179,6 @@ 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.paths')
QUOTAS = quota.QUOTAS

View File

@ -27,12 +27,13 @@ from nova import db
from nova import exception
from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
xvp_opts = [
cfg.StrOpt('console_xvp_conf_template',
default='$pybasedir/nova/console/xvp.conf.template',
default=paths.basedir_def('nova/console/xvp.conf.template'),
help='XVP conf template'),
cfg.StrOpt('console_xvp_conf',
default='/etc/xvp.conf',
@ -51,7 +52,6 @@ xvp_opts = [
CONF = cfg.CONF
CONF.register_opts(xvp_opts)
CONF.import_opt('host', 'nova.config')
CONF.import_opt('pybasedir', 'nova.paths')
LOG = logging.getLogger(__name__)

View File

@ -35,6 +35,7 @@ from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova import paths
from nova import utils
@ -51,10 +52,10 @@ crypto_opts = [
default='crl.pem',
help=_('Filename of root Certificate Revocation List')),
cfg.StrOpt('keys_path',
default='$state_path/keys',
default=paths.state_path_def('keys'),
help=_('Where we keep our keys')),
cfg.StrOpt('ca_path',
default='$state_path/CA',
default=paths.state_path_def('CA'),
help=_('Where we keep our root CA')),
cfg.BoolOpt('use_project_ca',
default=False,
@ -73,7 +74,6 @@ crypto_opts = [
CONF = cfg.CONF
CONF.register_opts(crypto_opts)
CONF.import_opt('state_path', 'nova.paths')
def ca_folder(project_id=None):

View File

@ -242,11 +242,12 @@ from nova.exception import InvalidUnicodeParameter
from nova.openstack.common import cfg
import nova.openstack.common.log as logging
from nova.openstack.common import timeutils
from nova import paths
sql_opts = [
cfg.StrOpt('sql_connection',
default='sqlite:///$state_path/$sqlite_db',
default='sqlite:///' + paths.state_path_def('$sqlite_db'),
help='The SQLAlchemy connection string used to connect to the '
'database'),
cfg.StrOpt('sqlite_db',
@ -290,7 +291,6 @@ sql_opts = [
CONF = cfg.CONF
CONF.register_opts(sql_opts)
CONF.import_opt('state_path', 'nova.paths')
LOG = logging.getLogger(__name__)
_ENGINE = None

View File

@ -31,6 +31,7 @@ from nova.openstack.common import fileutils
from nova.openstack.common import importutils
from nova.openstack.common import lockutils
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
@ -42,7 +43,7 @@ linux_net_opts = [
default='/etc/nova/nova-dhcpbridge.conf',
help='location of flagfile for dhcpbridge'),
cfg.StrOpt('networks_path',
default='$state_path/networks',
default=paths.state_path_def('networks'),
help='Location to keep network config files'),
cfg.StrOpt('public_interface',
default='eth0',
@ -51,7 +52,7 @@ linux_net_opts = [
default=None,
help='MTU setting for vlan'),
cfg.StrOpt('dhcpbridge',
default='$bindir/nova-dhcpbridge',
default=paths.bindir_def('nova-dhcpbridge'),
help='location of nova-dhcpbridge'),
cfg.StrOpt('routing_source_ip',
default='$my_ip',
@ -94,12 +95,9 @@ linux_net_opts = [
CONF = cfg.CONF
CONF.register_opts(linux_net_opts)
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('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

@ -46,13 +46,14 @@ import webob
from nova.openstack.common import cfg
from nova.openstack.common import fileutils
from nova import paths
from nova import utils
from nova import wsgi
s3_opts = [
cfg.StrOpt('buckets_path',
default='$state_path/buckets',
default=paths.state_path_def('buckets'),
help='path to s3 buckets'),
cfg.StrOpt('s3_listen',
default="0.0.0.0",
@ -64,7 +65,6 @@ s3_opts = [
CONF = cfg.CONF
CONF.register_opts(s3_opts)
CONF.import_opt('state_path', 'nova.paths')
def get_wsgi_server():

View File

@ -36,3 +36,33 @@ path_opts = [
CONF = cfg.CONF
CONF.register_opts(path_opts)
def basedir_def(*args):
"""Return an uninterpolated path relative to $pybasedir."""
return os.path.join('$pybasedir', *args)
def bindir_def(*args):
"""Return an uninterpolated path relative to $bindir."""
return os.path.join('$bindir', *args)
def state_path_def(*args):
"""Return an uninterpolated path relative to $state_path."""
return os.path.join('$state_path', *args)
def basedir_rel(*args):
"""Return a path relative to $pybasedir."""
return os.path.join(CONF.pybasedir, *args)
def bindir_rel(*args):
"""Return a path relative to $bindir."""
return os.path.join(CONF.bindir, *args)
def state_path_rel(*args):
"""Return a path relative to $state_path."""
return os.path.join(CONF.state_path, *args)

View File

@ -42,6 +42,7 @@ from nova.network import manager as network_manager
from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova.openstack.common import timeutils
from nova import paths
from nova import service
from nova.tests import conf_fixture
from nova.tests import policy_fixture
@ -57,7 +58,6 @@ 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.paths')
CONF.set_override('use_stderr', False)
logging.setup('nova')
@ -83,7 +83,7 @@ class Database(fixtures.Fixture):
if db_migrate.db_version() > db_migrate.INIT_VERSION:
return
else:
testdb = os.path.join(CONF.state_path, sqlite_db)
testdb = paths.state_path_rel(sqlite_db)
if os.path.exists(testdb):
return
db_migrate.db_sync()
@ -93,7 +93,7 @@ class Database(fixtures.Fixture):
self._DB = "".join(line for line in conn.connection.iterdump())
self.engine.dispose()
else:
cleandb = os.path.join(CONF.state_path, sqlite_clean_db)
cleandb = paths.state_path_rel(sqlite_clean_db)
shutil.copyfile(testdb, cleandb)
def setUp(self):
@ -104,10 +104,8 @@ class Database(fixtures.Fixture):
conn.connection.executescript(self._DB)
self.addCleanup(self.engine.dispose)
else:
shutil.copyfile(os.path.join(CONF.state_path,
self.sqlite_clean_db),
os.path.join(CONF.state_path,
self.sqlite_db))
shutil.copyfile(paths.state_path_rel(self.sqlite_clean_db),
paths.state_path_rel(self.sqlite_db))
def post_migrations(self):
"""Any addition steps that are needed outside of the migrations."""

View File

@ -21,10 +21,10 @@ import fixtures
from nova import config
from nova import ipv6
from nova.openstack.common import cfg
from nova import paths
from nova.tests.utils import cleanup_dns_managers
CONF = cfg.CONF
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')
@ -46,7 +46,7 @@ class ConfFixture(fixtures.Fixture):
super(ConfFixture, self).setUp()
self.conf.set_default('api_paste_config',
'$state_path/etc/nova/api-paste.ini')
paths.state_path_def('etc/nova/api-paste.ini'))
self.conf.set_default('compute_driver', 'nova.virt.fake.FakeDriver')
self.conf.set_default('fake_network', True)
self.conf.set_default('fake_rabbit', True)

View File

@ -21,10 +21,12 @@
from nova.db.sqlalchemy import session as nova_session
from nova.openstack.common import cfg
from nova import paths
opts = [
cfg.StrOpt('sql_connection',
default='sqlite:///$state_path/baremetal_$sqlite_db',
default=('sqlite:///' +
paths.state_path_def('baremetal_$sqlite_db')),
help='The SQLAlchemy connection string used to connect to the '
'bare-metal database'),
]
@ -37,7 +39,6 @@ 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.paths')
_ENGINE = None
_MAKER = None

View File

@ -27,6 +27,7 @@ from nova import exception
from nova.openstack.common import cfg
from nova.openstack.common import importutils
from nova.openstack.common import log as logging
from nova import paths
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import db
from nova.virt import driver
@ -38,7 +39,8 @@ opts = [
default=True,
help='Whether baremetal compute injects password or not'),
cfg.StrOpt('injected_network_template',
default='$pybasedir/nova/virt/baremetal/interfaces.template',
default=paths.basedir_def('nova/virt/'
'baremetal/interfaces.template'),
help='Template file for injected network'),
cfg.StrOpt('vif_driver',
default='nova.virt.baremetal.vif_driver.BareMetalVIFDriver',
@ -72,7 +74,6 @@ 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

@ -28,6 +28,7 @@ import tempfile
from nova.exception import InvalidParameterValue
from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
from nova.virt.baremetal import baremetal_states
from nova.virt.baremetal import base
@ -41,7 +42,7 @@ opts = [
default=None,
help='path to baremetal terminal SSL cert(PEM)'),
cfg.StrOpt('terminal_pid_dir',
default='$state_path/baremetal/console',
default=paths.state_path_def('baremetal/console'),
help='path to directory stores pidfiles of baremetal_terminal'),
cfg.IntOpt('ipmi_power_retry',
default=5,
@ -54,7 +55,6 @@ 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

@ -36,6 +36,7 @@ from nova import exception
from nova.openstack.common import cfg
from nova.openstack.common import jsonutils
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
from nova.virt.disk.mount import api as mount
from nova.virt.disk.vfs import api as vfs
@ -46,7 +47,7 @@ LOG = logging.getLogger(__name__)
disk_opts = [
cfg.StrOpt('injected_network_template',
default='$pybasedir/nova/virt/interfaces.template',
default=paths.basedir_def('nova/virt/interfaces.template'),
help='Template file for injected network'),
# NOTE(yamahata): ListOpt won't work because the command may include a
@ -73,7 +74,6 @@ disk_opts = [
CONF = cfg.CONF
CONF.register_opts(disk_opts)
CONF.import_opt('pybasedir', 'nova.paths')
_MKFS_COMMAND = {}
_DEFAULT_MKFS_COMMAND = None

View File

@ -23,6 +23,7 @@ import os
from nova import exception
from nova.openstack.common import cfg
from nova.openstack.common import log as logging
from nova import paths
from nova import utils
from nova.virt.libvirt import volume
@ -30,12 +31,11 @@ LOG = logging.getLogger(__name__)
volume_opts = [
cfg.StrOpt('nfs_mount_point_base',
default='$state_path/mnt',
default=paths.state_path_def('mnt'),
help='Base dir where nfs expected to be mounted on compute'),
]
CONF = cfg.CONF
CONF.register_opts(volume_opts)
CONF.import_opt('state_path', 'nova.paths')
class NfsVolumeDriver(volume.LibvirtVolumeDriver):