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

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

commit a35a55096a654ed8d71d949a7bf4f717baae893e
Author: Oleh Martushevskyi <[email protected]>
AuthorDate: Tue Mar 12 14:02:13 2019 +0200

    added installation and configuration of reverse proxy;
---
 .../src/general/scripts/aws/edge_configure.py      |  2 +-
 .../src/general/scripts/gcp/edge_configure.py      | 30 +++++++++++++++++++
 .../src/general/scripts/gcp/edge_prepare.py        |  4 +--
 .../src/general/scripts/gcp/jupyter_configure.py   | 35 ++++++++++++++++++++--
 4 files changed, 66 insertions(+), 5 deletions(-)

diff --git 
a/infrastructure-provisioning/src/general/scripts/aws/edge_configure.py 
b/infrastructure-provisioning/src/general/scripts/aws/edge_configure.py
index 7720b54..cf69adb 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/edge_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/edge_configure.py
@@ -200,7 +200,7 @@ if __name__ == "__main__":
             raise Exception
     except Exception as err:
         print('Error: {0}'.format(err))
-        append_result("Failed installing users key." + str(err))
+        append_result("Failed installing nginx reverse proxy." + str(err))
         remove_all_iam_resources('notebook', os.environ['edge_user_name'])
         remove_all_iam_resources('edge', os.environ['edge_user_name'])
         remove_ec2(edge_conf['tag_name'], edge_conf['instance_name'])
diff --git 
a/infrastructure-provisioning/src/general/scripts/gcp/edge_configure.py 
b/infrastructure-provisioning/src/general/scripts/gcp/edge_configure.py
index f8a3792..4f9d4c9 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/edge_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/edge_configure.py
@@ -230,6 +230,36 @@ if __name__ == "__main__":
         sys.exit(1)
 
     try:
+        print('[INSTALLING NGINX REVERSE PROXY]')
+        logging.info('[INSTALLING NGINX REVERSE PROXY]')
+        params = "--hostname {} --keyfile {} --user {}" \
+            .format(instance_hostname, edge_conf['ssh_key_path'], 
edge_conf['dlab_ssh_user'])
+        try:
+            local("~/scripts/{}.py {}".format('configure_nginx_reverse_proxy', 
params))
+        except:
+            traceback.print_exc()
+            raise Exception
+    except Exception as err:
+        print('Error: {0}'.format(err))
+        append_result("Failed installing nginx reverse proxy. Excpeption: " + 
str(err))
+        GCPActions().remove_instance(edge_conf['instance_name'], 
edge_conf['zone'])
+        GCPActions().remove_static_address(edge_conf['static_address_name'], 
edge_conf['region'])
+        GCPActions().remove_bucket(edge_conf['bucket_name'])
+        GCPActions().remove_firewall(edge_conf['fw_edge_ingress_public'])
+        GCPActions().remove_firewall(edge_conf['fw_edge_ingress_internal'])
+        GCPActions().remove_firewall(edge_conf['fw_edge_egress_public'])
+        GCPActions().remove_firewall(edge_conf['fw_edge_egress_internal'])
+        GCPActions().remove_firewall(edge_conf['fw_ps_ingress'])
+        GCPActions().remove_firewall(edge_conf['fw_ps_egress_private'])
+        GCPActions().remove_firewall(edge_conf['fw_ps_egress_public'])
+        
GCPActions().remove_service_account(edge_conf['ps_service_account_name'])
+        GCPActions().remove_role(edge_conf['ps_role_name'])
+        
GCPActions().remove_service_account(edge_conf['edge_service_account_name'])
+        GCPActions().remove_role(edge_conf['edge_role_name'])
+        GCPActions().remove_subnet(edge_conf['subnet_name'], 
edge_conf['region'])
+        sys.exit(1)
+
+    try:
         print('[SUMMARY]')
         logging.info('[SUMMARY]')
         print("Instance name: {}".format(edge_conf['instance_name']))
