Use computes + control for NUM_OS_SYSTEM
[releng.git] / jjb / functest / functest-env-presetup.sh
1 #!/usr/bin/env bash
2 set -o errexit
3 set -o pipefail
4
5 # Fetch INSTALLER_IP for APEX deployments
6 if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
7     if [ -n "$RC_FILE_PATH" ]; then
8         echo "RC_FILE_PATH is set: ${RC_FILE_PATH}...skipping detecting UC IP"
9     else
10         echo "Gathering IP information for Apex installer VM"
11         ssh_options="-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
12         if sudo virsh list | grep undercloud; then
13             echo "Installer VM detected"
14             undercloud_mac=$(sudo virsh domiflist undercloud | grep default | \
15                       grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
16             export INSTALLER_IP=$(/usr/sbin/arp -e | grep ${undercloud_mac} | awk {'print $1'})
17             export sshkey_vol="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
18             sudo scp $ssh_options root@${INSTALLER_IP}:/home/stack/stackrc ${HOME}/stackrc
19             export stackrc_vol="-v ${HOME}/stackrc:/home/opnfv/functest/conf/stackrc"
20
21             if sudo iptables -C FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
22                 sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
23             fi
24             if sudo iptables -C FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
25                 sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
26             fi
27             echo "Installer ip is ${INSTALLER_IP}"
28         else
29             echo "No available installer VM exists and no credentials provided...exiting"
30             exit 1
31         fi
32     fi
33
34 elif [[ ${INSTALLER_TYPE} == 'daisy' ]]; then
35     echo "Gathering IP information for Daisy installer VM"
36     if sudo virsh list | grep daisy; then
37         echo "Installer VM detected"
38
39         bridge_name=$(sudo virsh domiflist daisy | grep vnet | awk '{print $3}')
40         echo "Bridge is $bridge_name"
41
42         installer_mac=$(sudo virsh domiflist daisy | grep vnet | \
43                       grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
44         export INSTALLER_IP=$(/usr/sbin/arp -e -i $bridge_name | grep ${installer_mac} | head -n 1 | awk {'print $1'})
45
46         echo "Installer ip is ${INSTALLER_IP}"
47     else
48         echo "No available installer VM exists...exiting"
49         exit 1
50     fi
51
52 elif [[ ${INSTALLER_TYPE} == 'fuel' ]]; then
53     if [[ ! "${BRANCH}" =~ "danube" ]]; then
54         echo "Map mcp ssh_key"
55         export sshkey_vol="-v ${SSH_KEY:-/var/lib/opnfv/mcp.rsa}:/root/.ssh/id_rsa"
56     fi
57 fi
58