From 46de1cc2674d6fe4f068054527b176d0dd98cffb Mon Sep 17 00:00:00 2001 From: Mark McLoughlin Date: Thu, 23 Aug 2012 10:37:38 +0100 Subject: 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 --- tools/conf/README | 9 +++++++++ tools/conf/extract_opts.py | 6 +++--- tools/conf/generate_sample.sh | 10 +++++----- 3 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 tools/conf/README (limited to 'tools/conf') 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 -- cgit