urgent bug fixes for danube (2)
[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     # NOTE: while executing command as doctor user,
33     #       'OS_PROJECT_ID' env parameter make openstack clients confused.
34     unset OS_PROJECT_ID
35 }
36
37 function get_compute_ip_from_hostname {
38     local compute_host=$1
39
40     compute_host_in_undercloud=${compute_host%%.*}
41     COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
42                  "source stackrc;
43                   nova show $compute_host_in_undercloud  | \
44                   awk '/ ctlplane network /{print \$5}'")
45     die_if_not_set $LINENO COMPUTE_IP "Could get IP address of $compute_host."
46 }
47
48 function cleanup_installer {
49     # Noop
50     return
51 }