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:
parent
4ac715e0f3
commit
20afe1a62f
@ -74,7 +74,7 @@ def bootstrap_server(server, key, name, volume_device, keep,
|
|||||||
ip = server.public_v4
|
ip = server.public_v4
|
||||||
ssh_kwargs = dict(pkey=key)
|
ssh_kwargs = dict(pkey=key)
|
||||||
|
|
||||||
print 'Public IP', ip
|
print("--- Running initial configuration on host %s ---" % ip)
|
||||||
for username in ['root', 'ubuntu', 'centos', 'admin']:
|
for username in ['root', 'ubuntu', 'centos', 'admin']:
|
||||||
ssh_client = utils.ssh_connect(ip, username, ssh_kwargs, timeout=600)
|
ssh_client = utils.ssh_connect(ip, username, ssh_kwargs, timeout=600)
|
||||||
if ssh_client:
|
if ssh_client:
|
||||||
|
@ -40,19 +40,23 @@ class SSHClient(object):
|
|||||||
|
|
||||||
def ssh(self, command, error_ok=False):
|
def ssh(self, command, error_ok=False):
|
||||||
stdin, stdout, stderr = self.client.exec_command(command)
|
stdin, stdout, stderr = self.client.exec_command(command)
|
||||||
print command
|
print('--- ssh: "%s" ---' % command)
|
||||||
|
print(' -- stdout --')
|
||||||
output = ''
|
output = ''
|
||||||
for x in stdout:
|
for x in stdout:
|
||||||
output += x
|
output += x
|
||||||
sys.stdout.write(x)
|
sys.stdout.write(" | " + x)
|
||||||
ret = stdout.channel.recv_exit_status()
|
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:
|
if (not error_ok) and ret:
|
||||||
raise SSHException("Unable to %s" % command, ret)
|
raise SSHException("Unable to %s" % command, ret)
|
||||||
|
print("--- done ---\n")
|
||||||
return ret, output
|
return ret, output
|
||||||
|
|
||||||
def scp(self, source, dest):
|
def scp(self, source, dest):
|
||||||
print 'copy', source, dest
|
print('--- scp copy: %s -> %s' % (source, dest))
|
||||||
ftp = self.client.open_sftp()
|
ftp = self.client.open_sftp()
|
||||||
ftp.put(source, dest)
|
ftp.put(source, dest)
|
||||||
ftp.close()
|
ftp.close()
|
||||||
|
Loading…
Reference in New Issue
Block a user