From 471686590ae9e0a332781e04a6073c8e32cee31e Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Mon, 1 Jul 2013 17:29:20 +0200 Subject: 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 --- openstack/common/config/generator.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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, '') -- cgit