Build VM e2etest site values
[icn.git] / tools / vagrant / create_machine_resource.sh
1 #!/bin/bash
2 set -eu -o pipefail
3
4 index=$1
5 site=$2
6 name=$3
7
8 ipmi_host=$(virsh -c qemu:///system net-dumpxml ${site}-baremetal | xmlstarlet sel -t -v "//network/ip/@address")
9 ipmi_port=$((6230+index-1))
10 boot_mac=$(virsh -c qemu:///system dumpxml "${site}-${name}" | xmlstarlet sel -t -v "//interface[source/@network='${site}-provisioning']/mac/@address")
11
12 if [[ ${index} == 1 ]]; then
13     mkdir -p build/site/${site}
14     cat <<EOF >build/site/${site}/machines-values.yaml
15 machines:
16 EOF
17 fi
18 cat <<EOF >>build/site/${site}/machines-values.yaml
19   machine-${index}:
20     bootMACAddress: ${boot_mac}
21     bmcAddress: ipmi://${ipmi_host}:${ipmi_port}
22     bmcUsername: admin
23     bmcPassword: password
24 EOF