This is an automated email from the ASF dual-hosted git repository.
lfrolov pushed a commit to branch DLAB-1531
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1531 by this push:
new 1e4fe85 DLAB-1531 changed add_bucket_labels function, updated code
according to changed function
1e4fe85 is described below
commit 1e4fe85a08190a5e140cc92a4140f302491adf10
Author: leonidfrolov <[email protected]>
AuthorDate: Thu Feb 20 13:10:18 2020 +0200
DLAB-1531 changed add_bucket_labels function, updated code according to
changed function
---
.../src/general/lib/gcp/actions_lib.py | 7 ++-----
.../src/general/scripts/gcp/project_prepare.py | 22 +++++++++++++---------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
index 8657b78..ba55bc4 100644
--- a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py
@@ -188,14 +188,11 @@ class GCPActions:
file=sys.stdout)}))
traceback.print_exc(file=sys.stdout)
- def add_bucket_label(self, bucket_name, key , value):
+ def add_bucket_labels(self, bucket_name, tags):
try:
- print('----------adding tags to bucket: ' + bucket_name)
bucket = self.storage_client.get_bucket(bucket_name)
labels = bucket.labels
- print('labels:')
- print(labels)
- labels[key] = '{}'.format(value)
+ labels.update(tags)
bucket.labels = labels
bucket.patch()
print('Updated labels on {}.'.format(bucket_name))
diff --git
a/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py
b/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py
index f23cf07..ede9991 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py
@@ -366,26 +366,30 @@ if __name__ == "__main__":
try:
logging.info('[CREATE BUCKETS]')
print('[CREATE BUCKETS]')
+ project_conf['shared_bucket_tags'] = {
+ "name":project_conf['shared_bucket_name'],
+ "endpoint_tag":project_conf['endpoint_tag'],
+ "product":"dlab",
+ "sbn":project_conf['service_base_name']}
params = "--bucket_name {}".format(project_conf['shared_bucket_name'])
try:
local("~/scripts/{}.py {}".format('common_create_bucket', params))
- GCPActions().add_bucket_label(project_conf['shared_bucket_name'],
"name", project_conf['shared_bucket_name'])
- GCPActions().add_bucket_label(project_conf['shared_bucket_name'],
"endpoint_tag", project_conf['endpoint_tag'])
- GCPActions().add_bucket_label(project_conf['shared_bucket_name'],
"product", "dlab")
- GCPActions().add_bucket_label(project_conf['shared_bucket_name'],
"sbn", project_conf['service_base_name'])
+ GCPActions().add_bucket_labels(project_conf['shared_bucket_name'],
project_conf['shared_bucket_tags'])
except:
traceback.print_exc()
raise Exception
params = "--bucket_name {}".format(project_conf['bucket_name'])
+ project_conf['bucket_tags'] = {
+ "name":project_conf['bucket_name'],
+ "endpoint_tag":project_conf['endpoint_tag'],
+ "product":"dlab",
+ "sbn":project_conf['service_base_name'],
+ "project_tag":project_conf['project_tag']}
try:
local("~/scripts/{}.py {}".format('common_create_bucket', params))
- GCPActions().add_bucket_label(project_conf['bucket_name'], "name",
project_conf['shared_bucket_name'])
- GCPActions().add_bucket_label(project_conf['bucket_name'],
"endpoint_tag", project_conf['endpoint_tag'])
- GCPActions().add_bucket_label(project_conf['bucket_name'],
"product", "dlab")
- GCPActions().add_bucket_label(project_conf['bucket_name'],
"project_tag", project_conf['project_tag'])
- GCPActions().add_bucket_label(project_conf['bucket_name'], "sbn",
project_conf['service_base_name'])
+ GCPActions().add_bucket_labels(project_conf['bucket_name'],
project_conf['bucket_tags'])
except:
traceback.print_exc()
raise Exception
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]