Make mistral optional for Ansible Update and Upgrade
Add option: --no-workflow to enable running ansible update and upgrade outside of mistral. Depends-On: I0c106cf795a6830a87790f1075889a6a4db65d22 Change-Id: I77f1a4efb5c60ffb5d7363d0343101fb6e702292
This commit is contained in:
parent
cd42f44769
commit
92a2fda8e6
@ -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()
|
||||
|
@ -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()
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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()
|
||||
|
@ -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.")
|
||||
|
@ -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.")
|
||||
|
@ -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):
|
||||
|
@ -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):
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user