diff options
| author | Zhongyue Luo <zhongyue.nah@intel.com> | 2013-01-22 14:01:27 +0800 |
|---|---|---|
| committer | Zhongyue Luo <zhongyue.nah@intel.com> | 2013-01-22 14:14:55 +0800 |
| commit | 4a04aacef3bd537f19c66b135b8d4e7e293a4a80 (patch) | |
| tree | 95441b8f8e6f224a662e3f5f599bafcf6a4a27be /tools/conf | |
| parent | a4d608fa33b328d7ed77c7f9c40ffbb43c0ade6b (diff) | |
| download | nova-4a04aacef3bd537f19c66b135b8d4e7e293a4a80.tar.gz nova-4a04aacef3bd537f19c66b135b8d4e7e293a4a80.tar.xz nova-4a04aacef3bd537f19c66b135b8d4e7e293a4a80.zip | |
Cleanup of extract_opts.py
Moved global variables to the top.
Removed once used variables
Used option type definitions in OPT_TYPES
Change-Id: Ia0bf39933bac84dbf432e6b4590ceb2527e6889c
Diffstat (limited to 'tools/conf')
| -rw-r--r-- | tools/conf/extract_opts.py | 31 |
1 files changed, 14 insertions, 17 deletions
diff --git a/tools/conf/extract_opts.py b/tools/conf/extract_opts.py index 3185cb93d..ccfcf3e4f 100644 --- a/tools/conf/extract_opts.py +++ b/tools/conf/extract_opts.py @@ -2,7 +2,6 @@ # Copyright 2012 SINA Corporation # All Rights Reserved. -# Author: Zhongyue Luo <lzyeval@gmail.com> # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -15,6 +14,9 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +# +# @author: Zhongyue Luo, SINA Corporation. +# """Extracts OpenStack config option info from module(s).""" @@ -35,6 +37,15 @@ FLOATOPT = "FloatOpt" LISTOPT = "ListOpt" MULTISTROPT = "MultiStrOpt" +OPT_TYPES = { + STROPT: 'string value', + BOOLOPT: 'boolean value', + INTOPT: 'integer value', + FLOATOPT: 'floating point value', + LISTOPT: 'list value', + MULTISTROPT: 'multi valued', +} + OPTION_COUNT = 0 OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT, FLOATOPT, LISTOPT, @@ -187,33 +198,19 @@ def _get_my_ip(): return None -MY_IP = _get_my_ip() -HOST = socket.getfqdn() - - def _sanitize_default(s): """Set up a reasonably sensible default for pybasedir, my_ip and host.""" if s.startswith(BASEDIR): return s.replace(BASEDIR, '/usr/lib/python/site-packages') - elif s == MY_IP: + elif s == _get_my_ip(): return '10.0.0.1' - elif s == HOST: + elif s == socket.getfqdn(): return 'nova' elif s.strip() != s: return '"%s"' % s return s -OPT_TYPES = { - 'StrOpt': 'string value', - 'BoolOpt': 'boolean value', - 'IntOpt': 'integer value', - 'FloatOpt': 'floating point value', - 'ListOpt': 'list value', - 'MultiStrOpt': 'multi valued', -} - - def _print_opt(opt): opt_name, opt_default, opt_help = opt.dest, opt.default, opt.help if not opt_help: |
