Commit bdc8d646 authored by Nikos Skalkotos's avatar Nikos Skalkotos

Don't fail if an non-existing sysprep is specified

Create a warning instead.

This resolves #36
parent c9b557b0
......@@ -309,11 +309,21 @@ def image_creator():
if not os.access(script, os.X_OK):
raise FatalError("File: `%s' is not executable." % script)
for sysprep in options.disabled_syspreps:
image.os.disable_sysprep(image.os.get_sysprep_by_name(sysprep))
for name in options.disabled_syspreps:
sysprep = image.os.get_sysprep_by_name(name)
if sysprep is not None:
image.os.disable_sysprep(sysprep)
else:
out.warn("Sysprep: `%s' does not exist. Can't disable it." %
name)
for sysprep in options.enabled_syspreps:
image.os.enable_sysprep(image.os.get_sysprep_by_name(sysprep))
for name in options.enabled_syspreps:
sysprep = image.os.get_sysprep_by_name(name)
if sysprep is not None:
image.os.enable_sysprep(sysprep)
else:
out.warn("Sysprep: `%s' does not exist. Can't enable it." %
name)
if options.print_syspreps:
image.os.print_syspreps()
......
......@@ -341,8 +341,6 @@ class OSBase(object):
def get_sysprep_by_name(self, name):
"""Returns the sysprep object with the given name"""
error_msg = "Syprep operation %s does not exist for %s" % \
(name, self.__class__.__name__)
method_name = '_' + name.replace('-', '_')
......@@ -352,7 +350,7 @@ class OSBase(object):
if hasattr(method, '_sysprep'):
return method
raise FatalError(error_msg)
return None
def enable_sysprep(self, obj):
"""Enable a system preparation operation"""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment