diff options
author | Mark McLoughlin <markmc@redhat.com> | 2012-08-23 10:37:38 +0100 |
---|---|---|
committer | Mark McLoughlin <markmc@redhat.com> | 2012-08-23 10:37:38 +0100 |
commit | 46de1cc2674d6fe4f068054527b176d0dd98cffb (patch) | |
tree | 8093f941b9d2837442f7fe790499a06be3e7332a /tools | |
parent | 9fecad9e6f7803f3422e7769c01ba3b9076ed308 (diff) | |
download | nova-46de1cc2674d6fe4f068054527b176d0dd98cffb.tar.gz nova-46de1cc2674d6fe4f068054527b176d0dd98cffb.tar.xz nova-46de1cc2674d6fe4f068054527b176d0dd98cffb.zip |
Allow generate_sample.sh to be run from toplevel dir
I hit an issue where extract_opts.py couldn't import importutils
since it's not in my sys.path, so it's clear we need to set
PYTHONPATH before running.
The whole business of running the tool from the tools/conf dir
is fairly awkward, so change it to run from the top-level dir
instead.
Change-Id: I89b4d874a6ee3732234a9704a8ee6001a293ed71
Diffstat (limited to 'tools')
-rw-r--r-- | tools/conf/README | 9 | ||||
-rw-r--r-- | tools/conf/extract_opts.py | 6 | ||||
-rwxr-xr-x | tools/conf/generate_sample.sh | 10 |
3 files changed, 17 insertions, 8 deletions
diff --git a/tools/conf/README b/tools/conf/README new file mode 100644 index 000000000..a76efb2a7 --- /dev/null +++ b/tools/conf/README @@ -0,0 +1,9 @@ +This tool is used to generate etc/nova/nova.conf.sample + +Run it from the top-level working directory i.e. + + $> ./tools/conf/generate_sample.sh + +Watch out for warnings about modules like libvirt, qpid and zmq not +being found - these warnings are significant because they result +in options not appearing in the generated config file. diff --git a/tools/conf/extract_opts.py b/tools/conf/extract_opts.py index 44ae2b000..75985e340 100644 --- a/tools/conf/extract_opts.py +++ b/tools/conf/extract_opts.py @@ -41,7 +41,7 @@ OPTION_REGEX = re.compile(r"(%s)" % "|".join([STROPT, BOOLOPT, INTOPT, OPTION_HELP_INDENT = "####" PY_EXT = ".py" -BASEDIR = os.path.abspath(os.path.dirname(__file__) + "../../") +BASEDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../")) WORDWRAP_WIDTH = 60 @@ -50,8 +50,8 @@ def main(srcfiles): '', '[DEFAULT]', '']) mods_by_pkg = dict() for filepath in srcfiles: - pkg_name = filepath.split(os.sep)[3] - mod_str = '.'.join(['.'.join(filepath.split(os.sep)[2:-1]), + pkg_name = filepath.split(os.sep)[1] + mod_str = '.'.join(['.'.join(filepath.split(os.sep)[:-1]), os.path.basename(filepath).split('.')[0]]) mods_by_pkg.setdefault(pkg_name, list()).append(mod_str) # NOTE(lzyeval): place top level modules before packages diff --git a/tools/conf/generate_sample.sh b/tools/conf/generate_sample.sh index 2a6b17aa4..25462caa2 100755 --- a/tools/conf/generate_sample.sh +++ b/tools/conf/generate_sample.sh @@ -16,10 +16,10 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -pushd $(cd $(dirname "$0") && pwd) >/dev/null -find ../../nova -type f -name "*.py" ! -path "../../nova/tests/*" -exec \ - grep -l "Opt(" {} \; | sort -u | xargs python extract_opts.py > \ - ../../etc/nova/nova.conf.sample +FILES=$(find nova -type f -name "*.py" ! -path "nova/tests/*" -exec \ + grep -l "Opt(" {} \; | sort -u) -popd >/dev/null +PYTHONPATH=./:${PYTHONPATH} \ + python $(dirname "$0")/extract_opts.py ${FILES} > \ + etc/nova/nova.conf.sample |