From 873bbad884582010e159ca7ed04d8ccb3dd8ac8f Mon Sep 17 00:00:00 2001
From: Nikos Skalkotos <skalkoto@grnet.gr>
Date: Thu, 3 Apr 2014 16:30:24 +0300
Subject: [PATCH] Fix a bug in sysprep param handling in dialog_menu

If the needed sysprep parameters had all default values,
snf-image-creator would crash when trying to run the image
customization. This bug could not be triggered from the current os_type
classes.
---
 image_creator/dialog_menu.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/image_creator/dialog_menu.py b/image_creator/dialog_menu.py
index 2b6925b..06e3ce1 100644
--- a/image_creator/dialog_menu.py
+++ b/image_creator/dialog_menu.py
@@ -690,7 +690,14 @@ def sysprep_params(session):
     advanced_names = [k for k, v in needed.items() if v.default is not None]
 
     while 1:
-        code, output = print_form(simple_names, extra_button=True)
+
+        if len(simple_names) > 0:
+            extra_button = len(advanced_names) > 0
+            code, output = print_form(simple_names, extra_button=extra_button)
+            choice = simple_names
+        elif len(advanced_names) > 0:
+            code, output = print_form(advanced_names, extra_button=False)
+            choice = advanced_names
 
         if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
             return False
@@ -703,7 +710,7 @@ def sysprep_params(session):
                     break
             continue
 
-        if check_params(simple_names, output):
+        if check_params(choice, output):
             break
 
     return True
-- 
GitLab