|
1 | 1 | #!/bin/bash |
2 | 2 |
|
3 | | -# for node in $(jq -c '.[]' nodes.json); do |
4 | | -# uuid=$(echo ${node} | jq -r '.uuid') |
5 | | -# node_name=$(echo ${node} | jq -r '.name') |
6 | | -# baremetal node create --driver redfish --driver-info \ |
7 | | -# redfish_address=http://192.168.111.1:8000 --driver-info \ |
8 | | -# redfish_system_id=/redfish/v1/Systems/${uuid} --driver-info \ |
9 | | -# redfish_username=admin --driver-info redfish_password=password \ |
10 | | -# --uuid ${uuid} \ |
11 | | -# --name ${node_name} |
12 | | -# done |
13 | | -# |
14 | | -# sleep 10 |
| 3 | +for node in $(jq -c '.[]' nodes.json); do |
| 4 | + uuid=$(echo "${node}" | jq -r '.uuid') |
| 5 | + node_name=$(echo "${node}" | jq -r '.name') |
| 6 | +baremetal node create --driver redfish --driver-info \ |
| 7 | + redfish_address=http://192.168.111.1:8000 --driver-info \ |
| 8 | + redfish_system_id=/redfish/v1/Systems/"${uuid}" --driver-info \ |
| 9 | + redfish_username=admin --driver-info redfish_password=password \ |
| 10 | + --uuid "${uuid}" \ |
| 11 | + --name "${node_name}" |
| 12 | +done |
| 13 | + |
| 14 | +sleep 10 |
15 | 15 | nodes=$(baremetal node list -f json) |
16 | | -n_nodes=$(echo ${nodes} | jq -c '.[]' | wc -l) |
| 16 | +n_nodes=$(echo "${nodes}" | jq -c '.[]' | wc -l) |
17 | 17 | inspected_nodes="" |
18 | 18 | while true; do |
19 | 19 | nodes=$(baremetal node list -f json) |
20 | | - for row in $(echo $nodes | jq -c -r '.[] | @base64'); do |
21 | | - node=$(echo ${row} | base64 --decode) |
22 | | - node_name=$(echo ${node} | jq -r '.Name') |
23 | | - provisioning_state=$(echo ${node} | jq -r '."Provisioning State"') |
| 20 | + for row in $(echo "$nodes" | jq -c -r '.[] | @base64'); do |
| 21 | + node=$(echo "${row}" | base64 --decode) |
| 22 | + node_name=$(echo "${node}" | jq -r '.Name') |
| 23 | + provisioning_state=$(echo "${node}" | jq -r '."Provisioning State"') |
24 | 24 | if [[ $provisioning_state == "enroll" ]]; then |
25 | | - baremetal node manage ${node_name} |
| 25 | + baremetal node manage "${node_name}" |
26 | 26 | continue |
27 | 27 | fi |
28 | 28 | if [[ $provisioning_state == "verifying" ]]; then |
29 | 29 | continue |
30 | 30 | fi |
31 | | - power_state=$(echo ${node} | jq -r '."Power State"') |
32 | | - if [[ $power_state == "power off" ]]; then |
33 | | - baremetal node power on ${node_name} |
34 | | - continue |
35 | | - fi |
36 | 31 | if [[ $provisioning_state == "inspect wait" ]]; then |
37 | 32 | continue |
38 | 33 | fi |
39 | 34 | if [[ $provisioning_state == "manageable" ]]; then |
40 | | - inspection_info=$(baremetal node show $node_name -f json | jq -r '.inspection_finished_at') |
| 35 | + inspection_info=$(baremetal node show "$node_name" -f json | jq -r '.inspection_finished_at') |
41 | 36 | if [[ $inspection_info == "null" ]]; then |
42 | | - baremetal node inspect ${node_name} |
| 37 | + baremetal node inspect "${node_name}" |
43 | 38 | else |
44 | 39 | if [[ $inspected_nodes == *$node_name* ]]; then |
45 | 40 | continue |
46 | 41 | fi |
47 | 42 | inspected_nodes="${inspected_nodes} ${node_name}" |
48 | 43 | echo "${node_name} was inspected at ${inspection_info}" |
49 | | - if [[ $(echo $inspected_nodes | wc -w) == $n_nodes ]]; then |
| 44 | + if [[ $(echo "$inspected_nodes" | wc -w) == "$n_nodes" ]]; then |
50 | 45 | exit 0 |
51 | 46 | fi |
52 | 47 | fi |
53 | 48 | fi |
54 | 49 | if [[ $provisioning_state == "inspect failed" ]]; then |
55 | 50 | inspected_nodes="${inspected_nodes} ${node_name}" |
56 | 51 | echo "Failed to inspect ${node_name}" |
57 | | - if [[ $(echo $inspected_nodes | wc -w) == $n_nodes ]]; then |
| 52 | + if [[ $(echo "$inspected_nodes" | wc -w) == "$n_nodes" ]]; then |
58 | 53 | exit 0 |
59 | 54 | fi |
60 | 55 | fi |
|
0 commit comments