summaryrefslogtreecommitdiff
path: root/morphlib/exts/ssh-rsync.check
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-05-20 09:37:49 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-05-20 10:05:59 +0000
commit7d849ca1db73c1544073acb6b7c88a33ec88be8d (patch)
treef07118281341dea40a58107d4517ed75f2c09b1b /morphlib/exts/ssh-rsync.check
parent06b61dd0344d8e3bf1039dffc964e1e58556e75d (diff)
downloadmorph-7d849ca1db73c1544073acb6b7c88a33ec88be8d.tar.gz
deploy: Do sanity checks earlier in ssh-rsync (upgrade) extension
Diffstat (limited to 'morphlib/exts/ssh-rsync.check')
-rwxr-xr-xmorphlib/exts/ssh-rsync.check24
1 files changed, 24 insertions, 0 deletions
diff --git a/morphlib/exts/ssh-rsync.check b/morphlib/exts/ssh-rsync.check
index 90029cb4..6a776ce9 100755
--- a/morphlib/exts/ssh-rsync.check
+++ b/morphlib/exts/ssh-rsync.check
@@ -33,4 +33,28 @@ class SshRsyncCheckExtension(morphlib.writeexts.WriteExtension):
'Baserock machines. It cannot be used for an initial '
'deployment.')
+ location = args[0]
+ self.check_ssh_connectivity(location)
+ self.check_is_baserock_system(location)
+
+ # The new system that being deployed as an upgrade must contain
+ # baserock-system-config-sync and system-version-manager. However, the
+ # old system simply needs to have SSH and rsync.
+ self.check_command_exists(location, 'rsync')
+
+ def check_is_baserock_system(self, location):
+ output = cliapp.ssh_runcmd(location, ['sh', '-c',
+ 'test -d /baserock || echo -n dirnotfound'])
+ if output == 'dirnotfound':
+ raise cliapp.AppException('%s is not a baserock system'
+ % location)
+
+ def check_command_exists(self, location, command):
+ test = 'type %s > /dev/null 2>&1 || echo -n cmdnotfound' % command
+ output = cliapp.ssh_runcmd(location, ['sh', '-c', test])
+ if output == 'cmdnotfound':
+ raise cliapp.AppException(
+ "%s does not have %s" % (location, command))
+
+
SshRsyncCheckExtension().run()