diff --git a/tripleoclient/tests/v1/overcloud_external_update/fakes.py b/tripleoclient/tests/v1/overcloud_external_update/fakes.py index 8867cd35f..e079ac837 100644 --- a/tripleoclient/tests/v1/overcloud_external_update/fakes.py +++ b/tripleoclient/tests/v1/overcloud_external_update/fakes.py @@ -47,3 +47,4 @@ class TestOvercloudExternalUpdateRun(utils.TestCommand): self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN") self.app.client_manager.tripleoclient = FakeClientWrapper() self.app.client_manager.workflow_engine = mock.Mock() + self.app.client_manager.orchestration = mock.Mock() diff --git a/tripleoclient/tests/v1/overcloud_external_upgrade/fakes.py b/tripleoclient/tests/v1/overcloud_external_upgrade/fakes.py index 60d5d8c33..22ef36766 100644 --- a/tripleoclient/tests/v1/overcloud_external_upgrade/fakes.py +++ b/tripleoclient/tests/v1/overcloud_external_upgrade/fakes.py @@ -47,3 +47,4 @@ class TestOvercloudExternalUpgradeRun(utils.TestCommand): self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN") self.app.client_manager.tripleoclient = FakeClientWrapper() self.app.client_manager.workflow_engine = mock.Mock() + self.app.client_manager.orchestration = mock.Mock() diff --git a/tripleoclient/tests/v1/overcloud_ffwd_upgrade/fakes.py b/tripleoclient/tests/v1/overcloud_ffwd_upgrade/fakes.py index 89eab4c5d..cbd093be3 100644 --- a/tripleoclient/tests/v1/overcloud_ffwd_upgrade/fakes.py +++ b/tripleoclient/tests/v1/overcloud_ffwd_upgrade/fakes.py @@ -62,6 +62,7 @@ class TestFFWDUpgradeRun(utils.TestCommand): self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN") self.app.client_manager.tripleoclient = FakeClientWrapper() self.app.client_manager.workflow_engine = mock.Mock() + self.app.client_manager.orchestration = mock.Mock() class TestFFWDUpgradeConverge(utils.TestCommand): diff --git a/tripleoclient/tests/v1/overcloud_update/fakes.py b/tripleoclient/tests/v1/overcloud_update/fakes.py index a82e50b71..9972af267 100644 --- a/tripleoclient/tests/v1/overcloud_update/fakes.py +++ b/tripleoclient/tests/v1/overcloud_update/fakes.py @@ -62,6 +62,7 @@ class TestOvercloudUpdateRun(utils.TestCommand): self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN") self.app.client_manager.tripleoclient = FakeClientWrapper() self.app.client_manager.workflow_engine = mock.Mock() + self.app.client_manager.orchestration = mock.Mock() class TestOvercloudUpdateConverge(utils.TestCommand): diff --git a/tripleoclient/tests/v1/overcloud_upgrade/fakes.py b/tripleoclient/tests/v1/overcloud_upgrade/fakes.py index 21456f2eb..1e2bd79ab 100644 --- a/tripleoclient/tests/v1/overcloud_upgrade/fakes.py +++ b/tripleoclient/tests/v1/overcloud_upgrade/fakes.py @@ -62,3 +62,4 @@ class TestOvercloudUpgradeRun(utils.TestCommand): self.app.client_manager.auth_ref = mock.Mock(auth_token="TOKEN") self.app.client_manager.tripleoclient = FakeClientWrapper() self.app.client_manager.workflow_engine = mock.Mock() + self.app.client_manager.orchestration = mock.Mock() diff --git a/tripleoclient/v1/overcloud_external_update.py b/tripleoclient/v1/overcloud_external_update.py index 046e977b8..bf878362d 100644 --- a/tripleoclient/v1/overcloud_external_update.py +++ b/tripleoclient/v1/overcloud_external_update.py @@ -79,19 +79,36 @@ class ExternalUpdateRun(command.Command): '(default=Env: OVERCLOUD_STACK_NAME)'), default=utils.env('OVERCLOUD_STACK_NAME', default='overcloud')) - parser.add_argument( - '-e', '--extra-vars', dest='extra_vars', action='append', - help='Set additional variables as key=value or yaml/json', - default=[]) + parser.add_argument('-e', '--extra-vars', dest='extra_vars', + action='append', + help=('Set additional variables as key=value or ' + 'yaml/json'), + default=[]) + parser.add_argument('--no-workflow', dest='no_workflow', + action='store_true', + default=False, + help=_('Run ansible-playbook directly via ' + 'system command instead of running Ansible' + 'via the TripleO mistral workflows.') + ) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager + orchestration = clients.orchestration verbosity = self.app_args.verbose_level stack = parsed_args.stack + ansible_dir = None + key = None + # Disable mistral + if parsed_args.no_workflow: + ansible_dir = oooutils.download_ansible_playbooks(orchestration, + stack) + key = package_update.get_key(clients) + # Run ansible: inventory = oooutils.get_tripleo_ansible_inventory( parsed_args.static_inventory, parsed_args.ssh_user, stack) @@ -101,9 +118,10 @@ class ExternalUpdateRun(command.Command): oooutils.run_update_ansible_action( self.log, clients, limit_hosts, inventory, playbook, - constants.EXTERNAL_UPDATE_PLAYBOOKS, - parsed_args.ssh_user, package_update, + constants.EXTERNAL_UPDATE_PLAYBOOKS, parsed_args.ssh_user, + (None if parsed_args.no_workflow else package_update), tags=parsed_args.tags, skip_tags=parsed_args.skip_tags, - verbosity=verbosity, extra_vars=extra_vars) + verbosity=verbosity, extra_vars=extra_vars, workdir=ansible_dir, + priv_key=key) self.log.info("Completed Overcloud External Update Run.") diff --git a/tripleoclient/v1/overcloud_external_upgrade.py b/tripleoclient/v1/overcloud_external_upgrade.py index dcf3ed0d1..77e62a0af 100644 --- a/tripleoclient/v1/overcloud_external_upgrade.py +++ b/tripleoclient/v1/overcloud_external_upgrade.py @@ -79,19 +79,36 @@ class ExternalUpgradeRun(command.Command): '(default=Env: OVERCLOUD_STACK_NAME)'), default=utils.env('OVERCLOUD_STACK_NAME', default='overcloud')) - parser.add_argument( - '-e', '--extra-vars', dest='extra_vars', action='append', - help='Set additional variables as key=value or yaml/json', - default=[]) + parser.add_argument('-e', '--extra-vars', dest='extra_vars', + action='append', + help=('Set additional variables as key=value or ' + 'yaml/json'), + default=[]) + parser.add_argument('--no-workflow', dest='no_workflow', + action='store_true', + default=False, + help=_('Run ansible-playbook directly via ' + 'system command instead of running Ansible' + 'via the TripleO mistral workflows.') + ) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager + orchestration = clients.orchestration verbosity = self.app_args.verbose_level stack = parsed_args.stack + ansible_dir = None + key = None + # Disable mistral + if parsed_args.no_workflow: + ansible_dir = oooutils.download_ansible_playbooks(orchestration, + stack) + key = package_update.get_key(clients) + # Run ansible: inventory = oooutils.get_tripleo_ansible_inventory( parsed_args.static_inventory, parsed_args.ssh_user, stack) @@ -101,9 +118,10 @@ class ExternalUpgradeRun(command.Command): oooutils.run_update_ansible_action( self.log, clients, limit_hosts, inventory, playbook, - constants.EXTERNAL_UPGRADE_PLAYBOOKS, - parsed_args.ssh_user, package_update, + constants.EXTERNAL_UPGRADE_PLAYBOOKS, parsed_args.ssh_user, + (None if parsed_args.no_workflow else package_update), tags=parsed_args.tags, skip_tags=parsed_args.skip_tags, - verbosity=verbosity, extra_vars=extra_vars) + verbosity=verbosity, extra_vars=extra_vars, workdir=ansible_dir, + priv_key=key) self.log.info("Completed Overcloud External Upgrade Run.") diff --git a/tripleoclient/v1/overcloud_ffwd_upgrade.py b/tripleoclient/v1/overcloud_ffwd_upgrade.py index 1bc25ec25..f7aa2ef3d 100644 --- a/tripleoclient/v1/overcloud_ffwd_upgrade.py +++ b/tripleoclient/v1/overcloud_ffwd_upgrade.py @@ -139,6 +139,13 @@ class FFWDUpgradeRun(command.Command): default=utils.env('OVERCLOUD_STACK_NAME', default='overcloud') ) + parser.add_argument('--no-workflow', dest='no_workflow', + action='store_true', + default=False, + help=_('Run ansible-playbook directly via ' + 'system command instead of running Ansible' + 'via the TripleO mistral workflows.') + ) return parser def take_action(self, parsed_args): @@ -146,6 +153,16 @@ class FFWDUpgradeRun(command.Command): oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log) verbosity = self.app_args.verbose_level clients = self.app.client_manager + orchestration = clients.orchestration + stack = parsed_args.stack + + ansible_dir = None + key = None + # Disable mistral + if parsed_args.no_workflow: + ansible_dir = oooutils.download_ansible_playbooks(orchestration, + stack) + key = package_update.get_key(clients) # Run ansible: inventory = oooutils.get_tripleo_ansible_inventory( @@ -156,7 +173,8 @@ class FFWDUpgradeRun(command.Command): oooutils.run_update_ansible_action( self.log, clients, limit_hosts, inventory, constants.FFWD_UPGRADE_PLAYBOOK, [], parsed_args.ssh_user, - package_update, verbosity=verbosity) + (None if parsed_args.no_workflow else package_update), + verbosity=verbosity, workdir=ansible_dir, priv_key=key) class FFWDUpgradeConverge(DeployOvercloud): diff --git a/tripleoclient/v1/overcloud_update.py b/tripleoclient/v1/overcloud_update.py index 752efd94f..46d8bf13b 100644 --- a/tripleoclient/v1/overcloud_update.py +++ b/tripleoclient/v1/overcloud_update.py @@ -129,15 +129,31 @@ class UpdateRun(command.Command): default=utils.env('OVERCLOUD_STACK_NAME', default='overcloud') ) + parser.add_argument('--no-workflow', dest='no_workflow', + action='store_true', + default=False, + help=_('Run ansible-playbook directly via ' + 'system command instead of running Ansible' + 'via the TripleO mistral workflows.') + ) return parser def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager + orchestration = clients.orchestration verbosity = self.app_args.verbose_level stack = parsed_args.stack + ansible_dir = None + key = None + # Disable mistral + if parsed_args.no_workflow: + ansible_dir = oooutils.download_ansible_playbooks(orchestration, + stack) + key = package_update.get_key(clients) + # Run ansible: limit_hosts = parsed_args.limit @@ -148,8 +164,11 @@ class UpdateRun(command.Command): inventory, playbook, constants.MINOR_UPDATE_PLAYBOOKS, parsed_args.ssh_user, - package_update, - verbosity=verbosity) + (None if parsed_args.no_workflow + else package_update), + verbosity=verbosity, + workdir=ansible_dir, + priv_key=key) class UpdateConverge(DeployOvercloud): diff --git a/tripleoclient/v1/overcloud_upgrade.py b/tripleoclient/v1/overcloud_upgrade.py index 93ef9afa7..6c95df38d 100644 --- a/tripleoclient/v1/overcloud_upgrade.py +++ b/tripleoclient/v1/overcloud_upgrade.py @@ -173,6 +173,13 @@ class UpgradeRun(command.Command): '(default=Env: OVERCLOUD_STACK_NAME)'), default=utils.env('OVERCLOUD_STACK_NAME', default='overcloud')) + parser.add_argument('--no-workflow', dest='no_workflow', + action='store_true', + default=False, + help=_('Run ansible-playbook directly via ' + 'system command instead of running Ansible' + 'via the TripleO mistral workflows.') + ) return parser @@ -190,8 +197,17 @@ class UpgradeRun(command.Command): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager verbosity = self.app_args.verbose_level + orchestration = clients.orchestration stack = parsed_args.stack + ansible_dir = None + key = None + # Disable mistral + if parsed_args.no_workflow: + ansible_dir = oooutils.download_ansible_playbooks(orchestration, + stack) + key = package_update.get_key(clients) + # Run ansible: limit_hosts = parsed_args.limit @@ -203,10 +219,13 @@ class UpgradeRun(command.Command): inventory, playbook, constants.MAJOR_UPGRADE_PLAYBOOKS, parsed_args.ssh_user, - package_update, + (None if parsed_args.no_workflow + else package_update), parsed_args.tags, skip_tags, - verbosity) + verbosity, + workdir=ansible_dir, + priv_key=key) playbooks = (constants.MAJOR_UPGRADE_PLAYBOOKS if playbook == 'all' else playbook) diff --git a/tripleoclient/workflows/package_update.py b/tripleoclient/workflows/package_update.py index 4c1e735f7..4a8b8432b 100644 --- a/tripleoclient/workflows/package_update.py +++ b/tripleoclient/workflows/package_update.py @@ -85,6 +85,28 @@ def get_config(clients, **workflow_input): raise RuntimeError('Minor update failed with: {}'.format(payload)) +def get_key(clients, **workflow_input): + workflow_client = clients.workflow_engine + tripleoclients = clients.tripleoclient + + with tripleoclients.messaging_websocket() as ws: + execution = base.start_workflow( + workflow_client, + 'tripleo.package_update.v1.get_key', + workflow_input=workflow_input + ) + + for payload in base.wait_for_messages(workflow_client, ws, execution, + _WORKFLOW_TIMEOUT): + assert payload['status'] == "SUCCESS", pprint.pformat(payload) + + if payload['status'] == 'SUCCESS': + print('Success') + return payload['message'] + else: + raise RuntimeError('Get_key action failed with: {}'.format(payload)) + + def update_ansible(clients, **workflow_input): workflow_client = clients.workflow_engine tripleoclients = clients.tripleoclient