Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Open Subsurface Data Universe Software
Platform
Domain Data Mgmt Services
Wellbore
Lib
Wellbore-cloud
Wellbore-aws-lib
Commits
a0e85010
Commit
a0e85010
authored
Oct 05, 2021
by
Spencer Sutton
Browse files
Adding call to partition service for multi tenant
parent
e12a936b
Pipeline
#70086
passed with stage
in 49 seconds
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
osdu_aws/storage/storage_aws.py
View file @
a0e85010
...
...
@@ -22,6 +22,10 @@ from osdu.core.api.storage.tenant import Tenant
import
boto3
from
datetime
import
datetime
,
timedelta
,
timezone
from
botocore.exceptions
import
ClientError
,
WaiterError
from
osdu_api.clients.partition_client
import
PartitionClient
from
osdu_api.providers.aws.partition_info_aws
import
PartitionInfoAws
try
:
import
ujson
as
json
except
ImportError
:
...
...
@@ -119,6 +123,10 @@ class AwsStorage(BlobStorageBase):
]}
return
UploadPolicy
def
getTenantId
(
self
,
data_partition_id
:
str
)
->
str
:
partition_client
=
PartitionClient
(
data_partition_id
=
data_partition_id
)
partition_info_aws
=
partition_client
.
get_partition
(
data_partition_id
)
return
partition_info_aws
.
tenant_id
async
def
getCredentials
(
self
,
tenant
:
Tenant
):
if
len
(
self
.
_session_token
)
>
2
and
datetime
.
now
(
timezone
.
utc
)
<
self
.
_timestamp
:
...
...
@@ -126,13 +134,13 @@ class AwsStorage(BlobStorageBase):
""" get credentials to access s3 bucket for tenant's folder """
# all tenants in one bucket(self._bucket_name). Each tenant.bucket_name is in fact, a folder in self._bucket_name
folder
=
tenant
.
bucket_name
data_partition_id
=
tenant
.
data_partition_id
tenant_id
=
self
.
getTenantId
(
tenant
.
data_partition_id
)
ssm
=
boto3
.
client
(
'ssm'
,
region_name
=
self
.
_region
)
if
(
self
.
_bucket_name
==
""
):
# get bucket name from ssm
response
=
ssm
.
get_parameter
(
Name
=
f
'/osdu/
{
self
.
_aws_env
}
/
{
data_partition
_id
}
/wellbore-ddms/WellboreDDMSBucket/name'
,
Name
=
f
'/osdu/
{
self
.
_aws_env
}
/
{
tenant
_id
}
/wellbore-ddms/WellboreDDMSBucket/name'
,
WithDecryption
=
True
)
self
.
_bucket_name
=
response
[
'Parameter'
][
'Value'
]
...
...
requirements.txt
View file @
a0e85010
# for aws provider
boto3
botocore
--extra-index-url https://community.opengroup.org/api/v4/projects/148/packages/pypi/simple
osdu_api
==0.10.1.dev203+a8daba87
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment