Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
[train-only] Don't always generate keys for ssh
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rabi committed Jul 20, 2022
1 parent 27c02a5 commit 8cc1d6d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tripleoclient/workflows/deployment.py
Expand Up @@ -22,6 +22,7 @@
import yaml

from heatclient.common import event_utils
from mistralclient.api import base as mistralclient_exc
from openstackclient import shell
import six
import tenacity
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8cc1d6d

Please sign in to comment.