Search Site
Topics
RSS Feed
« LegalCloud.net Update: Enterprise Cloud Computing for Law Firms | Main | Sphinx Install: Ubuntu 9.04 Rackspace Cloud Server »
Sunday
Aug022009

Using Curl to Access the Rackspace Cloud API

I've been playing around w/ the Rackspace Cloud API quite a bit. Then, today I got an email from a reader of this blog asking me how it works more or less. So, I thought I'd post a couple of the examples I've been using. In the absense of a fancy GUI to control cloud servers I've simply been using Curl and writing little shell scripts to get the job done.

Authentication Request

curl -D - \
  -H "X-Auth-Key: youneedtoputyourownauthkeyhere" \
  -H "X-Auth-User: acctusr" \
  https://auth.api.rackspacecloud.com/v1.0

Authentication Response

HTTP/1.1 204 No Content

Date: Sat, 25 Jul 2009 15:44:07 GMT
Server: Apache/2.2.3 (Mosso Engineering)
X-Storage-Token: 8gc00ld-a77r-6548-eq58-5nb5hsrv9876
X-Storage-Url: https://storage.clouddrive.com/v1/MossoCloudFS_8gaserd-65q3-5dfas-8888-c66e9987r953
X-Auth-Token: aq9beanS-d75c-9135-ed78-4bs3chse9135
X-CDN-Management-Url: https://cdn.clouddrive.com/v1/MossoCloudFS_d96e4c99-85ej-2pol-7777-v33e9135e669
X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/928875
Content-Length: 0
Connection: close
Content-Type: application/octet-stream

These aren't real tokens so you can't use them yourself of course. You need to get your own, which is exactly the point. Once you have successfully received your own response then you can move on to actually using other API calls to do things with the API. Here is a cloud servers API example using curl again.

Listing Your Account Limits

curl -D - \
  -H "X-Auth-Token: aq9beanS-d75c-9135-ed78-4bs3chse9135" \
  https://servers.api.rackspacecloud.com/v1.0/928875/limits

That will output something that looks like this:

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
vary: Accept, Accept-Encoding
Set-Cookie: JSESSIONID=D6DBBE0BE05C4559BC71E6F851501575; Path=/v1.0
Cache-Control: s-maxage=1800
Last-Modified: Sat, 25 Jul 2009 15:51:26 GMT
Content-Type: application/json
Content-Length: 657
Date: Sat, 25 Jul 2009 15:51:26 GMT
X-Varnish: 1753447558
Age: 0
Via: 1.1 varnish
Connection: keep-alive

{"limits":{"absolute":{"maxTotalRAMSize":51200,"maxIPGroupMembers":25,"maxIPGroups":25},"rate":[{"value":25,"unit":"DAY","verb":"POST","remaining":25,"URI":"\/servers*","resetTime":1248537086,"regex":"^\/servers"},{"value":10,"unit":"MINUTE","verb":"POST","remaining":10,"URI":"*","resetTime":1248537086,"regex":".*"},{"value":600,"unit":"MINUTE","verb":"DELETE","remaining":600,"URI":"*","resetTime":1248537086,"regex":".*"},{"value":3,"unit":"MINUTE","verb":"GET","remaining":3,"URI":"*changes-since*","resetTime":1248537086,"regex":"changes-since"},{"value":10,"unit":"MINUTE","verb":"PUT","remaining":10,"URI":"*","resetTime":1248537086,"regex":".*"}]}}

Here is a very simple bash shell script you could use for the Authentication example above:

#!/bin/sh

curl -D - \
  -H "X-Auth-Key: 5115a48a9ca852bc266ea3e7bc8805e7" \
  -H "X-Auth-User: nscaled" \
  https://auth.api.rackspacecloud.com/v1.0

I know that there are at least a couple of companies with growing support via their cloud management platforms quickly adding Rackspace Cloud functionalities.  So, while I have to hack around with curl today I suspect that in short order it might get easier.

Cheer!

Kent

EmailEmail Article to Friend

Reader Comments (1)

Do you know how to use cURL to do a soft REBOOT on these servers?

I can't fathom the document! :-)

March 31, 2010 | Unregistered CommenterStuart Halliday
Member Account Required
You must have a member account on this website in order to post comments. Log in to your account to enable posting.