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 (cherry picked from commitefcf2d98be
) (cherry picked from commita60ec726e4
)
This commit is contained in:
parent
10e13cbb99
commit
11c7c2663a
@ -363,6 +363,7 @@ class TripleOValidatorRun(command.Command):
|
|||||||
v_consts.DEFAULT_VALIDATIONS_BASEDIR = constants.\
|
v_consts.DEFAULT_VALIDATIONS_BASEDIR = constants.\
|
||||||
DEFAULT_VALIDATIONS_BASEDIR
|
DEFAULT_VALIDATIONS_BASEDIR
|
||||||
actions = ValidationActions()
|
actions = ValidationActions()
|
||||||
|
try:
|
||||||
results = actions.run_validations(
|
results = actions.run_validations(
|
||||||
inventory=static_inventory,
|
inventory=static_inventory,
|
||||||
limit_hosts=limit,
|
limit_hosts=limit,
|
||||||
@ -373,7 +374,10 @@ class TripleOValidatorRun(command.Command):
|
|||||||
extra_env_vars=parsed_args.extra_env_vars,
|
extra_env_vars=parsed_args.extra_env_vars,
|
||||||
python_interpreter=parsed_args.python_interpreter,
|
python_interpreter=parsed_args.python_interpreter,
|
||||||
quiet=True)
|
quiet=True)
|
||||||
|
except RuntimeError as e:
|
||||||
|
raise exceptions.CommandError(e)
|
||||||
|
|
||||||
|
if results:
|
||||||
# Build output
|
# Build output
|
||||||
t = PrettyTable(border=True, header=True, padding_width=1)
|
t = PrettyTable(border=True, header=True, padding_width=1)
|
||||||
# Set Field name by getting the result dict keys
|
# Set Field name by getting the result dict keys
|
||||||
@ -394,6 +398,9 @@ class TripleOValidatorRun(command.Command):
|
|||||||
r['status'] = '{}{}{}'.format(color, status, RESET)
|
r['status'] = '{}{}{}'.format(color, status, RESET)
|
||||||
t.add_row(r.values())
|
t.add_row(r.values())
|
||||||
print(t)
|
print(t)
|
||||||
|
else:
|
||||||
|
msg = "No Validation has been run, please check your parameters."
|
||||||
|
raise exceptions.CommandError(msg)
|
||||||
|
|
||||||
if not parsed_args.static_inventory:
|
if not parsed_args.static_inventory:
|
||||||
LOG.debug(_('Removing static tripleo ansible inventory file'))
|
LOG.debug(_('Removing static tripleo ansible inventory file'))
|
||||||
|
Loading…
Reference in New Issue
Block a user