Lately I have been looking at some cloud options for my more critical services, in this I have investigated Zerigo, Route 53, and Rackspace Cloud DNS. Currently I have been focused on Rackspace DNS, since it is still free at this point, and frankly I’d rather not spend money on anything until I understand exactly how it works. I have no experience with using “api” interactions and as such it has been a real struggle for me to get my head around sending the correct data to the infrastructure and getting the correct responses.
Now obviously before we do this you need to sign up with Rackspace and get your API Key from your Account Profile.
The first step is to install curl. For Debian derivatives you can install using apt-get, for Fedora derivatives you can install using yum.
# apt-get install curl
# yum install curl
Now that we have the tool needed to send the requests, the next step is to authenticate with the Rackspace cloud. This part was a bit tricky as you have to manipulate curl to send a specific header to the server in order to authenticate yourself. To do this we will need your Rackspace cloud username, and the API Key associated with your account.
# curl -D - -H "X-Auth-Key: <your api key - long hex string>" -H "X-Auth-User: <your rackspace cloud username>" https://auth.api.rackspacecloud.com/v1.0 HTTP/1.1 204 No Content Server: Apache/2.2.13 (Red Hat) vary: X-Auth-Token,X-Auth-Key,X-Storage-User,X-Storage-Pass X-Storage-Url: https://storage101.ord1.clouddrive.com/v1/MossoCloudFS_<string removed> Cache-Control: s-maxage=86400 Content-Type: application/octet-stream Date: Sun, 30 Oct 2011 18:09:02 GMT X-Auth-Token: <string removed> X-Storage-Token: <string removed> X-Server-Management-Url: https://servers.api.rackspacecloud.com/v1.0/<string removed> Connection: Keep-Alive X-CDN-Management-Url: https://cdn2.clouddrive.com/v1/MossoCloudFS_<string removed> Content-Length: 0
Now above is a successful authentication, which is denoted by the HTTP code. In our subsequent calls we will need to reference the X-Auth-Token to reference our authentication and the user number from the X-Server-Management string. Also notice above, I removed any string that could identify my account, I am not sure of the security implications of exposing some of the more obscure ones (like X-Server-Management-Url) but I’d rather not risk it.
# curl -D - -H "X-Auth-Token: <your x-auth-token here>" -H "Accept: application/xml" https://dns.api.rackspacecloud.com/v1.0/<your user number here>/limits HTTP/1.1 200 OK X-API-VERSION: 1.0.12 Content-Type: application/xml Date: Sun, 30 Oct 2011 21:54:24 GMT Content-Length: 666 Server: Jetty(7.3.1.v20110307) <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Limits xmlns="http://docs.openstack.org/common/api/v1.0"><rates><rate uri="*/status/*" regex=".*/v\d+\.\d+/(\d+/status).*"><limit verb="GET" value="5" remaining="0" unit="SECOND"/></rate><rate uri="*/domains*" regex=".*/v\d+\.\d+/(\d+/domains).*"><limit verb="GET" value="100" remaining="0" unit="MINUTE"/><limit verb="POST" value="25" remaining="0" unit="MINUTE"/><limit verb="PUT" value="50" remaining="0" unit="MINUTE"/><limit verb="DELETE" value="50" remaining="0" unit="MINUTE"/></rate></rates><absolute><limit name="domains" value="500"/><limit name="records per domain" value="500"/></absolute></Limits>
Above you will see a request to enumerate the limits on your account, this will indicate that you are in fact successfully authenticated with the Rackspace cloud.
# curl -D - -H "X-Auth-Token: <your x-auth-token here>" -H "Accept: application/xml" https://dns.api.rackspacecloud.com/v1.0/<your user number here>/domains HTTP/1.1 200 OK X-API-VERSION: 1.0.12 Content-Type: application/xml Date: Sun, 30 Oct 2011 21:59:27 GMT Content-Length: 224 Server: Jetty(7.3.1.v20110307) <?xml version="1.0" encoding="UTF-8" standalone="yes"?><domains xmlns="http://docs.rackspacecloud.com/dns/api/v1.0" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="http://docs.rackspacecloud.com/dns/api/management/v1.0"/>
Now obviously I have not created any zones, so this won’t really show us anything of use at this point. In my next article I will go over how to create our first zone on the Rackspace cloud DNS.