Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Baremetal: Pull data from ironic inspector and annotate BareMeta…
…lHost The idea here is to create a script which can pull data from ironic inspector (this part is implemented) and then either transform it and load it into the BareMetalHost CR in the existing annotation format - see: metal3-io/baremetal-operator#470 Or we'll add a new annotation which can directly accept the ironic inspector output.
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
data/data/bootstrap/baremetal/files/usr/local/bin/master-bmh-update.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/sh | ||
|
||
. /usr/local/bin/release-image.sh | ||
|
||
wait_for_existence() { | ||
while [ ! -e "${1}" ] | ||
do | ||
sleep 5 | ||
echo "bootkube not done, sleeping.." | ||
done | ||
} | ||
|
||
# Wait for the API to become active | ||
until curl http://localhost:6385/v1/nodes; do | ||
echo Waiting for API | ||
sleep 5 | ||
done | ||
|
||
# Wait for the nodes to become active after introspection. | ||
while curl http://localhost:6385/v1/nodes | jq '.nodes[] | .provision_state' | grep -v active; do | ||
echo Waiting for nodes to be come active | ||
sleep 5 | ||
done | ||
|
||
# Just for debugging for now. | ||
for node in $(curl http://localhost:6385/v1/nodes | jq -r '.nodes[] | .uuid'); do | ||
echo host $node | ||
curl http://localhost:5050/v1/introspection/$node/data | ||
done | ||
|
||
# Wait for bootkube to come up. We want to talk to the full instance not | ||
# the bootstrap openshift | ||
wait_for_existence /opt/openshift/.bootkube.done | ||
|
||
echo nodes are up | ||
|
||
BAREMETAL_OPERATOR_IMAGE=$(image_for baremetal-operator) | ||
|
||
# Now we go through each image.. | ||
for node in $(curl http://localhost:6385/v1/nodes | jq -r '.nodes[] | .uuid'); do | ||
echo host $node | ||
# And use the baremetal operator tool to load the introspection data into | ||
# the BareMetalHost CRs as annotations, which BMO then picks up. | ||
podman run --quiet --net=host \ | ||
--rm \ | ||
--name baremetal-operator \ | ||
--entrypoint /bin/make-introspection \ | ||
"${BAREMETAL_OPERATOR_IMAGE}" \ | ||
http://localhost:5050/v1 $node | ||
done | ||
|
13 changes: 13 additions & 0 deletions
13
data/data/bootstrap/baremetal/systemd/units/master-bmh-update.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Update master BareMetalHosts with introspection data | ||
Wants=bootkube.service | ||
After=bootkube.service release-image.service | ||
|
||
[Service] | ||
ExecStart=/usr/local/bin/master-bmh-update.sh | ||
|
||
Restart=on-failure | ||
RestartSec=5s | ||
|
||
[Install] | ||
WantedBy=multi-user.target |