Rackspace API/Cloud Block Storage

From Christoph's Personal Wiki
Revision as of 16:29, 24 October 2014 by Christoph (Talk | contribs)

Jump to: navigation, search

Boot from volume (BfV)

In this section, I will show you how to boot from a Cloud Block Storage (CBS) volume entirely using simple API calls (via cURL).

The examples in this article will do the following:

  • Create a SATA CBS volume in DFW; and
  • Boot a 1GB Performance-1 Cloud Server from that CBS volume in DFW;
  • Step #0: Setup your environment variables:
$ ACCOUNT=012345
$ USERNAME=myraxusername
$ API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
$ REGION=dfw
$ CBS_ENDPOINT=https://${REGION}.blockstorage.api.rackspacecloud.com/v1/${ACCOUNT}
$ SERVERS_ENDPOINT= https://${REGION}.servers.api.rackspacecloud.com/v2/${ACCOUNT}
$ IMAGE_ID="68d5cc64-cb68-4275-9ede-9b062f7be070" # CentOS 6.5
$ FLAVOR="performance1-1"
  • Step #1: Create a CBS volume in DFW:
$ CBS_VOLUME_NAME="test-bfb-sata"
$ CBS_VOLUME_TYPE="SATA"  # or, "SSD"
$ CBS_VOLUME_SIZE=75 # i.e., 75GB, the smallest possible volume
$ curl -i -XPOST -H "X-Auth-Token: $TOKEN" \
       -H "Content-Type: application/json" -H "Accept: application/json" \
       "$CBS_ENDPOINT/volumes" \
       -d "{\"volume\": {\"display_name\": \"$CBS_VOLUME_NAME\", \"imageRef\": \"$IMAGE_ID\", \
            \"availability_zone\": null, \"volume_type\": \"$CBS_VOLUME_TYPE\", \
            \"display_description\": null, \"snapshot_id\": null, \"size\": $CBS_VOLUME_SIZE}}"

Watch the status of your CBS volume build until it goes from status "creating" to "active":

$ CBS_VOLUME_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee # From output of last command
$ curl -i -H "X-Auth-Token: $TOKEN" \
       -H "Content-Type: application/json" -H "Accept: application/json" \
       "$CBS_ENDPOINT/volumes/$CBS_VOLUME_ID"
  • Step #2: Boot a Cloud Server (in DFW) from the above CBS volume:
$ SERVER_ID=aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee # From output of last command
$ curl -i -H "X-Auth-Token: $TOKEN" \
       -H "Content-Type: application/json" -X POST -H "Accept: application/json" \
       "$SERVERS_ENDPOINT/v2/$ACCOUNT/servers/$SERVER_ID"

That's it! You now have a Cloud Server that has been booted from a CBS volume.

Links