summaryrefslogtreecommitdiffstats
path: root/tests/lib/installers/apex
blob: e353d251ce07c5ef9a60cc6d942e484b65496632 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash

COMPUTE_USER=${COMPUTE_USER:-heat-admin}
ssh_opts_cpu="$ssh_opts -i instack_key"

function get_installer_ip {
    is_set INSTALLER_IP && return
    INSTALLER_IP=$(get_first_vnic_ip instack)
}

function installer_get_ssh_keys {
    sudo scp $ssh_opts "root@$INSTALLER_IP:/home/stack/.ssh/id_rsa" instack_key
    sudo chown $(whoami):$(whoami) instack_key
    chmod 400 instack_key
}

function get_controller_ips {
    is_set CONTROLLER_IPS && return
    get_installer_ip
    CONTROLLER_IPS=$(sudo ssh $ssh_opts $INSTALLER_IP \
                     "source stackrc
                      nova list | grep ' overcloud-controller-[0-9] ' | \
                      sed -e 's/^.*ctlplane=//' -e 's/ *|\$//'")
    die_if_not_set $LINENO CONTROLLER_IPS "No controller IPs"
}

function setup_installer {
    get_installer_ip
    installer_get_ssh_keys
    get_controller_ips
}

function get_compute_ip_from_hostname {
    local compute_host=$1

    compute_host_in_undercloud=${compute_host%%.*}
    COMPUTE_IP=$(sudo ssh $ssh_opts $INSTALLER_IP \
                 "source stackrc;
                  nova show $compute_host_in_undercloud  | \
                  awk '/ ctlplane network /{print \$5}'")
    die_if_not_set $LINENO COMPUTE_IP "Could get IP address of $compute_host."
}

function cleanup_installer {
    # Noop
    return
}