e353d251ce07c5ef9a60cc6d942e484b65496632
[doctor.git] / tests / lib / installers / apex
1 #!/bin/bash
2
3 COMPUTE_USER=${COMPUTE_USER:-heat-admin}
4 ssh_opts_cpu="$ssh_opts -i instack_key"
5
6 function get_installer_ip {
7     is_set INSTALLER_IP && return
8     INSTALLER_IP=$(get_first_vnic_ip instack)
9 }
10
11 function installer_get_ssh_keys {
12     sudo scp $ssh_opts "root@$INSTALLER_IP:/home/stack/.ssh/id_rsa" instack_key
13     sudo chown $(whoami):$(whoami) instack_key
14     chmod 400 instack_key
15 }
16
17 function get_controller_ips {
18     is_set CONTROLLER_IPS && return
19     get_installer_ip
20     CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \
21                      "source stackrc
22                       nova list | grep ' overcloud-controller-[0-9] ' | \
23                       sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'")
24     die_if_not_set $LINENO CONTROLLER_IPS "No controller IPs"
25 }
26
27 function setup_installer {
28     get_installer_ip
29     installer_get_ssh_keys
30     get_controller_ips
31 }
32
33 function get_compute_ip_from_hostname {
34     local compute_host=$1
35
36     compute_host_in_undercloud=${compute_host%%.*}
37     COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
38                  "source stackrc;
39                   nova show $compute_host_in_undercloud  | \
40                   awk '/ ctlplane network /{print \$5}'")
41     die_if_not_set $LINENO COMPUTE_IP "Could get IP address of $compute_host."
42 }
43
44 function cleanup_installer {
45     # Noop
46     return
47 }