You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by lf...@apache.org on 2020/02/20 14:54:06 UTC

[incubator-dlab] branch DLAB-1531 updated (9d3e854 -> 03b6694)

This is an automated email from the ASF dual-hosted git repository.

lfrolov pushed a change to branch DLAB-1531
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.


    from 9d3e854  DLAB-1531 fixed creation in aws
     new 27f91b6  DLAB-1531 fixed errors
     new bd48194  DLAB-1531 changed for testing
     new 03b6694  Merged

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 infrastructure-provisioning/src/general/lib/aws/actions_lib.py        | 4 ++--
 .../src/general/scripts/aws/common_create_bucket.py                   | 3 +--
 .../src/general/scripts/gcp/common_create_bucket.py                   | 2 +-
 .../src/general/scripts/gcp/project_prepare.py                        | 4 ++--
 4 files changed, 6 insertions(+), 7 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 02/03: DLAB-1531 changed for testing

Posted by lf...@apache.org.
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 bd48194568d3180406e3c63cc97f198587ab73a5
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Thu Feb 20 16:22:42 2020 +0200

    DLAB-1531 changed for testing
---
 .../general/scripts/aws/common_create_bucket.py    |  3 +--
 .../src/general/scripts/aws/project_prepare.py     | 28 ++++++++++++++--------
 2 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/infrastructure-provisioning/src/general/scripts/aws/common_create_bucket.py b/infrastructure-provisioning/src/general/scripts/aws/common_create_bucket.py
index 207af06..71a5456 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/common_create_bucket.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/common_create_bucket.py
@@ -32,7 +32,6 @@ parser = argparse.ArgumentParser()
 parser.add_argument('--bucket_name', type=str, default='')
 parser.add_argument('--bucket_tags', type=str, default='')
 parser.add_argument('--region', type=str, default='')
-parser.add_argument('--bucket_name_tag', type=str, default='')
 args = parser.parse_args()
 
 
@@ -42,7 +41,7 @@ if __name__ == "__main__":
             bucket = get_bucket_by_name(args.bucket_name)
             if bucket == '':
                 print("Creating bucket {0} with tags {1}.".format(args.bucket_name, args.bucket_tags))
-                bucket = create_s3_bucket(args.bucket_name, args.bucket_tags, args.region, args.bucket_name_tag)
+                bucket = create_s3_bucket(args.bucket_name, args.bucket_tags, args.region)
             else:
                 print("REQUESTED BUCKET ALREADY EXISTS")
             print("BUCKET_NAME {}".format(bucket))
diff --git a/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py b/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py
index b8fb85d..d04eedb 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/project_prepare.py
@@ -134,7 +134,7 @@ if __name__ == "__main__":
     logging.info(json.dumps(project_conf))
 
     if 'conf_additional_tags' in os.environ:
-        project_conf['bucket_additional_tags'] = os.environ['conf_additional_tags'] + ';'
+        project_conf['bucket_additional_tags'] = ';' + os.environ['conf_additional_tags']
         os.environ['conf_additional_tags'] = os.environ['conf_additional_tags'] + \
                                              ';project_tag:{0};endpoint_tag:{1};'.format(
                                                  project_conf['project_tag'], project_conf['endpoint_tag'])
@@ -533,22 +533,30 @@ if __name__ == "__main__":
     try:
         logging.info('[CREATE BUCKETS]')
         print('[CREATE BUCKETS]')
-        project_conf['shared_bucket_tags'] = 'endpoint_tag:{};{}:{};{}:{};{}'.format(project_conf['endpoint_tag'],
+        tags = list()
+        tags.append({'Key': os.environ['conf_tag_resource_id'],
+                     'Value': os.environ['conf_service_base_name'] + ':' + project_conf['shared_bucket_name_tag']})
+        project_conf['shared_bucket_tags'] = 'endpoint_tag:{};{}:{};{}:{}{}'.format(project_conf['endpoint_tag'],
                                                                                   os.environ['conf_billing_tag_key'], os.environ['conf_billing_tag_value'],
                                                                                   project_conf['tag_name'], project_conf['shared_bucket_name'], project_conf['bucket_additional_tags'])
-        params = "--bucket_name {} --bucket_tags {} --region {} --bucket_name_tag {}". \
-            format(project_conf['shared_bucket_name'], project_conf['shared_bucket_tags'], project_conf['region'], project_conf['shared_bucket_name_tag'])
+        for tag in project_conf['shared_bucket_tags'].split(';'):
+            tags.append(
+                {
+                    'Key': tag.split(':')[0],
+                    'Value': tag.split(':')[1]
+                }
+            )
+        params = "--bucket_name {} --bucket_tags '{}' --region {}". \
+            format(project_conf['shared_bucket_name'], tags, project_conf['region'])
         try:
             local("~/scripts/{}.py {}".format('common_create_bucket', params))
         except:
             traceback.print_exc()
             raise Exception
-        project_conf['bucket_tags'] = 'endpoint_tag:{};{}:{};project_tag:{};{}:{};{}'.format(project_conf['endpoint_tag'],
-                                                                                  os.environ['conf_billing_tag_key'], os.environ['conf_billing_tag_value'],
-                                                                                  project_conf['project_tag'],
-                                                                                  project_conf['tag_name'], project_conf['bucket_name'], project_conf['bucket_additional_tags'])
-        params = "--bucket_name {} --bucket_tags {} --region {} --bucket_name_tag {}" \
-                 .format(project_conf['bucket_name'], project_conf['tag_name'], project_conf['region'], project_conf['bucket_name_tag'])
+        tags.append({'Key': 'project_tag',
+                     'Value': project_conf['project_tag']})
+        params = "--bucket_name {} --bucket_tags '{}' --region {}" \
+                 .format(project_conf['bucket_name'], tags, project_conf['region'])
         try:
             local("~/scripts/{}.py {}".format('common_create_bucket', params))
         except:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 01/03: DLAB-1531 fixed errors

Posted by lf...@apache.org.
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 27f91b67ee8f5d93520aa0ac3af7be58164550bf
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Thu Feb 20 16:19:15 2020 +0200

    DLAB-1531 fixed errors
---
 .../src/general/lib/aws/actions_lib.py                     | 14 ++------------
 .../src/general/scripts/gcp/common_create_bucket.py        |  2 +-
 .../src/general/scripts/gcp/project_prepare.py             |  4 ++--
 3 files changed, 5 insertions(+), 15 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/aws/actions_lib.py b/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
index af6412c..d094ec5 100644
--- a/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
@@ -66,7 +66,7 @@ def put_to_bucket(bucket_name, local_file, destination_file):
         return False
 
 
-def create_s3_bucket(bucket_name, bucket_tags, region, bucket_name_tag):
+def create_s3_bucket(bucket_name, bucket_tags, region):
     try:
         s3 = boto3.resource('s3', config=Config(signature_version='s3v4'))
         if region == "us-east-1":
@@ -83,18 +83,8 @@ def create_s3_bucket(bucket_name, bucket_tags, region, bucket_name_tag):
                     },
                 ]
             })
