summaryrefslogtreecommitdiffstats
path: root/tools/conf
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 15:37:02 +0000
commit9120a7df376108515e3beee34c53925d969cf2b5 (patch)
tree829a4ef3cfc0e6b4057fe2b622c546d20ec307a3 /tools/conf
parent5aef0e13411fb8ce4e396b9addf65ef5a9ba28a2 (diff)
downloadnova-9120a7df376108515e3beee34c53925d969cf2b5.tar.gz
nova-9120a7df376108515e3beee34c53925d969cf2b5.tar.xz
nova-9120a7df376108515e3beee34c53925d969cf2b5.zip
Hack to fixup absolute pybasedir in nova.conf.sample
We want to avoid e.g. /home/markmc or /Users/vishvananda in this file. /usr/lib/python/site-packages is pretty dumb too, but it's suffices as an example. Change-Id: I851841a30ca01790c7b5a9b6bdbd160f4a84467c
Diffstat (limited to 'tools/conf')
-rw-r--r--tools/conf/create_conf.py31
1 files changed, 23 insertions, 8 deletions
diff --git a/tools/conf/create_conf.py b/tools/conf/create_conf.py
index 361c9efef..bc551a22e 100644
--- a/tools/conf/create_conf.py
+++ b/tools/conf/create_conf.py
@@ -38,6 +38,8 @@ _OPTION_REGEX = re.compile(r"(%s)" % "|".join([_STROPT, _BOOLOPT, _INTOPT,
_FLOATOPT, _LISTOPT,
_MULTISTROPT]))
+_BASEDIR = os.path.abspath(os.path.dirname(__file__) + "../../")
+
def main(srcfiles):
@@ -111,6 +113,13 @@ def print_module(mod_str):
print
+def convert_abspath(s):
+ """Set up a reasonably sensible default for pybasedir."""
+ if not s.startswith(_BASEDIR):
+ return s
+ return s.replace(_BASEDIR, '/usr/lib/python/site-packages')
+
+
def print_opt(opt):
opt_type = None
try:
@@ -120,20 +129,26 @@ def print_opt(opt):
sys.exit(1)
# print out option info
print "######", "".join(["(", opt_type, ")"]), opt.help
- if opt.default is None:
- print '# %s=<None>' % opt.name
+
+ name, default = opt.name, opt.default
+
+ if isinstance(default, basestring):
+ default = convert_abspath(default)
+
+ if default is None:
+ print '# %s=<None>' % name
else:
if opt_type == 'StrOpt':
- print '# %s="%s"' % (opt.name, opt.default)
+ print '# %s="%s"' % (name, default)
elif opt_type == 'ListOpt':
- print '# %s="%s"' % (opt.name, ','.join(opt.default))
+ print '# %s="%s"' % (name, ','.join(default))
elif opt_type == 'MultiStrOpt':
- for default in opt.default:
- print '# %s="%s"' % (opt.name, default)
+ for default in default:
+ print '# %s="%s"' % (name, default)
elif opt_type == 'BoolOpt':
- print '# %s=%s' % (opt.name, str(opt.default).lower())
+ print '# %s=%s' % (name, str(default).lower())
else:
- print '# %s=%s' % (opt.name, opt.default)
+ print '# %s=%s' % (name, default)
if __name__ == '__main__':