Revision 8e58e699 image_creator/dialog_wizard.py
b/image_creator/dialog_wizard.py | ||
---|---|---|
39 | 39 |
|
40 | 40 |
import time |
41 | 41 |
import StringIO |
42 |
import json |
|
42 | 43 |
|
43 | 44 |
from image_creator.kamaki_wrapper import Kamaki, ClientError |
44 | 45 |
from image_creator.util import MD5, FatalError |
... | ... | |
292 | 293 |
md5 = MD5(out) |
293 | 294 |
session['checksum'] = md5.compute(image.device, size) |
294 | 295 |
|
295 |
#Metadata |
|
296 |
metastring = '\n'.join( |
|
297 |
['%s=%s' % (key, value) for (key, value) in metadata.items()]) |
|
298 |
metastring += '\n' |
|
299 |
|
|
300 | 296 |
out.output() |
301 | 297 |
try: |
302 | 298 |
out.output("Uploading image to pithos:") |
... | ... | |
307 | 303 |
pithos_file = "" |
308 | 304 |
with open(image.device, 'rb') as f: |
309 | 305 |
pithos_file = kamaki.upload(f, size, name, |
310 |
"(1/4) Calculating block hashes",
|
|
311 |
"(2/4) Uploading missing blocks")
|
|
306 |
"(1/3) Calculating block hashes",
|
|
307 |
"(2/3) Uploading missing blocks")
|
|
312 | 308 |
|
313 |
out.output("(3/4) Uploading metadata file ...", False) |
|
314 |
kamaki.upload(StringIO.StringIO(metastring), size=len(metastring), |
|
315 |
remote_path="%s.%s" % (name, 'meta')) |
|
316 |
out.success('done') |
|
317 |
out.output("(4/4) Uploading md5sum file ...", False) |
|
309 |
out.output("(3/3) Uploading md5sum file ...", False) |
|
318 | 310 |
md5sumstr = '%s %s\n' % (session['checksum'], name) |
319 | 311 |
kamaki.upload(StringIO.StringIO(md5sumstr), size=len(md5sumstr), |
320 | 312 |
remote_path="%s.%s" % (name, 'md5sum')) |
... | ... | |
325 | 317 |
False |
326 | 318 |
out.output('Registering %s image with cyclades ...' % |
327 | 319 |
wizard['ImageRegistration'].lower(), False) |
328 |
kamaki.register(wizard['ImageName'], pithos_file, metadata,
|
|
329 |
is_public) |
|
320 |
result = kamaki.register(wizard['ImageName'], pithos_file,
|
|
321 |
metadata, is_public)
|
|
330 | 322 |
out.success('done') |
323 |
out.output("Uploading metadata file ...", False) |
|
324 |
metastring = unicode(json.dumps(result, ensure_ascii=False)) |
|
325 |
kamaki.upload(StringIO.StringIO(metastring), size=len(metastring), |
|
326 |
remote_path="%s.%s" % (name, 'meta')) |
|
327 |
out.success('done') |
|
328 |
|
|
331 | 329 |
if is_public: |
332 | 330 |
out.output("Sharing md5sum file ...", False) |
333 | 331 |
kamaki.share("%s.md5sum" % name) |
Also available in: Unified diff