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
		
			
				
	
	
		
			38 lines
		
	
	
		
			797 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			797 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
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
 | 
						|
 | 
						|
echo "request boot server to deploy image"
 | 
						|
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"
 | 
						|
nc -l -p 10000
 | 
						|
 | 
						|
echo "stop iSCSI target on $target_disk"
 | 
						|
 | 
						|
stop_iscsi_target
 | 
						|
 |