Merge "Remove mistral workflow to return the ssh private key"
This commit is contained in:
commit
b4c3d7674b
@ -78,6 +78,7 @@ ENABLE_SSH_ADMIN_SSH_PORT_TIMEOUT = 300
|
|||||||
ADDITIONAL_ARCHITECTURES = ['ppc64le']
|
ADDITIONAL_ARCHITECTURES = ['ppc64le']
|
||||||
|
|
||||||
DEFAULT_VALIDATIONS_BASEDIR = '/usr/share/openstack-tripleo-validations'
|
DEFAULT_VALIDATIONS_BASEDIR = '/usr/share/openstack-tripleo-validations'
|
||||||
|
DEFAULT_WORK_DIR = '/var/lib/mistral'
|
||||||
|
|
||||||
ANSIBLE_VALIDATION_DIR = \
|
ANSIBLE_VALIDATION_DIR = \
|
||||||
'/usr/share/openstack-tripleo-validations/playbooks'
|
'/usr/share/openstack-tripleo-validations/playbooks'
|
||||||
|
@ -1448,28 +1448,13 @@ def run_update_ansible_action(log, clients, stack, nodes, inventory,
|
|||||||
inventory=inventory,
|
inventory=inventory,
|
||||||
workdir=workdir,
|
workdir=workdir,
|
||||||
ssh_user=ssh_user,
|
ssh_user=ssh_user,
|
||||||
key=ssh_private_key(workdir, priv_key),
|
key=priv_key,
|
||||||
module_path='/usr/share/ansible-modules',
|
module_path='/usr/share/ansible-modules',
|
||||||
limit_hosts=nodes,
|
limit_hosts=nodes,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
skip_tags=skip_tags)
|
skip_tags=skip_tags)
|
||||||
|
|
||||||
|
|
||||||
def ssh_private_key(workdir, key):
|
|
||||||
if not key:
|
|
||||||
return None
|
|
||||||
if (isinstance(key, six.string_types) and
|
|
||||||
os.path.exists(key)):
|
|
||||||
os.chmod(key, 0o600)
|
|
||||||
return key
|
|
||||||
|
|
||||||
path = os.path.join(workdir, 'ssh_private_key')
|
|
||||||
with open(path, 'w') as ssh_key:
|
|
||||||
ssh_key.write(key)
|
|
||||||
os.chmod(path, 0o600)
|
|
||||||
return path
|
|
||||||
|
|
||||||
|
|
||||||
def parse_extra_vars(extra_var_strings):
|
def parse_extra_vars(extra_var_strings):
|
||||||
"""Parses extra variables like Ansible would.
|
"""Parses extra variables like Ansible would.
|
||||||
|
|
||||||
|
@ -102,12 +102,11 @@ class ExternalUpdateRun(command.Command):
|
|||||||
stack = parsed_args.stack
|
stack = parsed_args.stack
|
||||||
|
|
||||||
ansible_dir = None
|
ansible_dir = None
|
||||||
key = None
|
key = package_update.get_key(stack=stack)
|
||||||
# Disable mistral
|
# Disable mistral
|
||||||
if parsed_args.no_workflow:
|
if parsed_args.no_workflow:
|
||||||
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
||||||
stack)
|
stack)
|
||||||
key = package_update.get_key(clients)
|
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
inventory = oooutils.get_tripleo_ansible_inventory(
|
inventory = oooutils.get_tripleo_ansible_inventory(
|
||||||
|
@ -102,12 +102,11 @@ class ExternalUpgradeRun(command.Command):
|
|||||||
stack = parsed_args.stack
|
stack = parsed_args.stack
|
||||||
|
|
||||||
ansible_dir = None
|
ansible_dir = None
|
||||||
key = None
|
key = package_update.get_key(stack=stack)
|
||||||
# Disable mistral
|
# Disable mistral
|
||||||
if parsed_args.no_workflow:
|
if parsed_args.no_workflow:
|
||||||
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
||||||
stack)
|
stack)
|
||||||
key = package_update.get_key(clients)
|
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
inventory = oooutils.get_tripleo_ansible_inventory(
|
inventory = oooutils.get_tripleo_ansible_inventory(
|
||||||
|
@ -159,12 +159,11 @@ class FFWDUpgradeRun(command.Command):
|
|||||||
stack = parsed_args.stack
|
stack = parsed_args.stack
|
||||||
|
|
||||||
ansible_dir = None
|
ansible_dir = None
|
||||||
key = None
|
key = package_update.get_key(stack=stack)
|
||||||
# Disable mistral
|
# Disable mistral
|
||||||
if parsed_args.no_workflow:
|
if parsed_args.no_workflow:
|
||||||
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
||||||
stack)
|
stack)
|
||||||
key = package_update.get_key(clients)
|
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
inventory = oooutils.get_tripleo_ansible_inventory(
|
inventory = oooutils.get_tripleo_ansible_inventory(
|
||||||
|
@ -147,12 +147,11 @@ class UpdateRun(command.Command):
|
|||||||
stack = parsed_args.stack
|
stack = parsed_args.stack
|
||||||
|
|
||||||
ansible_dir = None
|
ansible_dir = None
|
||||||
key = None
|
key = package_update.get_key(stack=stack)
|
||||||
# Disable mistral
|
# Disable mistral
|
||||||
if parsed_args.no_workflow:
|
if parsed_args.no_workflow:
|
||||||
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
||||||
stack)
|
stack)
|
||||||
key = package_update.get_key(clients)
|
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
limit_hosts = parsed_args.limit
|
limit_hosts = parsed_args.limit
|
||||||
|
@ -203,12 +203,11 @@ class UpgradeRun(command.Command):
|
|||||||
stack = parsed_args.stack
|
stack = parsed_args.stack
|
||||||
|
|
||||||
ansible_dir = None
|
ansible_dir = None
|
||||||
key = None
|
key = package_update.get_key(stack=stack)
|
||||||
# Disable mistral
|
# Disable mistral
|
||||||
if parsed_args.no_workflow:
|
if parsed_args.no_workflow:
|
||||||
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
ansible_dir = oooutils.download_ansible_playbooks(orchestration,
|
||||||
stack)
|
stack)
|
||||||
key = package_update.get_key(clients)
|
|
||||||
|
|
||||||
# Run ansible:
|
# Run ansible:
|
||||||
limit_hosts = parsed_args.limit
|
limit_hosts = parsed_args.limit
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
|
import os
|
||||||
import pprint
|
import pprint
|
||||||
import time
|
import time
|
||||||
|
|
||||||
@ -20,6 +21,7 @@ from openstackclient import shell
|
|||||||
from tripleoclient import exceptions
|
from tripleoclient import exceptions
|
||||||
from tripleoclient import utils
|
from tripleoclient import utils
|
||||||
|
|
||||||
|
from tripleoclient import constants
|
||||||
from tripleoclient.workflows import base
|
from tripleoclient.workflows import base
|
||||||
|
|
||||||
_WORKFLOW_TIMEOUT = 120 * 60 # 2h
|
_WORKFLOW_TIMEOUT = 120 * 60 # 2h
|
||||||
@ -85,26 +87,32 @@ def get_config(clients, **workflow_input):
|
|||||||
raise RuntimeError('Minor update failed with: {}'.format(payload))
|
raise RuntimeError('Minor update failed with: {}'.format(payload))
|
||||||
|
|
||||||
|
|
||||||
def get_key(clients, **workflow_input):
|
def get_key(stack):
|
||||||
workflow_client = clients.workflow_engine
|
"""Returns the private key from the local file system.
|
||||||
tripleoclients = clients.tripleoclient
|
|
||||||
|
|
||||||
with tripleoclients.messaging_websocket() as ws:
|
Searches for and returns the stack private key. If the key is inaccessible
|
||||||
execution = base.start_workflow(
|
for any reason, the process will fall back to using the users key. If no
|
||||||
workflow_client,
|
key is found, this method will return None.
|
||||||
'tripleo.package_update.v1.get_key',
|
|
||||||
workflow_input=workflow_input
|
|
||||||
)
|
|
||||||
|
|
||||||
for payload in base.wait_for_messages(workflow_client, ws, execution,
|
:params stack: name of the stack to use
|
||||||
_WORKFLOW_TIMEOUT):
|
:type stack: String
|
||||||
assert payload['status'] == "SUCCESS", pprint.pformat(payload)
|
|
||||||
|
|
||||||
if payload['status'] == 'SUCCESS':
|
:returns: String || None
|
||||||
print('Success')
|
"""
|
||||||
return payload['message']
|
|
||||||
|
stack_dir = os.path.join(constants.DEFAULT_WORK_DIR, stack)
|
||||||
|
stack_key_file = os.path.join(stack_dir, 'ssh_private_key')
|
||||||
|
user_dir = os.path.join(os.path.expanduser("~"), '.ssh')
|
||||||
|
user_key_file = os.path.join(user_dir, 'id_rsa_tripleo')
|
||||||
|
for key_file in [stack_key_file, user_key_file]:
|
||||||
|
try:
|
||||||
|
if os.path.exists(key_file):
|
||||||
|
with open(key_file):
|
||||||
|
return key_file
|
||||||
|
except IOError:
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
raise RuntimeError('Get_key action failed with: {}'.format(payload))
|
return
|
||||||
|
|
||||||
|
|
||||||
def update_ansible(clients, **workflow_input):
|
def update_ansible(clients, **workflow_input):
|
||||||
|
Loading…
Reference in New Issue
Block a user