-        tags = list()
-        tags.append({'Key': os.environ['conf_tag_resource_id'],
-                     'Value': os.environ['conf_service_base_name'] + ':' + bucket_name_tag})
-        for tag in bucket_tags.split(';'):
-            tags.append(
-                {
-                    'Key': tag.split(':')[0],
-                    'Value': tag.split(':')[1]
-                }
-            )
         tagging = bucket.Tagging()
-        tagging.put(Tagging={'TagSet': tags})
+        tagging.put(Tagging={'TagSet': bucket_tags})
         tagging.reload()
         return bucket.name
     except Exception as err:
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 5291d9a..1ac223f 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/common_create_bucket.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/common_create_bucket.py
@@ -41,7 +41,7 @@ if __name__ == "__main__":
         else:
             print("Creating Bucket {}".format(args.bucket_name))
             GCPActions().create_bucket(args.bucket_name)
-            GCPActions().add_bucket_labels(args.bucket_name, args.tags)
+            GCPActions().add_bucket_labels(args.bucket_name, json.loads(args.tags))
     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 b25975d..5b44d66 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/project_prepare.py
@@ -371,7 +371,7 @@ if __name__ == "__main__":
             "endpoint_tag": project_conf['endpoint_tag'],
             os.environ['conf_billing_tag_key']: os.environ['conf_billing_tag_value'],
             "sbn": project_conf['service_base_name']}
-        params = "--bucket_name {} --tags {}".format(project_conf['shared_bucket_name'], project_conf['shared_bucket_tags'])
+        params = "--bucket_name {} --tags '{}'".format(project_conf['shared_bucket_name'], json.dumps(project_conf['shared_bucket_tags']))
         try:
             local("~/scripts/{}.py {}".format('common_create_bucket', params))
         except:
@@ -384,7 +384,7 @@ if __name__ == "__main__":
             os.environ['conf_billing_tag_key']: os.environ['conf_billing_tag_value'],
             "sbn": project_conf['service_base_name'],
             "project_tag": project_conf['project_tag']}
-        params = "--bucket_name {} --tags {}".format(project_conf['bucket_name'], project_conf['bucket_tags'])
+        params = "--bucket_name {} --tags '{}'".format(project_conf['bucket_name'], json.dumps(project_conf['bucket_tags']))
 
         try:
             local("~/scripts/{}.py {}".format('common_create_bucket', params))


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 03/03: Merged

Posted by lf...@apache.org.
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 03b6694efd53c90252ca9fb20edc6fdee45ca42e
Merge: bd48194 9d3e854
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Thu Feb 20 16:53:46 2020 +0200

    Merged

 .../src/general/lib/aws/actions_lib.py             | 10 ++++++++
 .../src/general/scripts/aws/project_prepare.py     | 28 ++++++++--------------
 2 files changed, 20 insertions(+), 18 deletions(-)

diff --cc infrastructure-provisioning/src/general/lib/aws/actions_lib.py
index d094ec5,adb2661..6ec2396
--- a/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
+++ b/infrastructure-provisioning/src/general/lib/aws/actions_lib.py
@@@ -83,8 -83,18 +83,18 @@@ def create_s3_bucket(bucket_name, bucke
                      },
                  ]
              })
+         tags = list()
+         tags.append({'Key': os.environ['conf_tag_resource_id'],
+                      'Value': os.environ['conf_service_base_name'] + ':' + bucket_name_tag})
+         for tag in bucket_tags.split(','):
+             tags.append(
+                 {
+                     'Key': tag.split(':')[0],
+                     'Value': tag.split(':')[1]
+                 }
+             )
          tagging = bucket.Tagging()
 -        tagging.put(Tagging={'TagSet': tags})
 +        tagging.put(Tagging={'TagSet': bucket_tags})
          tagging.reload()
          return bucket.name
      except Exception as err:


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org