summaryrefslogtreecommitdiff
path: root/morphlib/writeexts.py
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-04-14 12:35:26 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-04-15 12:03:51 +0300
commite0eb010bbe8fdb2ee4b5607d9a5288a078fcb1b0 (patch)
treee4bac1026c14a08dc64ee7af3c6a3cc3a2d34b0f /morphlib/writeexts.py
parentc0ecac7662235a66adca1c483f1a170c8a479bd0 (diff)
downloadmorph-e0eb010bbe8fdb2ee4b5607d9a5288a078fcb1b0.tar.gz
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.
Diffstat (limited to 'morphlib/writeexts.py')
-rw-r--r--morphlib/writeexts.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/morphlib/writeexts.py b/morphlib/writeexts.py
index bff21e8d..3f9c33d5 100644
--- a/morphlib/writeexts.py
+++ b/morphlib/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))