Skip to content

Commit

Permalink
WIP: Baremetal: Pull data from ironic inspector and annotate BareMeta…
Browse files Browse the repository at this point in the history
…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
imain committed May 13, 2020
1 parent 870444c commit 971ce92
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
@@ -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

@@ -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

0 comments on commit 971ce92

Please sign in to comment.