[train-only] Don't always generate keys for ssh
We check mistral environment for ssh keys else generate them. We don't populate mistral environment anymore and end up generating them all the time. Change-Id: I4dcaa29ab5eda3fa3272dd5ad1c1f9029ae98b2d
This commit is contained in:
parent
27c02a58c9
commit
8cc1d6da58
|
@ -22,6 +22,7 @@ import time
|
|||
import yaml
|
||||
|
||||
from heatclient.common import event_utils
|
||||
from mistralclient.api import base as mistralclient_exc
|
||||
from openstackclient import shell
|
||||
import six
|
||||
import tenacity
|
||||
|
@ -199,8 +200,23 @@ def get_hosts_and_enable_ssh_admin(
|
|||
overcloud_ssh_key, enable_ssh_timeout=ENABLE_SSH_ADMIN_TIMEOUT,
|
||||
enable_ssh_port_timeout=ENABLE_SSH_ADMIN_SSH_PORT_TIMEOUT):
|
||||
hosts = get_overcloud_hosts(stack, overcloud_ssh_network)
|
||||
mc = clients.workflow_engine
|
||||
key = utils.get_key(stack=stack.stack_name, needs_pair=True)
|
||||
if key:
|
||||
with open('{}.pub'.format(key), 'rt') as fp:
|
||||
pub_ssh_key = fp.read()
|
||||
with open('{}'.format(key), 'rt') as fp:
|
||||
priv_ssh_key = fp.read()
|
||||
try:
|
||||
mc.environments.get('ssh_keys').variables
|
||||
mc.environments.update(name='ssh_keys',
|
||||
variables={'public_key': pub_ssh_key,
|
||||
'private_key': priv_ssh_key})
|
||||
except mistralclient_exc.APIException:
|
||||
mc.environments.create(name='ssh_keys',
|
||||
variables={'public_key': pub_ssh_key,
|
||||
'private_key': priv_ssh_key})
|
||||
if [host for host in hosts if host]:
|
||||
|
||||
try:
|
||||
enable_ssh_admin(log, clients, stack.stack_name, hosts,
|
||||
overcloud_ssh_user, overcloud_ssh_key,
|
||||
|
|
Loading…
Reference in New Issue