Merge "support pep8 check"
[doctor.git] / tests / lib / installer
1 #!/bin/bash
2
3 INSTALLER_TYPE=${INSTALLER_TYPE:-local}
4 ssh_opts="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
5
6 function is_installer_supported {
7     local installer="$1"
8     [[ -f $TOP_DIR/lib/installers/$installer ]]
9 }
10
11 function is_installer {
12     local installer="$1"
13     [[ $installer == $INSTALLER_TYPE ]]
14 }
15
16 function validate_installer_lib {
17     local xtrace
18     xtrace=$(set +o | grep xtrace)
19     set +o xtrace
20     for p in COMPUTE_USER ssh_opts_cpu
21     do
22         die_if_not_set $LINENO $p \
23             "Parameter $p for $INSTALLER_TYPE is missing."
24     done
25     for f in setup_installer get_compute_ip_from_hostname cleanup_installer
26     do
27         die_if_not_defined $LINENO $f \
28             "Mandatory function ${f}() for $INSTALLER_TYPE is missing."
29     done
30     $xtrace
31 }
32
33 if ! is_installer_supported $INSTALLER_TYPE; then
34     die $LINENO "INSTALLER_TYPE=$INSTALLER_TYPE is not supported."
35 fi
36
37 source $TOP_DIR/lib/installers/$INSTALLER_TYPE
38
39 validate_installer_lib