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
This commit is contained in:
parent
ada70387e9
commit
bc82cc3e90
@ -34,6 +34,8 @@ import utils
|
|||||||
import openstack
|
import openstack
|
||||||
import paramiko
|
import paramiko
|
||||||
|
|
||||||
|
from sshclient import SSHException
|
||||||
|
|
||||||
SCRIPT_DIR = os.path.dirname(sys.argv[0])
|
SCRIPT_DIR = os.path.dirname(sys.argv[0])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -100,9 +102,14 @@ def bootstrap_server(server, key, name, volume_device, keep,
|
|||||||
ssh_kwargs = dict(pkey=key)
|
ssh_kwargs = dict(pkey=key)
|
||||||
|
|
||||||
print("--- Running initial configuration on host %s ---" % ip)
|
print("--- Running initial configuration on host %s ---" % ip)
|
||||||
|
ssh_client = None
|
||||||
for username in ['root', 'ubuntu', 'centos', 'admin']:
|
for username in ['root', 'ubuntu', 'centos', 'admin']:
|
||||||
ssh_client = utils.ssh_connect(ip, username, ssh_kwargs,
|
try:
|
||||||
timeout=timeout)
|
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:
|
if ssh_client:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user