Advertisement
Guest User

Untitled

a guest
Aug 27th, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. #!/bin/bash -ex
  2.  
  3. if [ "$RS_REBOOT" == "true" ];then
  4. echo "rebooting, skipping script."
  5. exit 0
  6. fi
  7.  
  8. rsc_cmd='sudo /home/rightlink/rsc --rl10 cm15'
  9. rsc_json_cmd="/home/rightlink/rsc"
  10.  
  11. #get the current instance values
  12. instance=`$rsc_cmd index_instance_session /api/sessions/instance`
  13. instance_href=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("self")).href' json`
  14. cloud_id=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("self")).href' json | cut -d '/' -f 4`
  15. datacenter_href=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("datacenter")).href' json`
  16. volume_attachments_href=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("volume_attachments")).href' json`
  17.  
  18. #create the new volume
  19. echo "Searching volume_attachment"
  20.  
  21.  
  22. #get volume from instance
  23. volume_attachments=`$rsc_cmd index $volume_attachments_href`
  24.  
  25. #get volume_attachment
  26. volume_attachment_href=`echo $volume_attachments | $rsc_json_cmd --x1 ':has(.rel:val("self")).href' json `
  27. volume_href=`echo $volume_attachments | $rsc_json_cmd --x1 ':has(.rel:val("volume")).href' json`
  28.  
  29. # remove volume from instance
  30. $rsc_cmd destroy $volume_attachment_href
  31.  
  32. #volume_state=`$rsc_cmd show --x1 .state $volume_attachement_href`
  33.  
  34.  
  35. #wait for volume to become detached
  36. #while [ "$volume_state" != "detached" ];do
  37. # sleep 5
  38. # echo "Getting volume status"
  39. # volume_state=`$rsc_cmd show --x1 .state $volume_attachement_href`
  40. #done
  41.  
  42. #destory the volume
  43. $rsc_cmd destroy $volume_href
  44.  
  45. echo "Volume $volume_name detached and destroyed."
  46.  
  47. exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement