From f7b4039973398400e355c5ea2a068dac4bbc994b Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Mon, 14 Apr 2014 12:35:26 +0000 Subject: deploy: Share SSH connectivity check in the common writeexts.py code Also, change it to log the real error message in morph.log before raising a more general exception to the user. --- writeexts.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/writeexts.py b/writeexts.py index bff21e8d..3f9c33d5 100644 --- a/writeexts.py +++ b/writeexts.py @@ -15,6 +15,7 @@ import cliapp +import logging import os import re import shutil @@ -417,3 +418,11 @@ class WriteExtension(cliapp.Application): else: raise cliapp.AppException('Unexpected value for %s: %s' % (variable, value)) + + def check_ssh_connectivity(self, ssh_host): + try: + cliapp.ssh_runcmd(ssh_host, ['true']) + 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)) -- cgit v1.2.1