summaryrefslogtreecommitdiffstats
path: root/tests/lib/installer
blob: 13953d28715be3fc6622d9d1a7b905519692d5c0 (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
#!/bin/bash

INSTALLER_TYPE=${INSTALLER_TYPE:-local}
ssh_opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"

function is_installer_supported {
    local installer="$1"
    [[ -f $TOP_DIR/lib/installers/$installer ]]
}

function is_installer {
    local installer="$1"
    [[ $installer == $INSTALLER_TYPE ]]
}

function validate_installer_lib {
    local xtrace
    xtrace=$(set +o | grep xtrace)
    set +o xtrace
    for p in COMPUTE_USER ssh_opts_cpu
    do
        die_if_not_set $LINENO $p \
            "Parameter $p for $INSTALLER_TYPE is missing."
    done
    for f in setup_installer get_compute_ip_from_hostname cleanup_installer
    do
        die_if_not_defined $LINENO $f \
            "Mandatory function ${f}() for $INSTALLER_TYPE is missing."
    done
    $xtrace
}

if ! is_installer_supported $INSTALLER_TYPE; then
    die $LINENO "INSTALLER_TYPE=$INSTALLER_TYPE is not supported."
fi

source $TOP_DIR/lib/installers/$INSTALLER_TYPE

validate_installer_lib