Skip to content

Commit

Permalink
Use cloudauthz to get cloud credentials in cloud download manager.
Browse files Browse the repository at this point in the history
  • Loading branch information
VJalili committed Sep 25, 2018
1 parent 5c35813 commit 8198b33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions lib/galaxy/managers/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def upload(self, trans, history_id, bucket_name, objects, authz_id, input_args=N

return datasets

def download(self, trans, history_id, provider, bucket_name, credentials, dataset_ids=None, overwrite_existing=False):
def download(self, trans, history_id, provider, bucket_name, authz_id, dataset_ids=None, overwrite_existing=False):
"""
Implements the logic of downloading dataset(s) from a given history to a given cloud-based storage
(e.g., Amazon S3).
Expand All @@ -296,10 +296,10 @@ def download(self, trans, history_id, provider, bucket_name, credentials, datase
:param bucket_name: the name of a bucket to which data should be downloaded (e.g., a bucket
name on AWS S3).
:type credentials: dict
:param credentials: a dictionary containing all the credentials required to authenticated
to the specified provider (e.g., {"secret_key": YOUR_AWS_SECRET_TOKEN,
"access_key": YOUR_AWS_ACCESS_TOKEN}).
:type authz_id: int
:param authz_id: the ID of CloudAuthz to be used for authorizing access to the resource provider.
You may get a list of the defined authorizations via `/api/cloud/authz`. Also,
you can use `/api/cloud/authz/create` to define a new authorization.
:type dataset_ids: set
:param dataset_ids: [Optional] The list of (decoded) dataset ID(s) belonging to the given
Expand All @@ -319,6 +319,9 @@ def download(self, trans, history_id, provider, bucket_name, credentials, datase
"""
if CloudProviderFactory is None:
raise Exception(NO_CLOUDBRIDGE_ERROR_MESSAGE)

cloudauthz = trans.app.authnz_manager.try_get_authz_config(trans, authz_id)
credentials = trans.app.authnz_manager.get_cloud_access_credentials(trans, cloudauthz)
connection = self._configure_provider(provider, credentials)

bucket = connection.storage.buckets.get(bucket_name)
Expand Down
2 changes: 1 addition & 1 deletion lib/galaxy/webapps/galaxy/api/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def download(self, trans, payload, **kwargs):
history_id=history_id,
provider=provider,
bucket=bucket,
credentials=credentials,
authz_id=encoded_authz_id,
dataset_ids=dataset_ids,
overwrite_existing=payload.get("overwrite_existing", False))
return {'downloaded_dataset': downloaded,
Expand Down

0 comments on commit 8198b33

Please sign in to comment.