Migrate verify-tempest-config to new cliff cli framework
Leave existing endpoint for now as to not disrupt existing workflows and deprecate next cycle. Added deprecation message for old entry point. Change-Id: If8afab441f51e5cf0f3bf1e2b95d76b2c1d0c474 Implements: blueprint tempest-cli-improvements
This commit is contained in:
parent
877e19fe99
commit
e45aa842bc
@ -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
|
||||
|
||||
|
43
tempest/cmd/verify_tempest_config.py
Executable file → Normal file
43
tempest/cmd/verify_tempest_config.py
Executable file → Normal file
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user