diff options
author | Richard Ipsum <richard.ipsum@codethink.co.uk> | 2015-05-22 10:37:22 +0100 |
---|---|---|
committer | Baserock Gerrit <gerrit@baserock.org> | 2015-07-04 20:37:42 +0000 |
commit | 51b71cc42eb9f1d6c35823a490fd73b6bee63eac (patch) | |
tree | c6e1d63e6786170da3e9b046b83499976922ca96 | |
parent | b0fc2fac0a1536b735602e177c7ec6395838da43 (diff) | |
download | definitions-51b71cc42eb9f1d6c35823a490fd73b6bee63eac.tar.gz |
Make ssh-rsync.check check VERSION_LABEL
As well as checking whether it's defined,
we make sure there isn't already a system named $VERSION_LABEL
Note, this depends on the new json-list feature of system-version-manager.
Change-Id: I0dee5253ba95a002b493f4179c2acda734afc37a
-rwxr-xr-x | extensions/ssh-rsync.check | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/extensions/ssh-rsync.check b/extensions/ssh-rsync.check index 436aaae0..fc9bf62d 100755 --- a/extensions/ssh-rsync.check +++ b/extensions/ssh-rsync.check @@ -17,6 +17,8 @@ import os +import json +import logging import writeexts @@ -40,6 +42,8 @@ class SshRsyncCheckExtension(writeexts.WriteExtension): location = args[0] self.check_ssh_connectivity(location) + + self.check_version_label(location, os.environ['VERSION_LABEL']) self.check_is_baserock_system(location) # The new system that being deployed as an upgrade must contain @@ -62,5 +66,19 @@ class SshRsyncCheckExtension(writeexts.WriteExtension): raise writeexts.ExtensionError( "%s does not have %s" % (location, command)) + def check_version_label(self, location, version_label): + args = ['system-version-manager', 'list', '--json'] + + try: + output = writeexts.ssh_runcmd(location, args) + except writeexts.ExtensionError: + msg = ("Couldn't get system list from system-version-manager, " + "skipping version label check") + logging.exception(msg) + return + + if version_label in json.loads(output): + raise writeexts.ExtensionError( + "There is already a system called `%s'" % version_label) SshRsyncCheckExtension().run() |