diff --git 
a/infrastructure-provisioning/src/general/scripts/gcp/edge_prepare.py 
b/infrastructure-provisioning/src/general/scripts/gcp/edge_prepare.py
index 71fdc4a..4ab4136 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/edge_prepare.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/edge_prepare.py
@@ -237,8 +237,8 @@ if __name__ == "__main__":
         rules = [
             {
                 'IPProtocol': 'tcp',
-                'ports': ['22', '8888', '8080', '8787', '6006', '20888', 
'8088', '18080', '50070', '8085', '8081',
-                          '4040-4045']
+                'ports': ['22', '389', '8888', '8080', '8787', '6006', 
'20888', '8042', '8088', '18080', '50070',
+                          '8085', '8081', '4040-4045']
             }
         ]
         egress_rule['allowed'] = rules
diff --git 
a/infrastructure-provisioning/src/general/scripts/gcp/jupyter_configure.py 
b/infrastructure-provisioning/src/general/scripts/gcp/jupyter_configure.py
index a01ff6a..15b909a 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/jupyter_configure.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/jupyter_configure.py
@@ -52,6 +52,7 @@ if __name__ == "__main__":
                                                                
notebook_config['exploratory_name'])
     instance_hostname = 
GCPMeta().get_private_ip_address(notebook_config['instance_name'])
     edge_instance_name = 
'{0}-{1}-edge'.format(notebook_config['service_base_name'], 
notebook_config['edge_user_name'])
+    edge_instance_hostname = get_instance_public_ip_by_name(edge_instance_name)
     notebook_config['ssh_key_path'] = 
'{0}{1}.pem'.format(os.environ['conf_key_dir'], os.environ['conf_key_name'])
     notebook_config['dlab_ssh_user'] = os.environ['conf_os_user']
     notebook_config['zone'] = os.environ['gcp_zone']
@@ -86,8 +87,8 @@ if __name__ == "__main__":
         print('[CONFIGURE PROXY ON JUPYTER INSTANCE]')
         additional_config = {"proxy_host": edge_instance_name, "proxy_port": 
"3128"}
         params = "--hostname {} --instance_name {} --keyfile {} 
--additional_config '{}' --os_user {}"\
-            .format(instance_hostname, notebook_config['instance_name'], 
notebook_config['ssh_key_path'], json.dumps(additional_config),
-                    notebook_config['dlab_ssh_user'])
+            .format(instance_hostname, notebook_config['instance_name'], 
notebook_config['ssh_key_path'],
+                    json.dumps(additional_config), 
notebook_config['dlab_ssh_user'])
         try:
             local("~/scripts/{}.py {}".format('common_configure_proxy', 
params))
         except:
@@ -176,6 +177,36 @@ if __name__ == "__main__":
         GCPActions().remove_instance(notebook_config['instance_name'], 
notebook_config['zone'])
         sys.exit(1)
 
+    try:
+        print('[SETUP EDGE REVERSE PROXY TEMPLATE]')
+        logging.info('[SETUP EDGE REVERSE PROXY TEMPLATE]')
+        additional_info = {
+            'instance_hostname': instance_hostname,
+            'tensor': False
+        }
+        params = "--edge_hostname {} " \
+                 "--keyfile {} " \
+                 "--os_user {} " \
+                 "--type {} " \
+                 "--exploratory_name {} " \
+                 "--additional_info '{}'"\
+            .format(edge_instance_hostname,
+                    notebook_config['ssh_key_path'],
+                    notebook_config['dlab_ssh_user'],
+                    'jupyter',
+                    notebook_config['exploratory_name'],
+                    json.dumps(additional_info))
+        try:
+            local("~/scripts/{}.py 
{}".format('common_configure_reverse_proxy', params))
+        except:
+            append_result("Failed edge reverse proxy template")
+            raise Exception
+    except Exception as err:
+        print('Error: {0}'.format(err))
+        append_result("Failed to set edge reverse proxy template.", str(err))
+        GCPActions().remove_instance(notebook_config['instance_name'], 
notebook_config['zone'])
+        sys.exit(1)
+
     # generating output information
     ip_address = 
GCPMeta().get_private_ip_address(notebook_config['instance_name'])
     jupyter_ip_url = "http://"; + ip_address + 
":8888/{}/".format(notebook_config['exploratory_name'])


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to