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/03/02 11:37:35 UTC

[incubator-dlab] branch DLAB-1539 created (now 907fcd6)

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

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


      at 907fcd6  [DLAB-1539]: added user tag and custom tag to notebook labels

This branch includes the following new commits:

     new 6129baf  [DLAB-1539]: changed user tag for notebooks
     new 907fcd6  [DLAB-1539]: added user tag and custom tag to notebook labels

The 2 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.



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


[incubator-dlab] 01/02: [DLAB-1539]: changed user tag for notebooks

Posted by lf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6129bafd762e0ee5929bc437af2885bed5357fba
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Thu Feb 27 12:22:38 2020 +0200

    [DLAB-1539]: changed user tag for notebooks
---
 .../src/general/scripts/gcp/common_prepare_notebook.py                 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py b/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py
index 7f14dab..dedf730 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py
@@ -45,6 +45,7 @@ if __name__ == "__main__":
     notebook_config['project_name'] = (os.environ['project_name']).lower().replace('_', '-')
     notebook_config['project_tag'] = (os.environ['project_name']).lower().replace('_', '-')
     notebook_config['endpoint_tag'] = (os.environ['endpoint_name']).lower().replace('_', '-')
+    notebook_config['user_tag'] = (os.environ['user_tag']).lower().replace('_', '-')
     notebook_config['region'] = os.environ['gcp_region']
     notebook_config['zone'] = os.environ['gcp_zone']
 
@@ -139,7 +140,7 @@ if __name__ == "__main__":
                                  "sbn": notebook_config['service_base_name'],
                                  "project_tag": notebook_config['project_tag'],
                                  "endpoint_tag": notebook_config['endpoint_tag'],
-                                 "user": notebook_config['edge_user_name'],
+                                 "user": notebook_config['user_tag'],
                                  "product": "dlab",
                                  }
     # launching instance for notebook server


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


[incubator-dlab] 02/02: [DLAB-1539]: added user tag and custom tag to notebook labels

Posted by lf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 907fcd66775af34e8e6fff763b6fcd3587310541
Author: leonidfrolov <fr...@gmail.com>
AuthorDate: Mon Mar 2 13:31:45 2020 +0200

    [DLAB-1539]: added user tag and custom tag to notebook labels
---
 .../src/general/lib/gcp/meta_lib.py                     |  2 +-
 .../src/general/scripts/gcp/common_prepare_notebook.py  | 17 +++++++++++++----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/infrastructure-provisioning/src/general/lib/gcp/meta_lib.py b/infrastructure-provisioning/src/general/lib/gcp/meta_lib.py
index d31106e..2cc6197 100644
--- a/infrastructure-provisioning/src/general/lib/gcp/meta_lib.py
+++ b/infrastructure-provisioning/src/general/lib/gcp/meta_lib.py
@@ -256,7 +256,7 @@ class GCPMeta:
                         service_account_email = service_account['email']
                         response = service_account_email[:service_account_email.find('@')][-5:]
                 if response == '':
-                    print("No service account with" + service_account_name + "display name.")
+                    print("No service account with " + service_account_name + " display name.")
                 else:
                     print("Service account " + service_account_name + " has " + response + " index.")
                 return response
diff --git a/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py b/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py
index dedf730..39c93e1 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/common_prepare_notebook.py
@@ -45,7 +45,6 @@ if __name__ == "__main__":
     notebook_config['project_name'] = (os.environ['project_name']).lower().replace('_', '-')
     notebook_config['project_tag'] = (os.environ['project_name']).lower().replace('_', '-')
     notebook_config['endpoint_tag'] = (os.environ['endpoint_name']).lower().replace('_', '-')
-    notebook_config['user_tag'] = (os.environ['user_tag']).lower().replace('_', '-')
     notebook_config['region'] = os.environ['gcp_region']
     notebook_config['zone'] = os.environ['gcp_zone']
 
@@ -133,16 +132,26 @@ if __name__ == "__main__":
         data = {"notebook_name": notebook_config['instance_name'], "error": ""}
         json.dump(data, f)
 
-    additional_tags = os.environ['tags'].replace("': u'", ": ").replace("', u'", ", ").replace("{u'", "" ).replace("'}", "")
-    print('Additional tags will be added: {}'.format(additional_tags))
+    additional_tags = json.loads(os.environ['tags'].replace("': u'", "\": \"").replace("', u'", "\", \"").replace("{u'", "{\"" ).replace("'}", "\"}"))
+
+    if '@' in additional_tags['user_tag']:
+        notebook_config['user_tag'] = additional_tags['user_tag'][:additional_tags['user_tag'].find('@')]
+    else:
+        notebook_config['user_tag'] = additional_tags['user_tag']
 
+    notebook_config['custom_tag'] = additional_tags['custom_tag']
+    print('Additional tags will be added: {}'.format(additional_tags))
     notebook_config['labels'] = {"name": notebook_config['instance_name'],
                                  "sbn": notebook_config['service_base_name'],
                                  "project_tag": notebook_config['project_tag'],
                                  "endpoint_tag": notebook_config['endpoint_tag'],
                                  "user": notebook_config['user_tag'],
-                                 "product": "dlab",
+                                 "product": "dlab"
                                  }
+
+    if notebook_config['custom_tag'] != '':
+        notebook_config['labels'].update({'custom_tag': notebook_config['custom_tag']})
+
     # launching instance for notebook server
     try:
         logging.info('[CREATE NOTEBOOK INSTANCE]')


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