005df554100e08850cb9c8cd83d6d1e60f862e02
[releng/builder.git] / jjb / integration / integration-get-apex-addresses.sh
1 #!/bin/bash -l
2 # Get the Controller and Tools VM slave addresses
3
4 set -ex -o pipefail
5
6 git clone https://gerrit.opnfv.org/gerrit/releng.git /tmp/opnfv_releng
7
8 openstack object save OPNFV-APEX-SNAPSHOTS node.yaml
9 openstack object save OPNFV-APEX-SNAPSHOTS id_rsa --file /tmp/id_rsa
10 cat > ~/.ssh/config <<EOF
11 Host 192.0.2.*
12   User heat-admin
13   IdentityFile /tmp/id_rsa
14 EOF
15 ln -s /tmp/id_rsa ~/.ssh/robot_id_rsa
16 chmod 0600 /tmp/id_rsa ~/.ssh/config
17
18 NUM_OPENSTACK_SYSTEM=3
19 NUM_ODL_SYSTEM=1
20 ODL_SYSTEM_IP=$(python /tmp/opnfv_releng/jjb/cperf/parse-node-yaml.py get_value -k address --node-type controller --file node.yaml)
21 OPENSTACK_COMPUTE_NODE_1_IP=$(python /tmp/opnfv_releng/jjb/cperf/parse-node-yaml.py get_value -k address --node-type compute --node-number 1 --file node.yaml)
22 OPENSTACK_COMPUTE_NODE_2_IP=$(python /tmp/opnfv_releng/jjb/cperf/parse-node-yaml.py get_value -k address --node-type compute --node-number 2 --file node.yaml)
23 OPENSTACK_CONTROL_NODE_1_IP=$ODL_SYSTEM_IP
24 ODL_SYSTEM_1_IP=$ODL_SYSTEM_IP
25
26 # shellcheck disable=SC2129
27 echo "NUM_OPENSTACK_SYSTEM=$NUM_OPENSTACK_SYSTEM" >> slave_addresses.txt
28 echo "NUM_ODL_SYSTEM=$NUM_ODL_SYSTEM" >> slave_addresses.txt
29 echo "ODL_SYSTEM_IP=$ODL_SYSTEM_IP" >> slave_addresses.txt
30 echo "CONTROLLER_1_IP=$ODL_SYSTEM_IP" >> slave_addresses.txt
31
32 echo "OPENSTACK_COMPUTE_NODE_1_IP=$OPENSTACK_COMPUTE_NODE_1_IP" >> slave_addresses.txt
33 echo "OPENSTACK_COMPUTE_NODE_2_IP=$OPENSTACK_COMPUTE_NODE_2_IP" >> slave_addresses.txt
34 echo "OPENSTACK_CONTROL_NODE_1_IP=$OPENSTACK_CONTROL_NODE_1_IP" >> slave_addresses.txt
35 echo "ODL_SYSTEM_1_IP=$ODL_SYSTEM_1_IP" >> slave_addresses.txt
36
37 cat slave_addresses.txt
38
39 # Add Robot builder to new Apex network (adding 2nd nic). The Apex snapshots
40 # have a single nic with a static ip on the 192.0.2.0/24 network. The eth0
41 # nic on the robot builders come up on the standard 10 net from our cloud
42 # infra. To give connectivity between the robot builder and the apex vms,
43 # a new network is created for the 192.0.2.0/subnet and this second nic is
44 # added to that network. DHCP is used for the robot builder in a range outside
45 # of what any apex ip address would be.
46 JOB_SUM=$(echo "$JOB_NAME" | sum | awk '{ print $1 }')
47 VM_NAME="$JOB_SUM-$BUILD_NUMBER"
48 SERVER_ID="$(openstack server show -f value -c id "$(hostname -s)")"
49 NETWORK_ID="$(openstack network show -f value -c id "$SILO-$VM_NAME-APEX_192_network")"
50 openstack server add network "$SERVER_ID" "$NETWORK_ID"
51 ETH1_MAC=$(ip address show eth1 | grep ether | awk -F' ' '{print $2}')
52 ETH1_SCRIPT="/etc/sysconfig/network-scripts/ifcfg-eth1"
53 sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 "$ETH1_SCRIPT"
54 sudo sed -i "s/eth0/eth1/; s/^HWADDR=.*/HWADDR=$ETH1_MAC/" "$ETH1_SCRIPT"
55 sudo echo 'PEERDNS=no' | sudo tee -a "$ETH1_SCRIPT"
56 sudo echo 'DEFROUTE=no' | sudo tee -a "$ETH1_SCRIPT"
57 cat "$ETH1_SCRIPT"
58 sudo ifup eth1
59 ip a
60
61 echo "Testing Connectivity To Apex Systems"
62 ping -c3 "$OPENSTACK_CONTROL_NODE_1_IP"
63 ping -c3 "$OPENSTACK_COMPUTE_NODE_1_IP"
64 ping -c3 "$OPENSTACK_COMPUTE_NODE_2_IP"
65
66 # vim: sw=4 ts=4 sts=4 et ft=sh :
67
68