Merge "Use newer bluval images"
[icn.git] / tools / vagrant / create_nodes_json_sample.sh
1 #!/bin/bash
2 set -eu -o pipefail
3
4 site=$1; shift
5
6 nodes_json_path="deploy/metal3/scripts/nodes.json.sample"
7 ipmi_host=$(virsh -c qemu:///system net-dumpxml ${site}-baremetal | xmlstarlet sel -t -v "//network/ip/@address")
8
9 cat <<EOF >${nodes_json_path}
10 {
11   "nodes": [
12 EOF
13
14 while (("$#")); do
15     name=$1; shift
16     ipmi_port=$1; shift
17     baremetal_mac=$(virsh -c qemu:///system dumpxml "${site}-${name}" | xmlstarlet sel -t -v "//interface[source/@network='${site}-baremetal']/mac/@address")
18     provisioning_mac=$(virsh -c qemu:///system dumpxml "${site}-${name}" | xmlstarlet sel -t -v "//interface[source/@network='${site}-provisioning']/mac/@address")
19     if (("$#")); then comma=","; else comma=""; fi
20     cat <<EOF >>${nodes_json_path}
21     {
22       "name": "${name}",
23       "ipmi_driver_info": {
24         "username": "admin",
25         "password": "password",
26         "address": "${ipmi_host}:${ipmi_port}"
27       },
28       "os": {
29         "image_name": "focal-server-cloudimg-amd64.img",
30         "username": "ubuntu",
31         "password": "mypasswd"
32       },
33       "net": {
34         "links": [
35           {
36             "id": "baremetal_nic",
37             "ethernet_mac_address": "${baremetal_mac}",
38             "type": "phy"
39           },
40           {
41             "id": "provisioning_nic",
42             "ethernet_mac_address": "${provisioning_mac}",
43             "type": "phy"
44           }
45         ],
46         "networks": [
47           {
48             "id": "baremetal",
49             "link": "baremetal_nic",
50             "type": "ipv4_dhcp"
51           },
52           {
53             "id": "provisioning",
54             "link": "provisioning_nic",
55             "type": "ipv4_dhcp"
56           }
57         ],
58         "services": []
59       }
60     }${comma}
61 EOF
62 done
63 cat <<EOF >>${nodes_json_path}
64   ]
65 }
66 EOF