from image_creator import get_os_class
from image_creator import __version__ as version
-from image_creator import FatalError
from image_creator.disk import Disk
-from image_creator.util import get_command, error, success, output
+from image_creator.util import get_command, error, success, output, FatalError
from image_creator import util
import sys
import os
dirname = os.path.dirname(value)
name = os.path.basename(value)
if dirname and not os.path.isdir(dirname):
- parser.error("`%s' is not an existing directory" % dirname)
+ raise FatalError("`%s' is not an existing directory" % dirname)
if not name:
- parser.error("`%s' is not a valid file name" % dirname)
+ raise FatalError("`%s' is not a valid file name" % dirname)
setattr(parser.values, option.dest, value)
parser.add_option("-f", "--force", dest="force", default=False,
action="store_true", help="overwrite output files if they exist")
- parser.add_option("--no-cleanup", dest="cleanup", default=True,
- help="don't cleanup sensitive data", action="store_false")
-
parser.add_option("--no-sysprep", dest="sysprep", default=True,
help="don't perform system preperation", action="store_false")
default=None, action="callback", callback=check_writable_dir,
help="dump image to FILE", metavar="FILE")
- parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
- help="Print the enabled and disable sysprep actions for this image",
- action="store_true")
+ parser.add_option("--enable-sysprep", dest="enabled_syspreps", default=[],
+ help="run SYSPREP operation on the input media",
+ action="append", metavar="SYSPREP")
- parser.add_option("--print-data-cleanup", dest="print_data_cleanup",
- default=False, help="Print the enabled and disable data cleanup "
- "operations actions for this source", action="store_true")
+ parser.add_option("--disable-sysprep", dest="disabled_syspreps",
+ help="prevent SYSPREP operation from running on the input media",
+ default=[], action="append", metavar="SYSPREP")
+
+ parser.add_option("--print-sysprep", dest="print_sysprep", default=False,
+ help="print the enabled and disabled sysprep operations for this "
+ "input media", action="store_true")
parser.add_option("-s", "--silent", dest="silent", default=False,
- help="silent mode, only output error", action="store_true")
+ help="silent mode, only output errors", action="store_true")
- parser.add_option("-u", "--upload", dest="upload", default=False,
- help="upload the image to pithos", action="store_true")
+ parser.add_option("-u", "--upload", dest="upload", type="string",
+ default=False, help="upload the image to pithos with name FILENAME",
+ metavar="FILENAME")
- parser.add_option("-r", "--register", dest="register", default=False,
- help="register the image to ~okeanos", action="store_true")
+ parser.add_option("-r", "--register", dest="register", type="string",
+ default=False, help="register the image to ~okeanos as IMAGENAME",
+ metavar="IMAGENAME")
options, args = parser.parse_args(input_args)
parser.error('Wrong number of arguments')
options.source = args[0]
if not os.path.exists(options.source):
- parser.error('input media is not accessible')
+ raise FatalError("Input media `%s' is not accessible" % options.source)
- if options.register:
- options.upload = True
+ if options.register and options.upload == False:
+ raise FatalError("You also need to set -u when -r option is set")
return options
util.silent = True
if options.outfile is None and not options.upload \
- and not options.print_sysprep and not options.print_data_cleanup:
- FatalError("At least one of the following: `-o', `-u', "
- "`--print-sysprep' `--print-data-cleanup' must be set")
+ and not options.print_sysprep:
+ raise FatalError("At least one of `-o', `-u' or" \
+ "`--print-sysprep' must be set")
output('snf-image-creator %s\n' % version)
output()
- if options.print_sysprep:
- image_os.print_sysprep()
- output()
+ for sysprep in options.disabled_syspreps:
+ image_os.disable_sysprep(sysprep)
+
+ for sysprep in options.enabled_syspreps:
+ image_os.enable_sysprep(sysprep)
- if options.print_data_cleanup:
- image_os.print_data_cleanup()
+ if options.print_sysprep:
+ image_os.print_syspreps()
output()
if options.outfile is None and not options.upload:
return 0
if options.sysprep:
- image_os.sysprep()
-
- if options.cleanup:
- image_os.data_cleanup()
+ image_os.do_sysprep()
dev.umount()