diskimage-builder/elements/deploy-ironic/init.d/80-deploy-ironic
Ben Nemec eed30adc48 Enable dracut deploy ramdisks
The element builds dracut from source on Ubuntu because the
Ubuntu dracut package is broken and very old, so it can't be
installed properly and causes a number of other issues that
are fixed by using a newer version of Dracut.

This initial version should work in virtualized environments.
Further validation of its suitability for real baremetal
deployments will need to be done in the future, but this should
be sufficient to enable that work.

Regarding Dracut specifically, in order to limit the changes
needed in the existing scripts this element continues to use a
cut down version of the /init script that we were building for the
existing ramdisk.  However, instead of running it as pid 0 it is
run as a Dracut pre-mount hook.  This allows Dracut to set up all
of the hardware and system bits, while falling early enough in the
Dracut sequence to complete the deployment before Dracut would try
to boot off the hard disk.

bp tripleo-juno-dracut-ramdisks
Change-Id: I144c8993fe040169f440bd4f7a428fdbe3d745cf
2014-10-17 21:44:09 -05:00

61 lines
1.5 KiB
Text

readonly IRONIC_API_URL=$(get_kernel_parameter ironic_api_url)
if [ -z "$ISCSI_TARGET_IQN" ]; then
err_msg "iscsi_target_iqn is not defined"
troubleshoot
fi
t=0
while ! target_disk=$(find_disk "$DISK"); do
if [ $t -eq 10 ]; then
break
fi
t=$(($t + 1))
sleep 1
done
if [ -z "$target_disk" ]; then
err_msg "Could not find disk to use."
troubleshoot
fi
echo "start iSCSI target on $target_disk"
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
if [ $? -ne 0 ]; then
err_msg "Failed to start iscsi target."
troubleshoot
fi
if [ "$BOOT_METHOD" = "$VMEDIA_BOOT_TAG" ]; then
TOKEN_FILE="$VMEDIA_DIR/token"
if [ -f "$TOKEN_FILE" ]; then
TOKEN_HEADER="-H 'X-Auth-Token: $(cat $TOKEN_FILE)'"
else TOKEN_HEADER=""
fi
else
TOKEN_FILE=token-$DEPLOYMENT_ID
# Allow multiple versions of the tftp client
if tftp -r $TOKEN_FILE -g $BOOT_SERVER || tftp $BOOT_SERVER -c get $TOKEN_FILE; then
TOKEN_HEADER="-H 'X-Auth-Token: $(cat $TOKEN_FILE)'"
else
TOKEN_HEADER=""
fi
fi
DATA="'{\"address\":\"$BOOT_IP_ADDRESS\",\"key\":\"$DEPLOYMENT_KEY\",\"iqn\":\"$ISCSI_TARGET_IQN\",\"error\":\"$FIRST_ERR_MSG\"}'"
echo "request Ironic API to deploy image"
eval curl -i -X POST \
"$TOKEN_HEADER" \
"-H 'Accept: application/json'" \
"-H 'Content-Type: application/json'" \
-d "$DATA" \
$IRONIC_API_URL/nodes/$DEPLOYMENT_ID/vendor_passthru/pass_deploy_info
echo "waiting for notice of complete"
nc -l -p 10000
echo "stop iSCSI target on $target_disk"
stop_iscsi_target