Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash -ex
- if [ "$RS_REBOOT" == "true" ];then
- echo "rebooting, skipping script."
- exit 0
- fi
- rsc_cmd='sudo /home/rightlink/rsc --rl10 cm15'
- rsc_json_cmd="/home/rightlink/rsc"
- #get the current instance values
- instance=`$rsc_cmd index_instance_session /api/sessions/instance`
- instance_href=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("self")).href' json`
- cloud_id=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("self")).href' json | cut -d '/' -f 4`
- datacenter_href=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("datacenter")).href' json`
- volume_attachments_href=`echo $instance | $rsc_json_cmd --x1 ':has(.rel:val("volume_attachments")).href' json`
- #create the new volume
- echo "Searching volume_attachment"
- #get volume from instance
- volume_attachments=`$rsc_cmd index $volume_attachments_href`
- #get volume_attachment
- volume_attachment_href=`echo $volume_attachments | $rsc_json_cmd --x1 ':has(.rel:val("self")).href' json `
- volume_href=`echo $volume_attachments | $rsc_json_cmd --x1 ':has(.rel:val("volume")).href' json`
- # remove volume from instance
- $rsc_cmd destroy $volume_attachment_href
- #volume_state=`$rsc_cmd show --x1 .state $volume_attachement_href`
- #wait for volume to become detached
- #while [ "$volume_state" != "detached" ];do
- # sleep 5
- # echo "Getting volume status"
- # volume_state=`$rsc_cmd show --x1 .state $volume_attachement_href`
- #done
- #destory the volume
- $rsc_cmd destroy $volume_href
- echo "Volume $volume_name detached and destroyed."
- exit 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement