e1afdc20ab9180fc022a65767082fdb5a3debea4
[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 mkdir -p build/site/${site}
13 cat <<EOF >build/site/${site}/machine-${index}-values.yaml
14 machineName: machine-${index}
15 bootMACAddress: ${boot_mac}
16 bmcAddress: ipmi://${ipmi_host}:${ipmi_port}
17 bmcUsername: admin
18 bmcPassword: password
19 EOF