Merge "Add mechanism to send error messages to helper."
This commit is contained in:
commit
92094ecdc5
@ -1,5 +1,5 @@
|
||||
if [ -z "$ISCSI_TARGET_IQN" ]; then
|
||||
echo "iscsi_target_iqn is not defined"
|
||||
err_msg "iscsi_target_iqn is not defined"
|
||||
troubleshoot
|
||||
fi
|
||||
|
||||
@ -13,19 +13,19 @@ while ! target_disk=$(find_disk "$DISK"); do
|
||||
done
|
||||
|
||||
if [ -z "$target_disk" ]; then
|
||||
echo "Could not find disk to use."
|
||||
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
|
||||
echo "Failed to start iscsi target."
|
||||
err_msg "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"
|
||||
d="i=$DEPLOYMENT_ID&k=$DEPLOYMENT_KEY&a=$BOOT_IP_ADDRESS&n=$ISCSI_TARGET_IQN&e=$FIRST_ERR_MSG"
|
||||
wget --post-data "$d" "http://$BOOT_SERVER:10000"
|
||||
|
||||
echo "waiting for notice of complete"
|
||||
|
@ -195,3 +195,33 @@ function troubleshoot() {
|
||||
fi
|
||||
}
|
||||
|
||||
function safe_url_encode() {
|
||||
local str=$1
|
||||
local out=""
|
||||
|
||||
for (( i=0; i<${#str}; i++ )); do
|
||||
c=${str:$i:1}
|
||||
case $c in
|
||||
[a-zA-Z0-9.-_] )
|
||||
out+="$c"
|
||||
;;
|
||||
' ' )
|
||||
out+="+"
|
||||
;;
|
||||
*)
|
||||
#skip it
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "$out"
|
||||
|
||||
}
|
||||
|
||||
function err_msg() {
|
||||
message=$1
|
||||
if [ -z "$FIRST_ERR_MSG" ]; then
|
||||
FIRST_ERR_MSG=$(safe_url_encode "$message")
|
||||
fi
|
||||
echo "$message"
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ readonly DEPLOYMENT_ID=$(get_kernel_parameter deployment_id)
|
||||
readonly DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
|
||||
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
|
||||
readonly TROUBLESHOOT=$(get_kernel_parameter troubleshoot)
|
||||
FIRST_ERR_MSG=
|
||||
|
||||
mount -t sysfs none /sys
|
||||
|
||||
@ -110,7 +111,7 @@ while ! BOOT_INTERFACE=$(find_interface "$BOOT_MAC_ADDRESS"); do
|
||||
sleep 5
|
||||
done
|
||||
if [ -z "$BOOT_INTERFACE" ]; then
|
||||
echo "could not find an interface owns MAC=$BOOT_MAC_ADDRESS"
|
||||
err_msg "Could not find an interface that owns MAC: $BOOT_MAC_ADDRESS"
|
||||
troubleshoot
|
||||
fi
|
||||
|
||||
@ -122,7 +123,7 @@ if [ $? -ne 0 ]; then
|
||||
sleep 10
|
||||
ifconfig "$BOOT_INTERFACE" up
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to up $BOOT_INTERFACE"
|
||||
err_msg "Failed to ifconfig up $BOOT_INTERFACE"
|
||||
troubleshoot
|
||||
fi
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user