From bc82cc3e90a35c119228a43729b6223a08e2a91f Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Wed, 21 Apr 2021 16:51:46 -0700 Subject: [PATCH] Handle focal's insistence we don't use root in launch-node.py It seems newer focal images force you to use the ubuntu user account. We already have code that attempts to fallback to ubuntu, but we were not properly catching the error when root fails which caused the whole script to fail. Address this by catching the exception, logging a message, then continuing to the next possible option. If no possible options are found we raise an exception already which handles the worst case situation. Change-Id: Ie6013763daff01063840abce193050b33120a7a2 --- launch/launch-node.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/launch/launch-node.py b/launch/launch-node.py index ed084dd27c..e0a9d97343 100755 --- a/launch/launch-node.py +++ b/launch/launch-node.py @@ -34,6 +34,8 @@ import utils import openstack import paramiko +from sshclient import SSHException + SCRIPT_DIR = os.path.dirname(sys.argv[0]) try: @@ -100,9 +102,14 @@ def bootstrap_server(server, key, name, volume_device, keep, ssh_kwargs = dict(pkey=key) print("--- Running initial configuration on host %s ---" % ip) + ssh_client = None for username in ['root', 'ubuntu', 'centos', 'admin']: - ssh_client = utils.ssh_connect(ip, username, ssh_kwargs, - timeout=timeout) + try: + ssh_client = utils.ssh_connect(ip, username, ssh_kwargs, + timeout=timeout) + except SSHException: + print("Username: " + username + " failed to ssh. " + "Trying next option.") if ssh_client: break