Difference between revisions of "Rackspace API/Cloud Block Storage"

From Christoph's Personal Wiki
Jump to: navigation, search
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
<div style="margin: 10px; padding: 5px; border: 2px solid red; text-align: center">'''NOTE:''' This article was written in 2014 and is no longer maintained.</div>
 +
 
This article will show various examples and techniques for working with Rackspace's [http://www.rackspace.com/cloud/block-storage/ Cloud Cloud Block Storage] (CBS) RESTful API.
 
This article will show various examples and techniques for working with Rackspace's [http://www.rackspace.com/cloud/block-storage/ Cloud Cloud Block Storage] (CBS) RESTful API.
  
 
==HOWTO: boot from volume (BfV)==
 
==HOWTO: boot from volume (BfV)==
In this section, I will show you how to boot from a [http://www.rackspace.com/cloud/block-storage/ Cloud Block Storage] (CBS) volume entirely using simple [http://docs.rackspace.com/ API calls] (via [[curl|cURL]]).
+
In this section, I will show you how to boot from a [http://www.rackspace.com/cloud/block-storage/ Cloud Block Storage] (CBS) volume entirely using simple [http://docs.rackspace.com/ API calls] (via [[curl|cURL]]). This process is also known as "Boot from Volume" (BfV).
  
 
The examples in this article will do the following:
 
The examples in this article will do the following:
Line 19: Line 21:
 
  $ IMAGE_ID="68d5cc64-cb68-4275-9ede-9b062f7be070" # CentOS 6.5
 
  $ IMAGE_ID="68d5cc64-cb68-4275-9ede-9b062f7be070" # CentOS 6.5
 
  $ FLAVOR="performance1-1"
 
  $ FLAVOR="performance1-1"
  $ TOKEN=`curl -s -XPOST <nowiki>https://identity.api.rackspacecloud.com/v2.0/tokens</nowiki> \
+
  $ TOKEN=`curl -sXPOST <nowiki>https://identity.api.rackspacecloud.com/v2.0/tokens</nowiki> \
 
         -d'{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$USERNAME'","apiKey":"'$API_KEY'"}}}' \
 
         -d'{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$USERNAME'","apiKey":"'$API_KEY'"}}}' \
 
         -H"Content-type:application/json" | \
 
         -H"Content-type:application/json" | \
Line 26: Line 28:
 
* Step #1: Create a CBS volume in DFW:
 
* Step #1: Create a CBS volume in DFW:
  
  $ CBS_VOLUME_NAME="test-bfb-sata"
+
  $ CBS_VOLUME_NAME="test-bfv-sata"
 
  $ CBS_VOLUME_TYPE="SATA"  # or, "SSD"
 
  $ CBS_VOLUME_TYPE="SATA"  # or, "SSD"
 
  $ CBS_VOLUME_SIZE=75 # i.e., 75GB, the smallest possible volume
 
  $ CBS_VOLUME_SIZE=75 # i.e., 75GB, the smallest possible volume
  $ curl -i -XPOST -H "X-Auth-Token: $TOKEN" \
+
  $ curl -iXPOST -H "X-Auth-Token: $TOKEN" \
 
         -H "Content-Type: application/json" -H "Accept: application/json" \
 
         -H "Content-Type: application/json" -H "Accept: application/json" \
 
         "$CBS_ENDPOINT/volumes" \
 
         "$CBS_ENDPOINT/volumes" \
Line 56: Line 58:
 
* [http://www.rackspace.com/blog/boot-rackspace-cloud-servers-from-a-cloud-block-storage-volume/ Boot Rackspace Cloud Servers From A Cloud Block Storage Volume]
 
* [http://www.rackspace.com/blog/boot-rackspace-cloud-servers-from-a-cloud-block-storage-volume/ Boot Rackspace Cloud Servers From A Cloud Block Storage Volume]
 
* [http://www.rackspace.com/knowledge_center/article/boot-a-server-from-a-cloud-block-storage-volume Boot a server from a Cloud Block Storage volume]
 
* [http://www.rackspace.com/knowledge_center/article/boot-a-server-from-a-cloud-block-storage-volume Boot a server from a Cloud Block Storage volume]
 +
 +
==See also==
 +
* [[Rackspace API]]
  
 
[[Category:Rackspace]]
 
[[Category:Rackspace]]

Latest revision as of 17:28, 19 September 2019

NOTE: This article was written in 2014 and is no longer maintained.

This article will show various examples and techniques for working with Rackspace's Cloud Cloud Block Storage (CBS) RESTful API.

HOWTO: 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). This process is also known as "Boot from Volume" (BfV).

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"
$ TOKEN=`curl -sXPOST https://identity.api.rackspacecloud.com/v2.0/tokens \
        -d'{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"'$USERNAME'","apiKey":"'$API_KEY'"}}}' \
        -H"Content-type:application/json" | \
        python -c 'import sys,json;data=json.loads(sys.stdin.read());print data["access"]["token"]["id"]'`
  • Step #1: Create a CBS volume in DFW:
$ CBS_VOLUME_NAME="test-bfv-sata"
$ CBS_VOLUME_TYPE="SATA"  # or, "SSD"
$ CBS_VOLUME_SIZE=75 # i.e., 75GB, the smallest possible volume
$ curl -iXPOST -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

See also