From 9fcf2e1251115af4fe59cc64453ffb50b5afd123 Mon Sep 17 00:00:00 2001 From: Jonas Bardino Date: Wed, 23 Oct 2024 12:30:39 +0000 Subject: [PATCH] Manually merge PR143 to improve cloud instance status page information and layout with helpful suggestions from users/colleagues git-svn-id: svn+ssh://svn.code.sf.net/p/migrid/code/trunk@6159 b75ad72c-e7d7-11dd-a971-7dbc132099af --- mig/shared/cloud.py | 46 +++++++++++++++------ mig/shared/functionality/reqcloudservice.py | 3 +- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/mig/shared/cloud.py b/mig/shared/cloud.py index c5584ba8c..640016860 100644 --- a/mig/shared/cloud.py +++ b/mig/shared/cloud.py @@ -1056,6 +1056,7 @@ def _get_jump_host(configuration, client_id, cloud_id, manage=False): return jump_host addr = lookup_user_service_value(configuration, client_id, service, 'service_jumphost_address', '') + jump_host['hostalias'] = '%s-cloud-jump' % cloud_id jump_host['address'] = jump_host['fqdn'] = addr jump_host['fqdn'] = cloud_fqdn_from_ip(configuration, addr)[0] jump_host['user'] = lookup_user_service_value( @@ -1152,39 +1153,60 @@ def cloud_remove_jump_host_key(configuration, client_id, cloud_id, auth_keys, def cloud_ssh_login_help(configuration, client_id, cloud_id, label, address, port, image): """Return complete ssh login instructions for saved cloud_dict instance on - cloud_id. + cloud_id. Output is explicitly html-formatted. """ _logger = configuration.logger - base_msg = """You can connect with ssh as user %s on host %s and port %d. - """ + base_msg = """

+You can connect with ssh as user %s on host %s and port %d. +
""" jump_msg = """Please note that you MUST explicitly ssh jump through host %(fqdn)s as user %(user)s to reach the instance. - """ +
""" jump_host = cloud_login_jump_host(configuration, client_id, cloud_id) fqdn = cloud_fqdn_from_ip(configuration, address)[0] username = cloud_login_username(configuration, cloud_id, image) msg = base_msg % (username, fqdn, port) jump_opt = '' ssh_config = """Host %s -HostName %s -User %s -# Path to your ssh private key matching pub key set on your Cloud Setup page -IdentityFile ~/.ssh/id_rsa -IdentitiesOnly yes + Hostname %s + User %s + # Path to your ssh private key matching pub key set on your Cloud Setup page + IdentityFile ~/.ssh/id_rsa + IdentitiesOnly yes """ % (label, fqdn, username) if jump_host['fqdn']: msg += jump_msg % jump_host jump_opt = "-J%(user)s@%(fqdn)s" % jump_host - ssh_config += """ProxyJump %(user)s@%(fqdn)s + ssh_config += """ ProxyJump %(hostalias)s + +Host %(hostalias)s %(fqdn)s + Hostname %(fqdn)s + User %(user)s + # Path to your ssh private key matching pub key set on your Cloud Setup page + IdentityFile ~/.ssh/id_rsa """ % jump_host msg += """Example explicit ssh command: +

+
 ssh %s %s@%s
+
+
+

""" % (jump_opt, username, fqdn) - msg += """ + msg += """

Alternatively you can add something like: +

+
 %s
-to your ~/.ssh/config to allow the simple ssh command:
+
+
+to your ~/.ssh/config to allow connecting with the simple ssh command: +
+
 ssh %s
+
+
+

""" % (ssh_config, label) return msg diff --git a/mig/shared/functionality/reqcloudservice.py b/mig/shared/functionality/reqcloudservice.py index 7885544fd..f9a466bb7 100644 --- a/mig/shared/functionality/reqcloudservice.py +++ b/mig/shared/functionality/reqcloudservice.py @@ -109,8 +109,7 @@ def _ssh_help(configuration, client_id, cloud_id, cloud_dict, image = cloud_dict.get('INSTANCE_IMAGE', 'UNKNOWN') msg = cloud_ssh_login_help(configuration, client_id, cloud_id, label, address, port, image) - # Wrap lines as html - return msg.replace('\n', '
') + return msg def signature():