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
commit fee98e6c0d86783d71129acbf14862b0a02188a5 Author: leonidfrolov <[email protected]> AuthorDate: Wed Feb 19 17:48:35 2020 +0200 DLAB-1531 remade add_bucket_label function for gcp a bit and added some labels to gcp buckets after creation --- infrastructure-provisioning/src/general/lib/gcp/actions_lib.py | 4 ++-- .../src/general/scripts/gcp/common_create_bucket.py | 1 - .../src/general/scripts/gcp/project_prepare.py | 9 +++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py index 0487e0b..aefc902 100644 --- a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py +++ b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py @@ -188,12 +188,12 @@ class GCPActions: file=sys.stdout)})) traceback.print_exc(file=sys.stdout) - def add_bucket_label(self, bucket_name): + def add_bucket_label(self, bucket_name, key , value): try: bucket = self.storage_client.get_bucket(bucket_name) labels = bucket.labels - labels['name'] = '{}'.format(bucket_name) + labels[key] = '{}'.format(value) bucket.labels = labels bucket.patch() print('Updated labels on {}.'.format(bucket_name)) diff --git a/infrastructure-provisioning/src/general/scripts/gcp/common_create_bucket.py b/infrastructure-provisioning/src/general/scripts/gcp/common_create_bucket.py index c75e718..643f6ca 100644 --- a/infrastructure-provisioning/src/general/scripts/gcp/common_create_bucket.py +++ b/infrastructure-provisioning/src/general/scripts/gcp/common_create_bucket.py @@ -40,7 +40,6 @@ if __name__ == "__main__": else: print("Creating Bucket {}".format(args.bucket_name)) GCPActions().create_bucket(args.bucket_name) - GCPActions().add_bucket_label(args.bucket_name) else: parser.print_help() sys.exit(2) diff --git a/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py b/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py index 099f7a6..f23cf07 100644 --- a/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py +++ b/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py @@ -369,6 +369,10 @@ if __name__ == "__main__": 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']) except: traceback.print_exc() raise Exception @@ -377,6 +381,11 @@ if __name__ == "__main__": 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']) except: traceback.print_exc() raise Exception --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
