Add pybasedir and bindir options

Add a pybasedir option so that it can be used for interpolation in the
default values of other options. This helps eliminate hard-coded paths
from the sample config file.

Also add a bindir option for similar reasons, but it also helps with
packaging.

Change-Id: Iadc746dcf2a24adbdf9bac945b5b330f01faeeb5
This commit is contained in:
Mark McLoughlin 2012-03-09 11:05:13 +00:00
parent 17396f6a08
commit 5aef0e1341
9 changed files with 18 additions and 20 deletions

View File

@ -63,10 +63,10 @@ auth_opts = [
help='Roles that apply to all projects'), help='Roles that apply to all projects'),
cfg.StrOpt('credentials_template', cfg.StrOpt('credentials_template',
default=utils.abspath('auth/novarc.template'), default='$pybasedir/nova/auth/novarc.template',
help='Template for creating users rc file'), help='Template for creating users rc file'),
cfg.StrOpt('vpn_client_template', cfg.StrOpt('vpn_client_template',
default=utils.abspath('cloudpipe/client.ovpn.template'), default='$pybasedir/nova/cloudpipe/client.ovpn.template',
help='Template for creating users vpn file'), help='Template for creating users vpn file'),
cfg.StrOpt('credential_vpn_file', cfg.StrOpt('credential_vpn_file',
default='nova-vpn.conf', default='nova-vpn.conf',

View File

@ -45,7 +45,7 @@ cloudpipe_opts = [
default='m1.tiny', default='m1.tiny',
help=_('Instance type for vpn instances')), help=_('Instance type for vpn instances')),
cfg.StrOpt('boot_script_template', cfg.StrOpt('boot_script_template',
default=utils.abspath('cloudpipe/bootscript.template'), default='$pybasedir/nova/cloudpipe/bootscript.template',
help=_('Template for cloudpipe instance boot script')), help=_('Template for cloudpipe instance boot script')),
cfg.StrOpt('dmz_net', cfg.StrOpt('dmz_net',
default='10.0.0.0', default='10.0.0.0',

View File

@ -33,7 +33,7 @@ from nova import utils
xvp_opts = [ xvp_opts = [
cfg.StrOpt('console_xvp_conf_template', cfg.StrOpt('console_xvp_conf_template',
default=utils.abspath('console/xvp.conf.template'), default='$pybasedir/nova/console/xvp.conf.template',
help='XVP conf template'), help='XVP conf template'),
cfg.StrOpt('console_xvp_conf', cfg.StrOpt('console_xvp_conf',
default='/etc/xvp.conf', default='/etc/xvp.conf',

View File

@ -102,11 +102,18 @@ core_opts = [
cfg.StrOpt('api_paste_config', cfg.StrOpt('api_paste_config',
default="api-paste.ini", default="api-paste.ini",
help='File name for the paste.deploy config for nova-api'), help='File name for the paste.deploy config for nova-api'),
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', cfg.StrOpt('state_path',
default=os.path.join(os.path.dirname(__file__), '../'), default='$pybasedir',
help="Top-level directory for maintaining nova's state"), help="Top-level directory for maintaining nova's state"),
cfg.StrOpt('lock_path', cfg.StrOpt('lock_path',
default=os.path.join(os.path.dirname(__file__), '../'), default='$pybasedir',
help='Directory to use for lock files'), help='Directory to use for lock files'),
] ]

View File

@ -35,11 +35,6 @@ from nova import utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def _bin_file(script):
"""Return the absolute path to scipt in the bin directory."""
return os.path.abspath(os.path.join(__file__, '../../../bin', script))
linux_net_opts = [ linux_net_opts = [
cfg.StrOpt('dhcpbridge_flagfile', cfg.StrOpt('dhcpbridge_flagfile',
default='/etc/nova/nova-dhcpbridge.conf', default='/etc/nova/nova-dhcpbridge.conf',
@ -54,7 +49,7 @@ linux_net_opts = [
default=None, default=None,
help='MTU setting for vlan'), help='MTU setting for vlan'),
cfg.StrOpt('dhcpbridge', cfg.StrOpt('dhcpbridge',
default=_bin_file('nova-dhcpbridge'), default='$bindir/nova-dhcpbridge',
help='location of nova-dhcpbridge'), help='location of nova-dhcpbridge'),
cfg.StrOpt('routing_source_ip', cfg.StrOpt('routing_source_ip',
default='$my_ip', default='$my_ip',

View File

@ -319,10 +319,6 @@ def ssh_execute(ssh, cmd, process_input=None,
return (stdout, stderr) return (stdout, stderr)
def abspath(s):
return os.path.join(os.path.dirname(__file__), s)
def novadir(): def novadir():
import nova import nova
return os.path.abspath(nova.__file__).split('nova/__init__.py')[0] return os.path.abspath(nova.__file__).split('nova/__init__.py')[0]

View File

@ -60,7 +60,7 @@ FLAGS = flags.FLAGS
baremetal_opts = [ baremetal_opts = [
cfg.StrOpt('baremetal_injected_network_template', cfg.StrOpt('baremetal_injected_network_template',
default=utils.abspath('virt/interfaces.template'), default='$pybasedir/nova/virt/interfaces.template',
help='Template file for injected network'), help='Template file for injected network'),
cfg.StrOpt('baremetal_type', cfg.StrOpt('baremetal_type',
default='baremetal', default='baremetal',

View File

@ -45,7 +45,7 @@ LOG = logging.getLogger(__name__)
disk_opts = [ disk_opts = [
cfg.StrOpt('injected_network_template', cfg.StrOpt('injected_network_template',
default=utils.abspath('virt/interfaces.template'), default='$pybasedir/nova/virt/interfaces.template',
help='Template file for injected network'), help='Template file for injected network'),
cfg.ListOpt('img_handlers', cfg.ListOpt('img_handlers',
default=['loop', 'nbd', 'guestfs'], default=['loop', 'nbd', 'guestfs'],

View File

@ -87,7 +87,7 @@ libvirt_opts = [
default=None, default=None,
help='Rescue ari image'), help='Rescue ari image'),
cfg.StrOpt('libvirt_xml_template', cfg.StrOpt('libvirt_xml_template',
default=utils.abspath('virt/libvirt.xml.template'), default='$pybasedir/nova/virt/libvirt.xml.template',
help='Libvirt XML Template'), help='Libvirt XML Template'),
cfg.StrOpt('libvirt_type', cfg.StrOpt('libvirt_type',
default='kvm', default='kvm',
@ -105,7 +105,7 @@ libvirt_opts = [
default=True, default=True,
help='Sync virtual and real mouse cursors in Windows VMs'), help='Sync virtual and real mouse cursors in Windows VMs'),
cfg.StrOpt('cpuinfo_xml_template', cfg.StrOpt('cpuinfo_xml_template',
default=utils.abspath('virt/cpuinfo.xml.template'), default='$pybasedir/nova/virt/cpuinfo.xml.template',
help='CpuInfo XML Template (Used only live migration now)'), help='CpuInfo XML Template (Used only live migration now)'),
cfg.StrOpt('live_migration_uri', cfg.StrOpt('live_migration_uri',
default="qemu+tcp://%s/system", default="qemu+tcp://%s/system",