summaryrefslogtreecommitdiffstats
path: root/nova/paths.py
diff options
context:
space:
mode:
authorMark McLoughlin <markmc@redhat.com>2013-01-04 17:36:29 +0000
committerMark McLoughlin <markmc@redhat.com>2013-01-04 17:36:29 +0000
commit1428956919ffdaf75297fd225452abb9649e6c32 (patch)
treef34a42d6ea09a0b1dc342c8f0136fc40d3ba31b8 /nova/paths.py
parent2553b4a22175d9a00a36fd9d20f3c646fd3fab1f (diff)
downloadnova-1428956919ffdaf75297fd225452abb9649e6c32.tar.gz
nova-1428956919ffdaf75297fd225452abb9649e6c32.tar.xz
nova-1428956919ffdaf75297fd225452abb9649e6c32.zip
Add helper methods to nova.paths
We only ever do one of two things with the global path options: 1) Reference the option in the default of another option so that the value can be interpolated it 2) Use the value of the option to build a path Add helper methods for both these cases - e.g. basedir_def() for the former case and basedir_rel() for the latter case. This makes it much more obvious how and where these options are used. Change-Id: I7fd94a329fe911761d02d94e5381e950c6668d56
Diffstat (limited to 'nova/paths.py')
-rw-r--r--nova/paths.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/nova/paths.py b/nova/paths.py
index bc17817b0..7405a7409 100644
--- a/nova/paths.py
+++ b/nova/paths.py
@@ -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)