From 5be813e9e1eab3ca289bac901dab40548bba42fe Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 19 Mar 2015 13:04:00 +0000 Subject: deploy: Tighten SSH connectivity check I accidentally tried to deploy a Baserock upgrade to a Fedora cloud machine. Every SSH command that Morph ran got the following output: Please login as the user "fedora" rather than the user "root". The existing implementation of check_ssh_connectivity() didn't raise an exception, leading to confusing errors further down. The new implementation produces this error: ERROR: Unexpected output from remote machine: Please login as the user "fedora" rather than the user "root". Change-Id: Ida5a82b25d759167aa842194b0d833d0565b4acf --- morphlib/writeexts.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py index ab451d14..270cade9 100644 --- a/morphlib/writeexts.py +++ b/morphlib/writeexts.py @@ -605,12 +605,16 @@ class WriteExtension(cliapp.Application): def check_ssh_connectivity(self, ssh_host): try: - cliapp.ssh_runcmd(ssh_host, ['true']) + output = cliapp.ssh_runcmd(ssh_host, ['echo', 'test']) except cliapp.AppException as e: logging.error("Error checking SSH connectivity: %s", str(e)) raise cliapp.AppException( 'Unable to SSH to %s: %s' % (ssh_host, e)) + if output.strip() != 'test': + raise cliapp.AppException( + 'Unexpected output from remote machine: %s' % output.strip()) + def is_device(self, location): try: st = os.stat(location) -- cgit v1.2.1