You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by ma...@apache.org on 2020/09/17 13:43:53 UTC
[airavata-django-portal-sdk] 03/05: AIRAVATA-3346: AIRAVATA-3346
Prevent accidentally using local data store API when configured for remote
data store API
This is an automated email from the ASF dual-hosted git repository.
machristie pushed a commit to branch AIRAVATA-3346-implement-remote-fs-abstraction-of-user-storage
in repository https://gitbox.apache.org/repos/asf/airavata-django-portal-sdk.git
commit a705626931a09872291a10fe6e1a471c274f451b
Author: Marcus Christie <ma...@iu.edu>
AuthorDate: Wed Sep 16 14:23:07 2020 -0400
AIRAVATA-3346: AIRAVATA-3346 Prevent accidentally using local data store API when configured for remote data store API
---
airavata_django_portal_sdk/user_storage.py | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/airavata_django_portal_sdk/user_storage.py b/airavata_django_portal_sdk/user_storage.py
index 3d66764..2a48bb8 100644
--- a/airavata_django_portal_sdk/user_storage.py
+++ b/airavata_django_portal_sdk/user_storage.py
@@ -118,6 +118,16 @@ def copy_input_file(request, data_product):
def is_input_file(request, data_product):
+ if getattr(settings, 'GATEWAY_DATA_STORE_REMOTE_API', None) is not None:
+ headers = {
+ 'Authorization': f'Bearer {request.authz_token.accessToken}'}
+ r = requests.get(
+ f'{settings.GATEWAY_DATA_STORE_REMOTE_API}/data-products/',
+ headers=headers,
+ params={'product-uri': data_product.productUri})
+ r.raise_for_status()
+ data = r.json()
+ return data['isInputFileUpload']
# Check if file is one of user's files and in TMP_INPUT_FILE_UPLOAD_DIR
path = _get_replica_filepath(data_product)
if _Datastore().exists(request.user.username, path):
@@ -555,6 +565,15 @@ class _Datastore:
"""Internal datastore abstraction."""
def __init__(self, directory=None):
+ if getattr(
+ settings,
+ 'GATEWAY_DATA_STORE_REMOTE_API',
+ None) is not None:
+ raise Exception(
+ f"This Django portal instance is configured to connect to a "
+ f"remote data store via API (settings.GATEWAY_DATA_STORE_REMOTE_API="
+ f"{settings.GATEWAY_DATA_STORE_REMOTE_API}). This local "
+ f"Datastore instance is not available in remote data store mode.")
if directory:
self.directory = directory
else: