summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2012-03-09 11:05:13 +0000
committerMark McLoughlin <markmc@redhat.com>2012-03-09 11:23:33 +0000
commit5aef0e13411fb8ce4e396b9addf65ef5a9ba28a2 (patch)
tree1972d4f62b4b3986af0e024a3aea4c92c2163b0b
parent17396f6a08b694b28538462baca582266152da86 (diff)
downloadnova-5aef0e13411fb8ce4e396b9addf65ef5a9ba28a2.tar.gz
nova-5aef0e13411fb8ce4e396b9addf65ef5a9ba28a2.tar.xz
nova-5aef0e13411fb8ce4e396b9addf65ef5a9ba28a2.zip
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
-rw-r--r--nova/auth/manager.py4
-rw-r--r--nova/cloudpipe/pipelib.py2
-rw-r--r--nova/console/xvp.py2
-rw-r--r--nova/flags.py11
-rwxr-xr-xnova/network/linux_net.py7
-rw-r--r--nova/utils.py4
-rw-r--r--nova/virt/baremetal/proxy.py2
-rw-r--r--nova/virt/disk/api.py2
-rw-r--r--nova/virt/libvirt/connection.py4
9 files changed, 18 insertions, 20 deletions
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index 438066e3b..ca2a3add5 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -63,10 +63,10 @@ auth_opts = [
help='Roles that apply to all projects'),
cfg.StrOpt('credentials_template',
- default=utils.abspath('auth/novarc.template'),
+ default='$pybasedir/nova/auth/novarc.template',
help='Template for creating users rc file'),
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'),
cfg.StrOpt('credential_vpn_file',
default='nova-vpn.conf',
diff --git a/nova/cloudpipe/pipelib.py b/nova/cloudpipe/pipelib.py
index dccfc8071..497ee6ffc 100644
--- a/nova/cloudpipe/pipelib.py
+++ b/nova/cloudpipe/pipelib.py
@@ -45,7 +45,7 @@ cloudpipe_opts = [
default='m1.tiny',
help=_('Instance type for vpn instances')),
cfg.StrOpt('boot_script_template',
- default=utils.abspath('cloudpipe/bootscript.template'),
+ default='$pybasedir/nova/cloudpipe/bootscript.template',
help=_('Template for cloudpipe instance boot script')),
cfg.StrOpt('dmz_net',
default='10.0.0.0',
diff --git a/nova/console/xvp.py b/nova/console/xvp.py
index 14e9cc0e7..341af1c57 100644
--- a/nova/console/xvp.py
+++ b/nova/console/xvp.py
@@ -33,7 +33,7 @@ from nova import utils
xvp_opts = [
cfg.StrOpt('console_xvp_conf_template',
- default=utils.abspath('console/xvp.conf.template'),
+ default='$pybasedir/nova/console/xvp.conf.template',
help='XVP conf template'),
cfg.StrOpt('console_xvp_conf',
default='/etc/xvp.conf',
diff --git a/nova/flags.py b/nova/flags.py
index ece5361c6..38c2258c2 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -102,11 +102,18 @@ core_opts = [
cfg.StrOpt('api_paste_config',
default="api-paste.ini",
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',
- default=os.path.join(os.path.dirname(__file__), '../'),
+ default='$pybasedir',
help="Top-level directory for maintaining nova's state"),
cfg.StrOpt('lock_path',
- default=os.path.join(os.path.dirname(__file__), '../'),
+ default='$pybasedir',
help='Directory to use for lock files'),
]
diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py
index 58fec83e2..c0dbe88af 100755
--- a/nova/network/linux_net.py
+++ b/nova/network/linux_net.py
@@ -35,11 +35,6 @@ from nova import utils
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 = [
cfg.StrOpt('dhcpbridge_flagfile',
default='/etc/nova/nova-dhcpbridge.conf',
@@ -54,7 +49,7 @@ linux_net_opts = [
default=None,
help='MTU setting for vlan'),
cfg.StrOpt('dhcpbridge',
- default=_bin_file('nova-dhcpbridge'),
+ default='$bindir/nova-dhcpbridge',
help='location of nova-dhcpbridge'),
cfg.StrOpt('routing_source_ip',
default='$my_ip',
diff --git a/nova/utils.py b/nova/utils.py
index 5b8eda012..c95382a0e 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -319,10 +319,6 @@ def ssh_execute(ssh, cmd, process_input=None,
return (stdout, stderr)
-def abspath(s):
- return os.path.join(os.path.dirname(__file__), s)
-
-
def novadir():
import nova
return os.path.abspath(nova.__file__).split('nova/__init__.py')[0]
diff --git a/nova/virt/baremetal/proxy.py b/nova/virt/baremetal/proxy.py
index 788386edd..50c72dd87 100644
--- a/nova/virt/baremetal/proxy.py
+++ b/nova/virt/baremetal/proxy.py
@@ -60,7 +60,7 @@ FLAGS = flags.FLAGS
baremetal_opts = [
cfg.StrOpt('baremetal_injected_network_template',
- default=utils.abspath('virt/interfaces.template'),
+ default='$pybasedir/nova/virt/interfaces.template',
help='Template file for injected network'),
cfg.StrOpt('baremetal_type',
default='baremetal',
diff --git a/nova/virt/disk/api.py b/nova/virt/disk/api.py
index a9b1067c2..f8b51fb31 100644
--- a/nova/virt/disk/api.py
+++ b/nova/virt/disk/api.py
@@ -45,7 +45,7 @@ LOG = logging.getLogger(__name__)
disk_opts = [
cfg.StrOpt('injected_network_template',
- default=utils.abspath('virt/interfaces.template'),
+ default='$pybasedir/nova/virt/interfaces.template',
help='Template file for injected network'),
cfg.ListOpt('img_handlers',
default=['loop', 'nbd', 'guestfs'],
diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py
index ae2a2b665..f526f15ca 100644
--- a/nova/virt/libvirt/connection.py
+++ b/nova/virt/libvirt/connection.py
@@ -87,7 +87,7 @@ libvirt_opts = [
default=None,
help='Rescue ari image'),
cfg.StrOpt('libvirt_xml_template',
- default=utils.abspath('virt/libvirt.xml.template'),
+ default='$pybasedir/nova/virt/libvirt.xml.template',
help='Libvirt XML Template'),
cfg.StrOpt('libvirt_type',
default='kvm',
@@ -105,7 +105,7 @@ libvirt_opts = [
default=True,
help='Sync virtual and real mouse cursors in Windows VMs'),
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)'),
cfg.StrOpt('live_migration_uri',
default="qemu+tcp://%s/system",