summaryrefslogtreecommitdiff
path: root/morphlib/exts/nfsboot.write
diff options
context:
space:
mode:
authorJonathan Maw <jonathan.maw@codethink.co.uk>2013-05-16 15:14:14 +0000
committerJonathan Maw <jonathan.maw@codethink.co.uk>2013-05-20 17:31:57 +0100
commitfa71f8b06cbf0199c7bc2aab7090e62a21e3f4b8 (patch)
tree1be48377be5eb571ddaa7cd9fd44566e335da354 /morphlib/exts/nfsboot.write
parentd9be3d12be5d385332445cd1c1b60552afe86e29 (diff)
downloadmorph-fa71f8b06cbf0199c7bc2aab7090e62a21e3f4b8.tar.gz
Can define version by the environment variable 'VERSION'
If the version already exists on the device, deployment is aborted
Diffstat (limited to 'morphlib/exts/nfsboot.write')
-rwxr-xr-xmorphlib/exts/nfsboot.write15
1 files changed, 14 insertions, 1 deletions
diff --git a/morphlib/exts/nfsboot.write b/morphlib/exts/nfsboot.write
index e2ce7db2..cfc3fc32 100755
--- a/morphlib/exts/nfsboot.write
+++ b/morphlib/exts/nfsboot.write
@@ -66,14 +66,27 @@ class NFSBootWriteExtension(morphlib.writeexts.WriteExtension):
'with hostname "baserock"')
self.test_good_server(location)
- version = 'version1'
+ version = os.environ['VERSION'] or 'version1'
versioned_root = os.path.join(self._nfsboot_root, hostname, 'systems',
version)
+ if self.version_exists(versioned_root, location):
+ raise cliapp.AppException('Version %s already exists on'
+ ' this device. Deployment aborted'
+ % version)
self.copy_rootfs(temp_root, location, versioned_root, hostname)
self.copy_kernel(temp_root, location, versioned_root, version,
hostname)
self.configure_nfs(location, hostname)
+ def version_exists(self, versioned_root, location):
+ try:
+ cliapp.ssh_runcmd('root@%s' % location,
+ ['test', '-d', versioned_root])
+ except cliapp.AppException:
+ return False
+
+ return True
+
def get_hostname(self, temp_root):
hostnamepath = os.path.join(temp_root, 'etc', 'hostname')
with open(hostnamepath) as f: