Add mechanism to send error messages to helper.
Adds a new err_msg function which is used to: -echo feedback to the deploy ramdisk console -keep track of the first error message we hit so that we can send it along to the baremetal-deploy-helper. Also, updates our wget request back to baremetal-deploy-helper to include the first the first error message (if any) as the 'e' parameter. The err_msg uses a new simple safe_url_encode function to ensure we don't send invalid characters in our HTTP post requests. Change-Id: I5a623a6f66cde8d81ff1e75800dc2953ca2703a8
This commit is contained in:
parent
0ff82aff46
commit
04bfd491ad
@ -1,5 +1,5 @@
|
|||||||
if [ -z "$ISCSI_TARGET_IQN" ]; then
|
if [ -z "$ISCSI_TARGET_IQN" ]; then
|
||||||
echo "iscsi_target_iqn is not defined"
|
err_msg "iscsi_target_iqn is not defined"
|
||||||
troubleshoot
|
troubleshoot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -13,19 +13,19 @@ while ! target_disk=$(find_disk "$DISK"); do
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$target_disk" ]; then
|
if [ -z "$target_disk" ]; then
|
||||||
echo "Could not find disk to use."
|
err_msg "Could not find disk to use."
|
||||||
troubleshoot
|
troubleshoot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "start iSCSI target on $target_disk"
|
echo "start iSCSI target on $target_disk"
|
||||||
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
|
start_iscsi_target "$ISCSI_TARGET_IQN" "$target_disk" ALL
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to start iscsi target."
|
err_msg "Failed to start iscsi target."
|
||||||
troubleshoot
|
troubleshoot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "request boot server to deploy image"
|
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"
|
wget --post-data "$d" "http://$BOOT_SERVER:10000"
|
||||||
|
|
||||||
echo "waiting for notice of complete"
|
echo "waiting for notice of complete"
|
||||||
|
@ -195,3 +195,33 @@ function troubleshoot() {
|
|||||||
fi
|
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 DEPLOYMENT_KEY=$(get_kernel_parameter deployment_key)
|
||||||
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
|
readonly ISCSI_TARGET_IQN=$(get_kernel_parameter iscsi_target_iqn)
|
||||||
readonly TROUBLESHOOT=$(get_kernel_parameter troubleshoot)
|
readonly TROUBLESHOOT=$(get_kernel_parameter troubleshoot)
|
||||||
|
FIRST_ERR_MSG=
|
||||||
|
|
||||||
mount -t sysfs none /sys
|
mount -t sysfs none /sys
|
||||||
|
|
||||||
@ -110,7 +111,7 @@ while ! BOOT_INTERFACE=$(find_interface "$BOOT_MAC_ADDRESS"); do
|
|||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
if [ -z "$BOOT_INTERFACE" ]; then
|
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
|
troubleshoot
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -122,7 +123,7 @@ if [ $? -ne 0 ]; then
|
|||||||
sleep 10
|
sleep 10
|
||||||
ifconfig "$BOOT_INTERFACE" up
|
ifconfig "$BOOT_INTERFACE" up
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Failed to up $BOOT_INTERFACE"
|
err_msg "Failed to ifconfig up $BOOT_INTERFACE"
|
||||||
troubleshoot
|
troubleshoot
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user