How-to use the Rackspace Cloud UK API

Rackspace just released the public beta for the UK version of Rackspace Cloud. The UK Rackspace Cloud doesn’t have the same auth server as the US Cloud so there is a few change you need to do to support the UK Rackspace Cloud. This is the same way Amazon has different zone for EC2 we have now different geographical zone between the US and now the UK.

If you access directly, you just need to adjust the Auth URL in your code to go to :

https://lon.auth.api.rackspacecloud.com

instead of :
https://auth.api.rackspacecloud.com

The language binding provided by Rackspace has all been updated and available from github :

For Python CloudFiles :

 cnx = cloudfiles.Connection(api_username, api_key, authurl="https://lon.auth.api.rackspacecloud.com/v1.0)

For Python CloudServers :

    cloudservers.CloudServers("USERNAME", "API_KEY", auth_url="https://lon.auth.api.rackspacecloud.com/v1.0")

For Ruby CloudFiles :

require 'cloudfiles'

  # Log into the Cloud Files system
cf = CloudFiles::Connection.new(
                                :username => "USERNAME",
                                :api_key => "API_KEY",
                                :authurl => "https://lon.auth.api.rackspacecloud.com/v1.0"
                                )

For C# CloudFiles :

UserCredentials userCreds = new UserCredentials(new Uri("https://lon.auth.api.rackspacecloud.com/v1.0"), username, api_key, null, null);
Connection connection = new com.mosso.cloudfiles.Connection(userCreds);

For Java CloudFIles add a cloudfiles.properties file in your classpath with this content :

username=username
password=apikey
auth_url=https://lon.auth.api.rackspacecloud.com/v1.0
connection_timeout=15000

and you would be able to access it like this without any argument to the constructor :

FilesClient client = new FilesClient();
client.login();

For non rackspace binding I have sent a patch for Apache libcloud :

https://issues.apache.org/jira/browse/LIBCLOUD-66

which when integrated would allow to do something like this :

for jclouds you can just pass the auth server like this for cloudfiles :

and like this for cloudservers :

for Ruby Fog :

require 'rubygems'
require 'fog'

rackspace = Fog::Rackspace::Storage.new(
  :rackspace_api_key => "",
  :rackspace_username => "",
  :rackspace_auth_url => "lon.auth.api.rackspacecloud.com"
)
  • Yoav Aner

    I tried using the latest python-cloudservers from github (or installing via pip), and it still doesn’t seem to support rackspace cloudservers in the UK.

    I’m getting this error:

    __init__() got an unexpected keyword argument ‘auth_url’

    python-novatools however seems to include this support. So I ended up using:

    pip install python-novatools

    Is this the right thing to do??

    • http://www.chmouel.com/ chmouel

      Hi Yoav,

      Unfortunately the maintainer of python-cloudservers didn’t integrate my patch to get an auth_server argument, the python-novatools should support it properly and that’s indeed the right thing to do. In the future python-novatools will be actively maintained…

      • Yoav Aner

        Thanks Chmouel,

        python-novatools seems to work great. Not sure I understand why your patch wasn’t added though. It seems like a small but crucial change to many users. At least there is a solution out there. Keep up the good work!

        Yoav

  • Alec

    I am doing this in C#. After I added the two dlls into references and run the code, it stopped at the line:

    Connection connection = new com.mosso.cloudfiles.Connection(userCreds);

    and complains security exception.

    [SecurityException: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
    System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
    System.Security.CodeAccessPermission.Demand() +61
    System.AppDomainSetup.VerifyDir(String dir, Boolean normalize) +93
    com.mosso.cloudfiles.utils.Log.initialize() in c:Usersjmeridthcodecsharp-cloudfilescom.mosso.cloudfilesUtilsLog.cs:280
    com.mosso.cloudfiles.domain.request.GenerateRequestByType..ctor() in c:Usersjmeridthcodecsharp-cloudfilescom.mosso.cloudfilesDomainGenerateRequestByType.cs:15
    com.mosso.cloudfiles.Connection..ctor(UserCredentials userCreds, Boolean useServiceNet) in c:Usersjmeridthcodecsharp-cloudfilescom.mosso.cloudfilesConnection.cs:81
    com.mosso.cloudfiles.Connection..ctor(UserCredentials userCreds) in c:Usersjmeridthcodecsharp-cloudfilescom.mosso.cloudfilesConnection.cs:73
    XploreCore.DefaultMaster.btnUpload_onClick(Object sender, EventArgs e) in D:2010 Projectspek001pek001Default.Master.cs:168

    Do you know why?….

  • Anonymous

    I am far to be an expert in C# but it seems to be a permission error where writing the log file where your use don’t have access.

  • Robert

    Here’s a working example of how to integrate with the Rackspace  API

    http://www.robertsindall.co.uk/blog/rackspace-cloud-servers-api-using-c-sharp/

  • http://www.netterland.com Social Networking Community

    superb post! thanks!

  • Bernard Banta

    You forgot one big thing.  The :authurl should :auth_url. It is working for me now. Thanks

  • http://www.facebook.com/christopher.odell.125 Christopher O’Dell

    Nice tutorial. I have written a PHP Script and Blog post at http://foxdellfolio.com/php-script-to-rack-up-the-space-for-the-next-generation/ to provide easy API access using PHP. The script provides methods for server creation, getting the details for a server and for server deletion.