diff --git a/setup.cfg b/setup.cfg index b94a4f4f2b..183c1fb329 100644 --- a/setup.cfg +++ b/setup.cfg @@ -37,6 +37,7 @@ tempest.cm = cleanup = tempest.cmd.cleanup:TempestCleanup run-stress = tempest.cmd.run_stress:TempestRunStress list-plugins = tempest.cmd.list_plugins:TempestListPlugins + verify-config = tempest.cmd.verify_tempest_config:TempestVerifyConfig oslo.config.opts = tempest.config = tempest.config:list_opts diff --git a/tempest/cmd/verify_tempest_config.py b/tempest/cmd/verify_tempest_config.py old mode 100755 new mode 100644 index 9c8e2a0a86..5d867dfbe5 --- a/tempest/cmd/verify_tempest_config.py +++ b/tempest/cmd/verify_tempest_config.py @@ -15,10 +15,13 @@ # under the License. import argparse +import httplib2 import os import sys +import traceback -import httplib2 +from cliff import command +from oslo_log import log as logging from oslo_serialization import jsonutils as json from six import moves from six.moves.urllib import parse as urlparse @@ -31,6 +34,8 @@ from tempest import config CONF = config.CONF CONF_PARSER = None +LOG = logging.getLogger(__name__) + def _get_config_file(): default_config_dir = os.path.join(os.path.abspath( @@ -310,8 +315,7 @@ def check_service_availability(os, update): return avail_services -def parse_args(): - parser = argparse.ArgumentParser() +def _parser_add_args(parser): parser.add_argument('-u', '--update', action='store_true', help='Update the config file with results from api ' 'queries. This assumes whatever is set in the ' @@ -329,13 +333,21 @@ def parse_args(): parser.add_argument('-r', '--replace-ext', action='store_true', help="If specified the all option will be replaced " "with a full list of extensions") - args = parser.parse_args() - return args -def main(): +def parse_args(): + parser = argparse.ArgumentParser() + _parser_add_args(parser) + opts = parser.parse_args() + return opts + + +def main(opts=None): print('Running config verification...') - opts = parse_args() + if opts is None: + print("Use of: 'verify-tempest-config' is deprecated, " + "please use: 'tempest verify-config'") + opts = parse_args() update = opts.update replace = opts.replace_ext global CONF_PARSER @@ -373,5 +385,22 @@ def main(): icreds.clear_creds() +class TempestVerifyConfig(command.Command): + """Verify your current tempest configuration""" + + def get_parser(self, prog_name): + parser = super(TempestVerifyConfig, self).get_parser(prog_name) + _parser_add_args(parser) + return parser + + def take_action(self, parsed_args): + try: + return main(parsed_args) + except Exception: + LOG.exception("Failure verifying configuration.") + traceback.print_exc() + raise + return 0 + if __name__ == "__main__": main()