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

mykolabodnar pushed a commit to branch DataLab-keycloak_deployment_fixes
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git


The following commit(s) were added to 
refs/heads/DataLab-keycloak_deployment_fixes by this push:
     new c1b5f8d  [DATALAB-Keycloak_deployment-fixes] - Connection fixed
c1b5f8d is described below

commit c1b5f8d1ea39f0d8f121fabd7a6f257daeaf418c
Author: bodnarmykola <[email protected]>
AuthorDate: Mon May 31 12:37:57 2021 +0300

    [DATALAB-Keycloak_deployment-fixes] - Connection fixed
---
 .../scripts/deploy_keycloak/deploy_keycloak.py     | 35 ++++++++++++----------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git 
a/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py 
b/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py
index 1050fda..655de88 100644
--- a/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py
+++ b/infrastructure-provisioning/scripts/deploy_keycloak/deploy_keycloak.py
@@ -85,26 +85,13 @@ def configure_nginx():
     conn.sudo("systemctl enable nginx")
     conn.sudo("systemctl restart nginx")
 
-if __name__ == "__main__":
-    subprocess.run("sudo mkdir /logs/keycloak -p", shell=True, check=True)
-    subprocess.run('sudo chown ' + args.os_user + ':' + args.os_user + ' -R 
/logs/keycloak', shell=True, check=True)
-    local_log_filename = "keycloak_deployment_script.log"
-    local_log_filepath = "/logs/keycloak/" + local_log_filename
-    logging.basicConfig(format='%(levelname)-8s [%(asctime)s]  %(message)s',
-                        level=logging.DEBUG,
-                        filename=local_log_filepath)
-
-    print("Configure connections")
-    if args.public_ip_address != '':
-        hostname = args.public_ip_address
-    else:
-        hostname = private_ip_address
+def init_datalab_connection(hostname, username, keyfile):
     try:
         global conn
         attempt = 0
         while attempt < 10:
             print('connection attempt {}'.format(attempt))
-            conn = Connection(host = hostname, user = args.os_user, 
connect_kwargs={'key_filename': args.keyfile})
+            conn = Connection(host = hostname, user = username, 
connect_kwargs={'key_filename': keyfile})
             conn.config.run.echo = True
             try:
                 conn.run('ls')
@@ -117,6 +104,24 @@ if __name__ == "__main__":
         traceback.print_exc()
         sys.exit(1)
 
+if __name__ == "__main__":
+    subprocess.run("sudo mkdir /logs/keycloak -p", shell=True, check=True)
+    subprocess.run('sudo chown ' + args.os_user + ':' + args.os_user + ' -R 
/logs/keycloak', shell=True, check=True)
+    local_log_filename = "keycloak_deployment_script.log"
+    local_log_filepath = "/logs/keycloak/" + local_log_filename
+    logging.basicConfig(format='%(levelname)-8s [%(asctime)s]  %(message)s',
+                        level=logging.DEBUG,
+                        filename=local_log_filepath)
+
+    print("Configure connections")
+    if args.public_ip_address != '':
+        hostname = args.public_ip_address
+    else:
+        hostname = private_ip_address
+
+    conn = datalab.fab.init_datalab_connection(hostname, args.os_user],
+                                               args.keyfile)
+
     print("Install Java")
     ensure_jre_jdk(args.os_user)
 

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

Reply via email to