Monkey-patch pythondialog to support form boxes
[snf-image-creator] / image_creator / dialog_wizard.py
index 17204dc..20fe45a 100644 (file)
@@ -1,5 +1,5 @@
-#!/usr/bin/env python
-
+# -*- coding: utf-8 -*-
+#
 # Copyright 2012 GRNET S.A. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or
 # interpreted as representing official policies, either expressed
 # or implied, of GRNET S.A.
 
+"""This module implements the "wizard" mode of the dialog-based version of
+snf-image-creator.
+"""
+
 import time
 import StringIO
 
@@ -195,9 +199,11 @@ def start_wizard(session):
     if init_token is None:
         init_token = ""
 
+    distro = session['image'].distro
+    ostype = session['image'].ostype
     name = WizardInputPage(
         "ImageName", "Image Name", "Please provide a name for the image:",
-        title="Image Name", init=session['image'].distro)
+        title="Image Name", init=ostype if distro == "unknown" else distro)
 
     descr = WizardInputPage(
         "ImageDescription", "Image Description",
@@ -264,16 +270,8 @@ def create_image(session):
         out.clear()
 
         #Sysprep
-        image.mount(False)
-        err_msg = "Unable to execute the system preparation tasks."
-        if not image.mounted:
-            raise FatalError("%s Couldn't mount the media." % err_msg)
-        elif image.mounted_ro:
-            raise FatalError("%s Couldn't mount the media read-write."
-                             % err_msg)
         image.os.do_sysprep()
         metadata = image.os.meta
-        image.umount()
 
         #Shrink
         size = image.shrink()
@@ -323,6 +321,14 @@ def create_image(session):
             kamaki.register(wizard['ImageName'], pithos_file, metadata,
                             is_public)
             out.success('done')
+            if is_public:
+                out.output("Sharing md5sum file ...", False)
+                kamaki.share("%s.md5sum" % name)
+                out.success('done')
+                out.output("Sharing metadata file ...", False)
+                kamaki.share("%s.meta" % name)
+                out.success('done')
+
             out.output()
 
         except ClientError as e: