The CloudFiles API uses a different Auth Host for accounts created via the UK service:

• US-based accounts authenticate through https://auth.api.rackspacecloud.com/v1.0.
• UK-based accounts authenticate through https://lon.auth.api.rackspacecloud.com/v1.0.

This is accommodated in the php-cloudfiles library, but there is no motion to use the alternate UK host within the Cloud Files module.

I've modified my local copy to offer a select box on the config page, and then use the appropriate host (as defined by cloudfiles.php's constants) whenever CF_Authentication is invoked. At first pass it seems to function as expected, it's successfully authenticated my username and API key. As all other variables are derived from these auth calls I would expect the rest of the module will continue to behave itself, but will let you know.

Find attached patches to apply this to cloud_files.module and rackspacecloudfiles_streams.inc.

Comments

magicmyth’s picture

StatusFileSize
new4.47 KB

Ah snap. I just wrote a patch for this feature myself.

My approach might be a bit more abstract and makes it dead simple to add support for any other authentication URLs Rackspace might add in the future. Another view is it might be unnecessarily abstract.

My patch is based against the latest git 7.x-1.0 branch.

Nice work btw kingandy (great minds think alike). May the best patch win ;) (Or neither as the module author is welcome to do it his own way).

kingandy’s picture

Well, I forgot to patch the .install file to remove my new variable, so you're already one up on me there...

My instinct was very much to use cloudfiles.php's constants, in case those URLs change arbitrarily down the line. Though of course the constants could vanish at any moment too, and they're really not likely to change the URLs as they're in the documentation and thousands of sites around the world will be relying on them, so it's probably not much of a risk.

magicmyth’s picture

I considered using the URL constants in _cloud_files_auth_urls() but I don't really know anything about the libraries module so I was not sure if cloudspace.php would have been included when the function was defined but if it is I agree it makes sense to use them.

Glad to see others are interested in getting Drupal running well with Rackspace's services.

A weird thing is that I had a look at the issue cue yesterday to see if anyone had mentioned this issue but none was there but I just looked at the date of the post and its a couple days ago :-/

kingandy’s picture

I'm pretty sure libraries_load() loads the constants, and that gets called at the start of cloud_files_admin_validate(), so I should be okay using them there. I could have sworn I checked it was called before CF_Authentication in rackspacecloudfiles_streams.inc too, but looking again it doesn't seem to be the case - presumably because of the way Drupal 7 caches class locations, it remembers that the CF_Authentication class lives in cloudfiles.php and loads it whenever you make a new one. Unfortunately this probably doesn't load the constants before it's called, as it's not psychic ... a swift call to libraries_load should fix that though.

That said, I'm honestly not sure whether it's better practise to use the URLs or the constants. The URLs are published in the API document, so are technically (theoretically, marginally) less likely to change ... but the constants are there, crying out to be used...

Anonymous’s picture

What about letting users enter their auth URL manually in the admin form? Does that make sense? If the URLs change, people can adapt. I also need this working.

mr.moses’s picture

Status: Active » Needs review

Thanks for your patches and suggestions. I used a little bit of everything.

I used the constants in the _cloud_files_auth_urls AND added an "Other" option with a text field on the admin form.

I don't have a UK account, so I haven't fully tested this, and I started getting an error but I think it was related to #1338794: InvalidResponseException (401) in CF_Connection->get_container()

Please test a UK account and let me know.

I also have updated the libraries path (#1341190: update Library path) to match whats used in http://drupal.org/project/backup_migrate_cloudfiles, so don't forget to rename 'rackspacecloud' folder to just 'rackspace'

Commited in http://drupalcode.org/project/cloud_files.git/commit/2c87a27

Thanks again!

mr.moses’s picture

Fixed the error I was getting. I used the cdn_domain instead of the auth_url variabl, whoops.

Commited in http://drupalcode.org/project/cloud_files.git/commit/c1bfb83

Still need a verification on a UK account.

magicmyth’s picture

Thanks Mr Moses. I've only done a quick test with two images attached to a node with the image field set to rcf:// on my UK cloud files and it worked just fine except the image thumbnails were not generated initially but that will be a separate issue.

I also removed one image on the same node and confirmed that it was indeed gone in my cloud files control panel.

Once I've got some free time I'll do some more thorough testing but I think its safe to say it works equally as well on the UK servers as the US.

I've noticed a potential minor issue though. If the library failed to load you would get a notice error as $cf_urls in cloud_files_admin() would be NULL since _cloud_files_auth_urls() will not return anything. So _cloud_files_auth_urls() should return and empty array after the form_set_error.

k0nG’s picture

I've just downloaded the latest version of this and its working nicely with my UK Rackspace Cloud files account.

No issues to report as yet.

Thanks for the patch.

mr.moses’s picture

Status: Needs review » Reviewed & tested by the community
mr.moses’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.