In my previous post “Using Curl to Access Rackspace Cloud DNS” we documented the basics of authenticating with the Rackspace Cloud for use with the Beta DNS service they offer, as well as doing basic queries against this service. Today we are going to focus on creating our first domain, which no doubt will offer challenges for us, since it will require the uploading of information to the Cloud service using the API. If you are not familiar with how to authenticate with the Rackspace Cloud please review my previous post.
Create A Zone
In order to create a domain, we need to build that domain in XML. Here I am using a test domain I use, which really has no complexity what-so-ever, I will give an example of a much more real world example in a later article.
# cat itfromallangles-com.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <domains xmlns:ns2="http://docs.rackspacecloud.com/dns/api/management/v1.0" xmlns="http://docs.rackspacecloud.com/dns/api/v1.0" xmlns:ns3="http://www.w3.org/2005/Atom"> <domain name="itfromallangles.com" ttl="3600" emailAddress="<your email here>"> <recordsList> <record type="NS" name="itfromallangles.com" data="dns1.stabletransit.com." ttl="3600"/> <record type="NS" name="itfromallangles.com" data="dns2.stabletransit.com." ttl="3600"/> </recordsList> </domain> </domains>
Now once we have authenticated to the Rackspace Cloud, then we can run the following command against the Rackspace Cloud to create the appropriate domain entries.
# curl -X POST -D - -H "X-Auth-Token: <your x-auth-token here>" -H "Content-Type: application/xml" -H "Accept: application/xml" -T itfromallangles-com.xml https://dns.api.rackspacecloud.com/v1.0/<your user number here>/domains
Now if you have done this correctly, then you will receive a HTTP/1.1 100 Continue followed by a HTTP/1.1 202 Accepted followed by some XML which will give you a “callbackUrl” this will allow you to check status on your request. In the course of doing this I found quite a few problems, some obvious, others not so obvious.
- The API doesn’t accept @rackspace.com email addresses when creating a domain, I tried to use the example.com XML definition from the developer guide and this did not work. Keep this in mind when you are doing your initial testing.
- The API requires that you use the fully qualified domain name, including the trailing period, when referencing objects out of the zone in question. This is kind of a no duh – however in the docs there are no trailing period on the NS records, which was making the whole zone barf. A big pat on the back to “Jordan C” at Rackspace on the Chat Support for spending a good chunk of time trying to figure out what was breaking it.
- The API doesn’t accept CNAME records which reference a different zone, this behavior might be different if the different zone were also hosted with Rackspace. This should work with the trailing period, but it does not.
Delete A Zone
# curl -X DELETE -D - -H "X-Auth-Token: <your x-auth-token here>" -H "Content-Type: application/xml" -H "Accept: application/xml" https://dns.api.rackspacecloud.com/v1.0/<your user number here>/domains/<your domain id here>
This really behaves pretty much the same as creating a zone did, except I didn’t run into any errors with this, you will need to domain id, which can be grabbed by listing all the zones.
List All Zones
# 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
Check Status of A Job
# curl -D - -H "X-Auth-Token: <your x-auth-token here>" -H "Accept: application/xml" <your callbackurl here>
When you check the status, you are looking for the content of the <status></status> tag. This will indicate what is going on in the cloud, if your job is RUNNING, COMPLETED, or FAILED (there might be other values as well – these are just the ones I ran into).
In the next article in the series I will document how to work with individual resource records.