Run validation without authentication in particular context
Since we are using mistral to get the list of the plan
in TripleO, we require authentication for the clients
otherwise the validation Run won't work due to unable
to get mistral context.
This patch handle the authentication if provided by the user and
environment, if no authentifcation, since we cant generate dynamic
inventory, it checks if a static is passed with the CLI, if not it
raised an exception.
If authentication is provided and succeed, then tripleoclient can
safely call the plan_management to check and ensure if the plan is
present.
Change-Id: I5a702a84ca0e1942f2e1636d31acc391f689a8ad
(cherry picked from commit ff4f4a9578
)
This commit is contained in:
parent
98ffc681c9
commit
89eaf7a5b8
|
@ -18,6 +18,7 @@ import json
|
|||
import logging
|
||||
import yaml
|
||||
|
||||
from openstack import exceptions as os_exceptions
|
||||
from osc_lib import exceptions
|
||||
from osc_lib.i18n import _
|
||||
from prettytable import PrettyTable
|
||||
|
@ -320,15 +321,25 @@ class TripleOValidatorRun(command.Command):
|
|||
|
||||
def _run_validator_run(self, parsed_args):
|
||||
LOG = logging.getLogger(__name__ + ".ValidationsRunAnsible")
|
||||
|
||||
clients = self.app.client_manager
|
||||
plans = plan_management.list_deployment_plans(clients)
|
||||
|
||||
if parsed_args.plan and parsed_args.plan not in plans:
|
||||
raise exceptions.CommandError(
|
||||
_("The plan '{}' doesn't exist. "
|
||||
"Please use one of those {}".format(parsed_args, plans)))
|
||||
|
||||
# Try to perform OpenStack authentication, if no authentication
|
||||
# and static inventory provided continue, else raise error.
|
||||
try:
|
||||
clients = self.app.client_manager
|
||||
clients._auth_required = True
|
||||
clients.setup_auth()
|
||||
except os_exceptions.ConfigException:
|
||||
LOG.warning("Running Validations without authentication.")
|
||||
if not parsed_args.static_inventory:
|
||||
raise exceptions.CommandError(
|
||||
_("No static inventory provided, please provide a valid"
|
||||
"inventory or use authentication."))
|
||||
else:
|
||||
plans = plan_management.list_deployment_plans(clients)
|
||||
if parsed_args.plan and parsed_args.plan not in plans:
|
||||
raise exceptions.CommandError(
|
||||
_("The plan '{}' doesn't exist. "
|
||||
"Please use one of those {}".format(parsed_args,
|
||||
plans)))
|
||||
limit = parsed_args.limit
|
||||
extra_vars = parsed_args.extra_vars
|
||||
if parsed_args.extra_vars_file:
|
||||
|
|
Loading…
Reference in New Issue