job, args = self._cleanup_jobs.pop()
job(*args)
- def get_device(self):
- """Returns a newly created DiskDevice instance.
-
- This instance is a snapshot of the original source media of
- the Disk instance.
+ def snapshot(self):
+ """Creates a snapshot of the original source media of the Disk
+ instance.
"""
output("Examining source media `%s'..." % self.source, False)
finally:
os.unlink(table)
success('done')
- new_device = DiskDevice("/dev/mapper/%s" % snapshot)
+ return "/dev/mapper/%s" % snapshot
+
+ def get_device(self, media):
+ """Returns a newly created DiskDevice instance."""
+
+ new_device = DiskDevice(media)
self._devices.append(new_device)
new_device.enable()
return new_device
disk = Disk(options.source)
try:
- dev = disk.get_device()
+ snapshot = disk.snapshot()
+
+ dev = disk.get_device(snapshot)
dev.mount()
osclass = get_os_class(dev.distro, dev.ostype)
dev.dump(options.outfile)
+ # Destroy the device. We only need the snapshot from now on
+ disk.destroy_device(dev)
+
if options.upload:
output("Uploading image to pithos...", False)
kamaki = Kamaki(options.account, options.token)
- kamaki.upload(dev.device, size, options.upload)
+ kamaki.upload(snapshot, size, options.upload)
output("done")
finally: