("File injection", ["EnforcePersonality"], ["windows", "linux"])
]
+SYSPREP_PARAM_MAXLEN = 20
+
class MetadataMonitor(object):
"""Monitors image metadata chages"""
session['upload'] = filename
break
- gauge = GaugeOutput(d, "Image Upload", "Uploading...")
+ gauge = GaugeOutput(d, "Image Upload", "Uploading ...")
try:
out = image.out
out.add(gauge)
"Calculating block hashes",
"Uploading missing blocks")
# Upload md5sum file
- out.output("Uploading md5sum file...")
+ out.output("Uploading md5sum file ...")
md5str = "%s %s\n" % (session['checksum'], filename)
kamaki.upload(StringIO.StringIO(md5str), size=len(md5str),
remote_path="%s.md5sum" % filename)
metadata[key] = 'yes'
img_type = "public" if is_public else "private"
- gauge = GaugeOutput(d, "Image Registration", "Registering image...")
+ gauge = GaugeOutput(d, "Image Registration", "Registering image ...")
try:
out = session['image'].out
out.add(gauge)
try:
try:
- out.output("Registering %s image with the cloud..." % img_type)
+ out.output("Registering %s image with the cloud ..." %
+ img_type)
kamaki = Kamaki(session['account'], out)
result = kamaki.register(name, session['pithos_uri'], metadata,
is_public)
out.success('done')
# Upload metadata file
- out.output("Uploading metadata file...")
+ out.output("Uploading metadata file ...")
metastring = unicode(json.dumps(result, ensure_ascii=False))
kamaki.upload(StringIO.StringIO(metastring),
size=len(metastring),
remote_path="%s.meta" % session['upload'])
out.success("done")
if is_public:
- out.output("Sharing metadata and md5sum files...")
+ out.output("Sharing metadata and md5sum files ...")
kamaki.share("%s.meta" % session['upload'])
kamaki.share("%s.md5sum" % session['upload'])
out.success('done')
(code, to_delete) = d.checklist("Choose which cloud accounts to delete:",
choices=choices, width=WIDTH)
+ to_delete = map(lambda x: x.strip('"'), to_delete) # Needed for OpenSUSE
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return False
if len(Kamaki.get_clouds()):
default_item = "Cloud"
else:
- default_time = "Add/Edit"
+ default_item = "Add/Edit"
else:
- default_time = "Delete"
+ default_item = "Delete"
elif choice == "Cloud":
default_item = "Cloud"
clouds = Kamaki.get_clouds()
(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:
choices=choices, height=19, list_height=8, width=WIDTH,
help_button=1, extra_button=1, extra_label="No Config",
title="Exclude Configuration Tasks")
+ tags = map(lambda x: x.strip('"'), tags) # Needed for OpenSUSE
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return False
return True
+def sysprep_params(session):
+ """Collect the needed sysprep parameters"""
+ d = session['dialog']
+ image = session['image']
+
+ available = image.os.sysprep_params
+ needed = image.os.needed_sysprep_params
+
+ if len(needed) == 0:
+ return True
+
+ def print_form(names, extra_button=False):
+ """print the dialog form providing sysprep_params"""
+ fields = []
+ for name in names:
+ param = needed[name]
+ default = str(available[name]) if name in available else ""
+ fields.append(("%s: " % param.description, default,
+ SYSPREP_PARAM_MAXLEN))
+
+ kwargs = {}
+ if extra_button:
+ kwargs['extra_button'] = 1
+ kwargs['extra_label'] = "Advanced"
+
+ txt = "Please provide the following system preparation parameters:"
+ return d.form(txt, height=13, width=WIDTH, form_height=len(fields),
+ fields=fields, **kwargs)
+
+ def check_params(names, values):
+ """check if the provided sysprep parameters have leagal values"""
+ for i in range(len(names)):
+ param = needed[names[i]]
+ try:
+ normalized = param.type(values[i])
+ if param.validate(normalized):
+ image.os.sysprep_params[names[i]] = normalized
+ continue
+ except ValueError:
+ pass
+
+ d.msgbox("Invalid value for parameter: `%s'" % names[i],
+ width=SMALL_WIDTH)
+ return False
+ return True
+
+ simple_names = [k for k, v in needed.items() if v.default is None]
+ 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 code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
+ return False
+ if code == d.DIALOG_EXTRA:
+ while 1:
+ code, output = print_form(advanced_names)
+ if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
+ break
+ if check_params(advanced_names, output):
+ break
+ continue
+
+ if check_params(simple_names, output):
+ break
+
+ return True
+
+
def sysprep(session):
"""Perform various system preperation tasks on the image"""
d = session['dialog']
wrapper = textwrap.TextWrapper(width=WIDTH - 5)
- help_title = "System Preperation Tasks"
- sysprep_help = "%s\n%s\n\n" % (help_title, '=' * len(help_title))
-
syspreps = image.os.list_syspreps()
if len(syspreps) == 0:
while 1:
choices = []
index = 0
+
+ help_title = "System Preperation Tasks"
+ sysprep_help = "%s\n%s\n\n" % (help_title, '=' * len(help_title))
+
for sysprep in syspreps:
name, descr = image.os.sysprep_info(sysprep)
display_name = name.replace('-', ' ').capitalize()
"run on the image. Press <Help> to see details about the system "
"preparation tasks.", title="Run system preparation tasks",
choices=choices, width=70, ok_label="Run", help_button=1)
+ tags = map(lambda x: x.strip('"'), tags) # Needed for OpenSUSE
if code in (d.DIALOG_CANCEL, d.DIALOG_ESC):
return False
title="System Preperation", width=SMALL_WIDTH)
continue
+ if not sysprep_params(session):
+ continue
+
infobox = InfoBoxOutput(d, "Image Configuration")
try:
image.out.add(infobox)
break
elif choice == "Reset":
if confirm_reset(d):
- d.infobox("Resetting snf-image-creator. Please wait...",
+ d.infobox("Resetting snf-image-creator. Please wait ...",
width=SMALL_WIDTH)
raise Reset
elif choice == "Help":