diskimage-builder/elements/deploy/init
Dan Prince 0ff82aff46 Make bash troubleshooting configurable
Adds a new 'troubleshooting' function which encapsulates
the things we might want to do when something bad happens.
Typically this is echo'ing a simple message and launching a
bash shell.

The new troubleshooting function also makes use of a new
'troubleshoot' kernel param which if specific will allow you to
hang the deployment process and interactively debug the deploy_ramdisk
via a bash shell on a console.

Troubleshoot is disabled by default.

Fixes LP Bug #1191043.

Change-Id: I2cba8a9674075ba7e420027d40ef8cbe756cf07e
2013-06-18 14:28:52 -04:00

38 lines
771 B
Plaintext

if [ -z "$ISCSI_TARGET_IQN" ]; then
echo "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
echo "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
echo "Failed to start iscsi target."
troubleshoot
fi
echo "request boot server to deploy image"
d="i=$DEPLOYMENT_ID&k=$DEPLOYMENT_KEY&a=$BOOT_IP_ADDRESS&n=$ISCSI_TARGET_IQN"
wget --post-data "$d" "http://$BOOT_SERVER:10000"
echo "waiting for notice of complete"
nc -l -p 10000
echo "stop iSCSI target on $target_disk"
stop_iscsi_target