Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass additional kwargs to libcloud #44

Open
gassc opened this issue Jan 4, 2021 · 1 comment
Open

Pass additional kwargs to libcloud #44

gassc opened this issue Jan 4, 2021 · 1 comment

Comments

@gassc
Copy link

gassc commented Jan 4, 2021

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.

@c-w
Copy link
Collaborator

c-w commented Jan 4, 2021

Thanks for reaching out. The kwargs approach that you mentioned sounds great to me. Would be happy to accept a pull request for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants