Skip to content

Pass additional kwargs to libcloud #44

@gassc

Description

@gassc

Hi! I'm using the apache-libcloud datastore and looking to access an S3 bucket that isn't in the AWS's us-east-1 region.

After setting up django-cloud-browser, I can see the bucket listed! (So easy to set up--thank you.) When I click the link to look in the bucket, Django throws an error:

<LibcloudError in <class 'libcloud.storage.drivers.s3.S3StorageDriver'> 'This bucket is located in a different region. Please use the correct driver. Bucket region "us-east-2", used region "us-east-1".'>

That's obviously an apache-libcloud error--it has a default region to fallback on. In looking up that error I found this:

apache/libcloud#1379 (comment)

...and it looks like the fix is to explicitly pass a region kwarg to get_driver constructor. Make sense.

I read through the django-cloud-browser documentation and source but it doesn't look like there is way to pass additional kwargs through to here:

via here:

conn_fn = lambda: ApacheLibcloudConnection(

  1. My first question is--am I missing an obvious way to set the region keyword in django-cloud-browser so it gets picked up in apached-libcloud?

  2. Second question is, assuming I'm not missing something...would it make sense to have a settings.py variable that could contain arbitrary kwargs that can be passed through to libcloud? Something like:

CLOUD_BROWSER_APACHE_LIBCLOUD_KWARGS = {
  'region': 'us-east-2'
}

Or, since region seems to be a kwarg found for most (all?) classes in libcloud.storage.drivers, would it make sense to follow the pattern in 77e8f03 and add a CLOUD_BROWSER_APACHE_LIBCLOUD_REGION variable?

I'd be happy to work up a PR doing this if the approach make sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions