summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-07-29 20:40:16 +0000
committerGerrit Code Review <review@openstack.org>2013-07-29 20:40:16 +0000
commit15ce1a6954fa84051af97df62066efd6ff017efb (patch)
treed17aac69a7f50875b48a0897f794240d8b8ee7b7 /openstack
parentd65f843829356f5ed8d8b7bb6fe92f225c30b1e6 (diff)
parent7448e7e1df892cde1e7ab1cb61c24f62a4eae8da (diff)
downloadoslo-15ce1a6954fa84051af97df62066efd6ff017efb.tar.gz
oslo-15ce1a6954fa84051af97df62066efd6ff017efb.tar.xz
oslo-15ce1a6954fa84051af97df62066efd6ff017efb.zip
Merge "Fix hostname conflict in config generator"
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/config/generator.py27
1 files changed, 14 insertions, 13 deletions
diff --git a/openstack/common/config/generator.py b/openstack/common/config/generator.py
index 07aa296..1ae6c4d 100644
--- a/openstack/common/config/generator.py
+++ b/openstack/common/config/generator.py
@@ -181,24 +181,24 @@ def _get_my_ip():
return None
-def _sanitize_default(s):
+def _sanitize_default(name, value):
"""Set up a reasonably sensible default for pybasedir, my_ip and host."""
- if s.startswith(sys.prefix):
+ if value.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, '')
- elif s == _get_my_ip():
+ value = os.path.normpath("/usr/" + value[len(sys.prefix):])
+ elif value.startswith(BASEDIR):
+ return value.replace(BASEDIR, '/usr/lib/python/site-packages')
+ elif BASEDIR in value:
+ return value.replace(BASEDIR, '')
+ elif value == _get_my_ip():
return '10.0.0.1'
- elif s == socket.gethostname():
+ elif value == socket.gethostname() and 'host' in name:
return 'oslo'
- elif s.strip() != s:
- return '"%s"' % s
- return s
+ elif value.strip() != value:
+ return '"%s"' % value
+ return value
def _print_opt(opt):
@@ -219,7 +219,8 @@ def _print_opt(opt):
print('#%s=<None>' % opt_name)
elif opt_type == STROPT:
assert(isinstance(opt_default, basestring))
- print('#%s=%s' % (opt_name, _sanitize_default(opt_default)))
+ print('#%s=%s' % (opt_name, _sanitize_default(opt_name,
+ opt_default)))
elif opt_type == BOOLOPT:
assert(isinstance(opt_default, bool))
print('#%s=%s' % (opt_name, str(opt_default).lower()))