launch-node.py: More verbose logging

One problem with "shell script as python" is that there's no
equivalent of "-x" in shell, which makes it really hard to extract
what's being called and where output came from.

This adds a bit more verbose logging around the ssh calls to try and
help someone parsing the logs.

Change-Id: I85e2415b47e044cfa1c678fc7786b4891fa1f93e
This commit is contained in:
Ian Wienand 2016-08-24 10:52:37 +10:00
parent 4ac715e0f3
commit 20afe1a62f
2 changed files with 9 additions and 5 deletions

View File

@ -74,7 +74,7 @@ def bootstrap_server(server, key, name, volume_device, keep,
ip = server.public_v4
ssh_kwargs = dict(pkey=key)
print 'Public IP', ip
print("--- Running initial configuration on host %s ---" % ip)
for username in ['root', 'ubuntu', 'centos', 'admin']:
ssh_client = utils.ssh_connect(ip, username, ssh_kwargs, timeout=600)
if ssh_client:

View File

@ -40,19 +40,23 @@ class SSHClient(object):
def ssh(self, command, error_ok=False):
stdin, stdout, stderr = self.client.exec_command(command)
print command
print('--- ssh: "%s" ---' % command)
print(' -- stdout --')
output = ''
for x in stdout:
output += x
sys.stdout.write(x)
sys.stdout.write(" | " + x)
ret = stdout.channel.recv_exit_status()
print stderr.read()
print(" -- stderr --")
for x in stderr:
sys.stdout.write(" | " + x)
if (not error_ok) and ret:
raise SSHException("Unable to %s" % command, ret)
print("--- done ---\n")
return ret, output
def scp(self, source, dest):
print 'copy', source, dest
print('--- scp copy: %s -> %s' % (source, dest))
ftp = self.client.open_sftp()
ftp.put(source, dest)
ftp.close()