Skip to content
Snippets Groups Projects
Commit 2005768d authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

Remove "Delete image properties" menu entry

Add functionality for deleting image properties in the "Modify"
menu entry in expert mode and completely remove the "Delete" entry.
parent af59d6cf
No related branches found
No related tags found
No related merge requests found
...@@ -534,30 +534,37 @@ def modify_properties(session): ...@@ -534,30 +534,37 @@ def modify_properties(session):
continue continue
(code, choice) = d.menu( (code, choice) = d.menu(
"In this menu you can edit existing image properties or add new " "In this menu you can edit and delete existing image properties "
"ones. Be careful! Most properties have special meaning and " "or add new ones. Be careful! Most properties have special "
"alter the image deployment behavior. Press <HELP> to see more " "meaning and alter the image deployment behavior. Press <HELP> to "
"information about image properties. Press <BACK> when done.", "see more information about image properties. Press <BACK> when "
height=18, width=WIDTH, choices=choices, menu_height=10, "done.", height=18, width=WIDTH, choices=choices, menu_height=10,
ok_label="Edit", extra_button=1, extra_label="Add", cancel="Back", ok_label="Edit/Del", extra_button=1, extra_label="Add",
help_button=1, title="Image Properties") cancel="Back", help_button=1, title="Image Properties")
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC): if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return True return True
# Edit button # Edit button
elif code == d.DIALOG_OK: elif code == d.DIALOG_OK:
(code, answer) = d.inputbox("Please provide a new value for the " (code, answer) = d.inputbox(
"image property with name `%s':" % "Please provide a new value for `%s' image property or press "
choice, "<Delete> to completely delete it." % choice,
init=session['metadata'][choice], init=session['metadata'][choice], width=WIDTH, extra_button=1,
width=WIDTH) extra_label="Delete")
if code not in (d.DIALOG_CANCEL, d.DIALOG_ESC): if code == d.DIALOG_OK:
value = answer.strip() value = answer.strip()
if len(value) == 0: if len(value) == 0:
d.msgbox("Value cannot be empty!") d.msgbox("Value cannot be empty!")
continue continue
else: else:
session['metadata'][choice] = value session['metadata'][choice] = value
# Delete button
elif code == d.DIALOG_EXTRA:
if not d.yesno("Are you sure you want to delete `%s' image "
"property?" % choice, width=WIDTH):
del session['metadata'][choice]
d.msgbox("Image property: `%s' was deleted." % choice,
width=SMALL_WIDTH)
# ADD button # ADD button
elif code == d.DIALOG_EXTRA: elif code == d.DIALOG_EXTRA:
add_property(session) add_property(session)
...@@ -565,35 +572,6 @@ def modify_properties(session): ...@@ -565,35 +572,6 @@ def modify_properties(session):
show_properties_help(session) show_properties_help(session)
def delete_properties(session):
"""Delete an image property"""
d = session['dialog']
choices = []
for (key, val) in session['metadata'].items():
choices.append((key, "%s" % val, 0))
if len(choices) == 0:
d.msgbox("No available images properties to delete!",
width=SMALL_WIDTH)
return True
(code, to_delete) = d.checklist("Choose which properties to delete:",
choices=choices, width=WIDTH)
to_delete = map(lambda x: x.strip('"'), to_delete) # needed for OpenSUSE
# If the user exits with ESC or CANCEL, the returned tag list is empty.
for i in to_delete:
del session['metadata'][i]
cnt = len(to_delete)
if cnt > 0:
d.msgbox("%d image properties were deleted." % cnt, width=SMALL_WIDTH)
return True
else:
return False
def exclude_tasks(session): def exclude_tasks(session):
"""Exclude specific tasks from running during image deployment""" """Exclude specific tasks from running during image deployment"""
d = session['dialog'] d = session['dialog']
...@@ -870,16 +848,14 @@ def customization_menu(session): ...@@ -870,16 +848,14 @@ def customization_menu(session):
choices = [("Sysprep", "Run various image preparation tasks"), choices = [("Sysprep", "Run various image preparation tasks"),
("Shrink", "Shrink image"), ("Shrink", "Shrink image"),
("View/Modify", "View/Modify image properties"), ("Modify", "Modify image properties"),
("Delete", "Delete image properties"),
("Exclude", "Exclude various deployment tasks from running")] ("Exclude", "Exclude various deployment tasks from running")]
default_item = 0 default_item = 0
actions = {"Sysprep": sysprep, actions = {"Sysprep": sysprep,
"Shrink": shrink, "Shrink": shrink,
"View/Modify": modify_properties, "Modify": modify_properties,
"Delete": delete_properties,
"Exclude": exclude_tasks} "Exclude": exclude_tasks}
while 1: while 1:
(code, choice) = d.menu( (code, choice) = d.menu(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment