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
bef20923
Commit
bef20923
authored
Oct 07, 2021
by
Spencer Sutton
Browse files
Merge branch 'multi-tenant' into 'master'
Multi tenant See merge request
!4
parents
c8f5b8f2
31897e54
Pipeline
#70595
passed with stages
in 1 minute and 21 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
osdu_aws/__init__.py
View file @
bef20923
...
...
@@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.
__version__
=
'0.0.
3
'
__version__
=
'0.0.
4
'
osdu_aws/storage/storage_aws.py
View file @
bef20923
...
...
@@ -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.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,18 +134,21 @@ 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
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
=
'/osdu/'
+
self
.
_aws_env
+
'/wellbore-ddms/wellbore-ddms-s3-bucket-name'
,
WithDecryption
=
True
)
response
=
ssm
.
get_parameter
(
Name
=
f
'/osdu/
{
self
.
_aws_env
}
/
{
tenant_id
}
/wellbore-ddms/WellboreDDMSBucket/name'
,
WithDecryption
=
True
)
self
.
_bucket_name
=
response
[
'Parameter'
][
'Value'
]
bucket_policy
=
self
.
getPolicy
(
self
.
_bucket_name
,
folder
)
response
=
ssm
.
get_parameter
(
Name
=
'/osdu/
'
+
self
.
_aws_env
+
'
/wellbore-ddms/iam/s3-access-role-arn'
)
response
=
ssm
.
get_parameter
(
Name
=
f
'/osdu/
{
self
.
_aws_env
}
/wellbore-ddms/iam/s3-access-role-arn'
)
roleArn
=
response
[
'Parameter'
][
'Value'
]
response
=
ssm
.
get_parameter
(
Name
=
'/osdu/
'
+
self
.
_aws_env
+
'
/wellbore-ddms/temp-cred-expiration-duration'
)
response
=
ssm
.
get_parameter
(
Name
=
f
'/osdu/
{
self
.
_aws_env
}
/wellbore-ddms/temp-cred-expiration-duration'
)
exp
=
response
[
'Parameter'
][
'Value'
]
sts_client
=
boto3
.
client
(
'sts'
,
region_name
=
self
.
_region
)
...
...
requirements.txt
View file @
bef20923
# for aws provider
boto3
botocore
requests
--extra-index-url https://community.opengroup.org/api/v4/projects/148/packages/pypi/simple
osdu_api
==0.10.1.dev207+67ed6fe4
setup.py
View file @
bef20923
...
...
@@ -20,6 +20,10 @@ from osdu_aws import __version__ as osdu_aws_version
setup
(
name
=
'osdu-core-lib-python-aws'
,
install_requires
=
[
'osdu_api==0.10.1.dev207+67ed6fe4'
],
version
=
osdu_aws_version
,
packages
=
find_packages
(),
...
...
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