+ # Create Cloud Wizard Page
+ def cloud_choices():
+ choices = []
+ for (name, cloud) in Kamaki.get_clouds().items():
+ descr = cloud['description'] if 'description' in cloud else ''
+ choices.append((name, descr))
+
+ return choices
+
+ def cloud_add():
+ return add_cloud(session)
+
+ def cloud_none_available():
+ if not session['dialog'].yesno(
+ "No available clouds found. Would you like to add one now?",
+ width=PAGE_WIDTH, defaultno=0):
+ return add_cloud(session)
+ return False
+
+ def cloud_validate(cloud):
+ if not Kamaki.get_account(cloud):
+ if not session['dialog'].yesno(
+ "The cloud you have selected is not valid! Would you "
+ "like to edit it now?", width=PAGE_WIDTH, defaultno=0):
+ if edit_cloud(session, cloud):
+ return cloud
+
+ raise WizardReloadPage
+
+ return cloud
+
+ cloud = WizardMenuPage(
+ "Cloud", "Cloud",
+ "Please select a cloud account or press <Add> to add a new one:",
+ choices=cloud_choices, extra_label="Add", extra=cloud_add,
+ title="Clouds", validate=cloud_validate, fallback=cloud_none_available)
+
+ # Create Image Name Wizard Page
+ name = WizardInputPage(
+ "ImageName", "Image Name", "Please provide a name for the image:",
+ title="Image Name", default=ostype if distro == "unknown" else distro)
+
+ # Create Image Description Wizard Page
+ descr = WizardInputPage(
+ "ImageDescription", "Image Description",
+ "Please provide a description for the image:",
+ title="Image Description", default=session['metadata']['DESCRIPTION']
+ if 'DESCRIPTION' in session['metadata'] else '')
+
+ # Create Sysprep Params Wizard Page
+ needed = image.os.needed_sysprep_params()
+
+ def sysprep_params_fields():
+ fields = []
+ available = image.os.sysprep_params
+ for param in needed:
+ text = param.description
+ default = available[param.name] if param.name in available else ""
+ fields.append(("%s: " % text, default, param.length))
+ return fields
+
+ def sysprep_params_validate(answer):
+ params = {}
+ for i in range(len(answer)):
+ if needed[i].validator(answer):
+ params[needed[i].name] = answer[i]
+ else:
+ session['dialog'].msgbox("Invalid value for parameter `%s'" %
+ needed[i].name)
+ raise WizardReloadPage
+ return params
+
+ def sysprep_params_display(params):
+ return ",".join(["%s=%s" % (key, val) for key, val in params.items()])
+
+ sysprep_params = WizardFormPage(
+ "SysprepParams", "Sysprep Parameters",
+ "Prease fill in the following system preparation parameters:",
+ title="System Preparation Parameters", fields=sysprep_params_fields,
+ display=sysprep_params_display, validate=sysprep_params_validate
+ ) if len(needed) != 0 else None
+
+ # Create Image Registration Wizard Page
+ def registration_choices():
+ return [("Private", "Image is accessible only by this user"),
+ ("Public", "Everyone can create VMs from this image")]
+
+ registration = WizardRadioListPage(
+ "ImageRegistration", "Registration Type",
+ "Please provide a registration type:", registration_choices,
+ title="Registration Type", default="Private")