+ try:
+ out.output("Uploading image to pithos:")
+ kamaki = Kamaki(wizard['account'], wizard['token'], out)
+
+ name = "%s-%s.diskdump" % (wizard['ImageName'],
+ time.strftime("%Y%m%d%H%M"))
+ pithos_file = ""
+ with open(snapshot, 'rb') as f:
+ pithos_file = kamaki.upload(f, size, name,
+ "(1/4) Calculating block hashes",
+ "(2/4) Uploading missing blocks")
+
+ out.output("(3/4) Uploading metadata file ...", False)
+ kamaki.upload(StringIO.StringIO(metastring), size=len(metastring),
+ remote_path="%s.%s" % (name, 'meta'))
+ out.success('done')
+ out.output("(4/4) Uploading md5sum file ...", False)
+ md5sumstr = '%s %s\n' % (session['checksum'], name)
+ kamaki.upload(StringIO.StringIO(md5sumstr), size=len(md5sumstr),
+ remote_path="%s.%s" % (name, 'md5sum'))
+ out.success('done')
+ out.output()
+
+ out.output('Registering image with ~okeanos ...', False)
+ kamaki.register(wizard['ImageName'], pithos_file, metadata)
+ out.success('done')
+ out.output()
+
+ except ClientError as e:
+ raise FatalError("Pithos client: %d %s" % (e.status, e.message))
+ finally:
+ out.remove(with_progress)
+
+ msg = "The image was successfully uploaded and registered with " \
+ "~okeanos. Would you like to keep a local copy of the image?"
+ if not d.yesno(msg, width=PAGE_WIDTH):
+ extract_image(session)