Raise if no validation has been executed
If no validations has been run, the CLI should raise a exceptions.CommandError instead of trying to build the prettytable from results. Change-Id: I2ed22b9c01ebb64281ad5b8b3b569cc53a4f122e
This commit is contained in:
parent
d2f665ef6c
commit
efcf2d98be
|
@ -331,6 +331,7 @@ class TripleOValidatorRun(command.Command):
|
|||
v_consts.DEFAULT_VALIDATIONS_BASEDIR = constants.\
|
||||
DEFAULT_VALIDATIONS_BASEDIR
|
||||
actions = ValidationActions()
|
||||
try:
|
||||
results = actions.run_validations(
|
||||
inventory=static_inventory,
|
||||
limit_hosts=limit,
|
||||
|
@ -340,7 +341,10 @@ class TripleOValidatorRun(command.Command):
|
|||
validation_name=parsed_args.validation_name,
|
||||
extra_env_vars=parsed_args.extra_env_vars,
|
||||
quiet=True)
|
||||
except RuntimeError as e:
|
||||
raise exceptions.CommandError(e)
|
||||
|
||||
if results:
|
||||
# Build output
|
||||
t = PrettyTable(border=True, header=True, padding_width=1)
|
||||
# Set Field name by getting the result dict keys
|
||||
|
@ -361,6 +365,9 @@ class TripleOValidatorRun(command.Command):
|
|||
r['status'] = '{}{}{}'.format(color, status, RESET)
|
||||
t.add_row(r.values())
|
||||
print(t)
|
||||
else:
|
||||
msg = "No Validation has been run, please check your parameters."
|
||||
raise exceptions.CommandError(msg)
|
||||
|
||||
if not parsed_args.static_inventory:
|
||||
LOG.debug(_('Removing static tripleo ansible inventory file'))
|
||||
|
|
Loading…
Reference in New Issue