5 # whitespace (space or newline) separated list
6 OVERCLOUD_HOSTS=${OVERCLOUD_HOSTS:-""}
7 OVERCLOUD_SSH_USER=${OVERCLOUD_SSH_USER:-"$USER"}
8 # this is just for compatibility with CI
9 SUBNODES_SSH_KEY=${SUBNODES_SSH_KEY:-"$HOME/.ssh/id_rsa"}
10 # this is the intended variable for overriding
11 OVERCLOUD_SSH_KEY=${OVERCLOUD_SSH_KEY:-"$SUBNODES_SSH_KEY"}
15 function overcloud_ssh_hosts_json {
16 echo "$OVERCLOUD_HOSTS" | python -c '
17 from __future__ import print_function
19 print(json.dumps(re.split("\s+", sys.stdin.read().strip())))'
22 function overcloud_ssh_key_json {
23 # we pass the contents to Mistral instead of just path, otherwise
24 # the key file would have to be readable for the mistral user
25 cat "$OVERCLOUD_SSH_KEY" | python -c 'import json,sys; print(json.dumps(sys.stdin.read()))'
28 function workflow_finished {
29 local execution_id="$1"
30 openstack workflow execution show -f shell $execution_id | grep 'state="SUCCESS"' > /dev/null
33 if [ -z "$OVERCLOUD_HOSTS" ]; then
34 echo 'Please set $OVERCLOUD_HOSTS'
38 echo "Starting workflow to create ssh admin on deployed servers."
39 echo "SSH user: $OVERCLOUD_SSH_USER"
40 echo "SSH key file: $OVERCLOUD_SSH_KEY"
41 echo "Hosts: $OVERCLOUD_HOSTS"
44 EXECUTION_PARAMS="{\"ssh_user\": \"$OVERCLOUD_SSH_USER\", \"ssh_servers\": $(overcloud_ssh_hosts_json), \"ssh_private_key\": $(overcloud_ssh_key_json)}"
45 EXECUTION_CREATE_OUTPUT=$(openstack workflow execution create -f shell -d 'deployed server ssh admin creation' tripleo.access.v1.enable_ssh_admin "$EXECUTION_PARAMS")
46 echo "$EXECUTION_CREATE_OUTPUT"
47 EXECUTION_ID=$(echo "$EXECUTION_CREATE_OUTPUT" | grep '^id=' | awk '-F"' '{ print $2 }')
49 if [ -z "$EXECUTION_ID" ]; then
50 echo "Failed to get workflow execution ID for ssh admin creation workflow"
54 echo -n "Waiting for the workflow execution to finish (id $EXECUTION_ID)."
55 while ! workflow_finished $EXECUTION_ID; do