summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-11-28 18:31:34 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2014-11-28 18:31:34 +0000
commit20d5d5bfd8dca33d009bfa2d7db38528ac14d757 (patch)
treeae872919c560344bf854b09c7ebd93ea080dafdc
parent7f0dc323b18599cf8726d1a1c9536ecfb2d25fd6 (diff)
downloadmorph-baserock/pedroalvarez/rawdisk-to-device7.tar.gz
separate disk and devices for everythingbaserock/pedroalvarez/rawdisk-to-device7
-rwxr-xr-xmorphlib/exts/rawdisk.write21
1 files changed, 12 insertions, 9 deletions
diff --git a/morphlib/exts/rawdisk.write b/morphlib/exts/rawdisk.write
index 8daf65fd..5c1b9790 100755
--- a/morphlib/exts/rawdisk.write
+++ b/morphlib/exts/rawdisk.write
@@ -48,22 +48,25 @@ class RawDiskWriteExtension(morphlib.writeexts.WriteExtension):
if upgrade:
self.upgrade_local_system(location, temp_root)
else:
- try:
- if not self.is_device(location):
+ if not self.is_device(location):
+ try:
with self.disk_image_created(location):
self.format_btrfs(location)
self.create_system(temp_root, location)
self.status(msg='Disk image has been created at %s' % location)
- else:
+ except Exception:
+ self.status(msg='Failure to create disk image at %s' %
+ location)
+ raise
+ else:
+ try:
self.format_btrfs(location)
self.create_system(temp_root, location)
self.status(msg='System deployed to %s' % location)
- except Exception:
- self.status(msg='Failure to create disk image at %s' %
- location)
- if os.path.exists(location):
- os.remove(location)
- raise
+ except Exception:
+ self.status(msg='Failure deploy system to %s' %
+ location)
+ raise
def upgrade_local_system(self, raw_disk, temp_root):
self.complete_fstab_for_btrfs_layout(temp_root)