summaryrefslogtreecommitdiff
path: root/morphlib/exts
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-05-21 16:55:19 +0000
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2013-05-21 16:55:19 +0000
commit2089f74af895a4918670051e5d49188ed3b3f170 (patch)
tree3badd4929cdbf588451cf1e34b786f07872646fc /morphlib/exts
parentd9be3d12be5d385332445cd1c1b60552afe86e29 (diff)
parentb8704752a13472e72730308c83217d6b05b9100b (diff)
downloadmorph-2089f74af895a4918670051e5d49188ed3b3f170.tar.gz
Merge remote-tracking branch 'origin/jonathan/nfsboot-upgrade'
Diffstat (limited to 'morphlib/exts')
-rwxr-xr-xmorphlib/exts/nfsboot.write23
1 files changed, 22 insertions, 1 deletions
diff --git a/morphlib/exts/nfsboot.write b/morphlib/exts/nfsboot.write
index e2ce7db2..61c5306a 100755
--- a/morphlib/exts/nfsboot.write
+++ b/morphlib/exts/nfsboot.write
@@ -66,19 +66,40 @@ 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:
return f.readline().strip()
+ def create_local_state(self, location, hostname):
+ statedir = os.path.join(self._nfsboot_root, hostname, 'state')
+ subdirs = [os.path.join(statedir, 'home'),
+ os.path.join(statedir, 'opt'),
+ os.path.join(statedir, 'srv')]
+ cliapp.ssh_runcmd('root@%s' % location,
+ ['mkdir', '-p'] + subdirs)
+
def copy_kernel(self, temp_root, location, versioned_root, version,
hostname):
bootdir = os.path.join(temp_root, 'boot')