X-Git-Url: https://code.grnet.gr/git/snf-image-creator/blobdiff_plain/39b0429a0e667e38174259702993685591ce9e35..8e58e69976b0d79f9b7758347c7bfce1ba9f6d8a:/image_creator/dialog_wizard.py?ds=sidebyside diff --git a/image_creator/dialog_wizard.py b/image_creator/dialog_wizard.py index 260a5bd..fb92f29 100644 --- a/image_creator/dialog_wizard.py +++ b/image_creator/dialog_wizard.py @@ -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 @@ -33,13 +33,19 @@ # 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 +import json from image_creator.kamaki_wrapper import Kamaki, ClientError from image_creator.util import MD5, FatalError from image_creator.output.cli import OutputWthProgress -from image_creator.dialog_util import extract_image, update_background_title +from image_creator.dialog_util import extract_image, update_background_title, \ + add_cloud, edit_cloud PAGE_WIDTH = 70 @@ -191,9 +197,40 @@ class WizardInputPage(WizardPage): def start_wizard(session): """Run the image creation wizard""" - init_token = Kamaki.get_token() - if init_token is None: - init_token = "" + + d = session['dialog'] + clouds = Kamaki.get_clouds() + if not len(clouds): + if not add_cloud(session): + return False + else: + while 1: + choices = [] + for (name, cloud) in clouds.items(): + descr = cloud['description'] if 'description' in cloud else '' + choices.append((name, descr)) + + (code, choice) = d.menu( + "In this menu you can select existing cloud account to use " + " or add new ones. Press