summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Danjou <julien@danjou.info>2013-07-01 17:29:20 +0200
committerJulien Danjou <julien@danjou.info>2013-07-04 11:35:15 +0200
commit471686590ae9e0a332781e04a6073c8e32cee31e (patch)
tree7490ed148a524a81fed4bca5b21add9edc293590
parent085dd69acdd5c8c216271dc8890c4107363190fb (diff)
downloadoslo-471686590ae9e0a332781e04a6073c8e32cee31e.zip
oslo-471686590ae9e0a332781e04a6073c8e32cee31e.tar.gz
oslo-471686590ae9e0a332781e04a6073c8e32cee31e.tar.xz
config.generator: replace sys.prefix by /usr
Nova has some default configuration option (bindir) value that uses sys.prefix as path start. That can generates weird paths depending on the system where you run the configuration generator. This patch fixes that by hardcoding a replacement of sys.prefix to /usr, which is what's actually expected most of the time. Change-Id: Ied3b58695965a3102670e3761701fbe10ac74785 Signed-off-by: Julien Danjou <julien@danjou.info>
-rwxr-xr-xopenstack/common/config/generator.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/openstack/common/config/generator.py b/openstack/common/config/generator.py
index 8ebfba1..0dd7c97 100755
--- a/openstack/common/config/generator.py
+++ b/openstack/common/config/generator.py
@@ -188,7 +188,12 @@ def _get_my_ip():
def _sanitize_default(s):
"""Set up a reasonably sensible default for pybasedir, my_ip and host."""
- if s.startswith(BASEDIR):
+ if s.startswith(sys.prefix):
+ # NOTE(jd) Don't use os.path.join, because it is likely to think the
+ # second part is an absolute pathname and therefore drop the first
+ # part.
+ s = os.path.normpath("/usr/" + s[len(sys.prefix):])
+ elif s.startswith(BASEDIR):
return s.replace(BASEDIR, '/usr/lib/python/site-packages')
elif BASEDIR in s:
return s.replace(BASEDIR, '')