duplicity-team team mailing list archive
-
duplicity-team team
-
Mailing list archive
-
Message #02654
[Merge] lp:~bruno-poirier/duplicity/duplicity into lp:duplicity
Bruno Poirier has proposed merging lp:~bruno-poirier/duplicity/duplicity into lp:duplicity.
Requested reviews:
duplicity-team (duplicity-team)
For more details, see:
https://code.launchpad.net/~bruno-poirier/duplicity/duplicity/+merge/243218
This commit allow the use of custom identity modules with pyrax.
An example of such a module is pyrax-identity-hubic, which allows pyrax to connect to OVH's HubiC "cloud storage" service.
This commit also introduce a new way to provide credentials, using pyrax's "credential file" (https://github.com/rackspace/pyrax/blob/master/docs/getting_started.md#authenticating).
This is required for identity modules implementing authentication scheme requiring more complex credendials than a simple username/password couple.
Here is a quick "how to" for using duplicity with pyrax-identity-hubic:
$ export PYRAX_IDENTITY_TYPE=pyrax_identity_hubic.HubicIdentity
$ export PYRAX_CREDENTIAL_FILE=./cred_file
$ duplicity collection-status cf+http://some_volume
--
Your team duplicity-team is requested to review the proposed merge of lp:~bruno-poirier/duplicity/duplicity into lp:duplicity.
=== modified file 'duplicity/backends/_cf_pyrax.py'
--- duplicity/backends/_cf_pyrax.py 2014-04-29 23:49:01 +0000
+++ duplicity/backends/_cf_pyrax.py 2014-11-29 20:31:42 +0000
@@ -37,34 +37,42 @@
raise BackendException("This backend requires the pyrax "
"library available from Rackspace.")
- # Inform Pyrax that we're talking to Rackspace
- # per Jesus Monzon (gsusmonzon)
- pyrax.set_setting("identity_type", "rackspace")
+ pyrax.set_setting("identity_type",
+ os.environ.get("PYRAX_IDENTITY_TYPE", "rackspace"))
conn_kwargs = {}
- if 'CLOUDFILES_USERNAME' not in os.environ:
- raise BackendException('CLOUDFILES_USERNAME environment variable'
- 'not set.')
-
- if 'CLOUDFILES_APIKEY' not in os.environ:
- raise BackendException('CLOUDFILES_APIKEY environment variable not set.')
-
- conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME']
- conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY']
-
if 'CLOUDFILES_REGION' in os.environ:
conn_kwargs['region'] = os.environ['CLOUDFILES_REGION']
+ if 'PYRAX_CREDENTIAL_FILE' in os.environ:
+ try:
+ pyrax.set_credential_file(os.environ['PYRAX_CREDENTIAL_FILE'], **conn_kwargs)
+ except Exception as e:
+ log.FatalError("Connection failed, please check your credential file: %s %s"
+ % (e.__class__.__name__, util.uexc(e)),
+ log.ErrorCode.connection_failed)
+ else:
+ # old style, using creds from environment
+ if 'CLOUDFILES_USERNAME' not in os.environ:
+ raise BackendException('CLOUDFILES_USERNAME environment variable'
+ 'not set.')
+
+ if 'CLOUDFILES_APIKEY' not in os.environ:
+ raise BackendException('CLOUDFILES_APIKEY environment variable not set.')
+
+ conn_kwargs['username'] = os.environ['CLOUDFILES_USERNAME']
+ conn_kwargs['api_key'] = os.environ['CLOUDFILES_APIKEY']
+
+ try:
+ pyrax.set_credentials(**conn_kwargs)
+ except Exception as e:
+ log.FatalError("Connection failed, please check your credentials: %s %s"
+ % (e.__class__.__name__, util.uexc(e)),
+ log.ErrorCode.connection_failed)
+
container = parsed_url.path.lstrip('/')
- try:
- pyrax.set_credentials(**conn_kwargs)
- except Exception as e:
- log.FatalError("Connection failed, please check your credentials: %s %s"
- % (e.__class__.__name__, util.uexc(e)),
- log.ErrorCode.connection_failed)
-
self.client_exc = pyrax.exceptions.ClientException
self.nso_exc = pyrax.exceptions.NoSuchObject
self.container = pyrax.cloudfiles.create_container(container)
Follow ups