def parse_options(args): parser = optparse.OptionParser() # options related to the image imgopt = optparse.OptionGroup(parser, "Image options", "These options define the created image.") imgopt.add_option("-c", "--config", type="string", dest="kscfg", help="Path or url to kickstart config file") imgopt.add_option("-n", "--name", type="string", dest="name", help="Name to use for the image") imgopt.add_option("-e", "--extract-bootfiles", action="store_true", dest="extract_bootfiles", help="Extract the kernel and ramdisk from the image") parser.add_option_group(imgopt) # options related to the config of your system sysopt = optparse.OptionGroup( parser, "System directory options", "These options define directories used on your system for creating the ami" ) sysopt.add_option("-t", "--tmpdir", type="string", dest="tmpdir", default="/var/tmp", help="Temporary directory to use (default: /var/tmp)") sysopt.add_option("", "--cache", type="string", dest="cachedir", default=None, help="Cache directory to use (default: private cache") parser.add_option_group(sysopt) imgcreate.setup_logging(parser) # debug options not recommended for "production" images # Start a shell in the chroot for post-configuration. parser.add_option("-l", "--shell", action="store_true", dest="give_shell", help=optparse.SUPPRESS_HELP) (options, args) = parser.parse_args() if not options.kscfg: raise Usage("Kickstart file must be provided") return options
def parse_options(args): parser = optparse.OptionParser() # options related to the image imgopt = optparse.OptionGroup(parser, "Image options", "These options define the created image.") imgopt.add_option("-c", "--config", type="string", dest="kscfg", help="Path or url to kickstart config file") imgopt.add_option("-n", "--name", type="string", dest="name", help="Name to use for the image") imgopt.add_option("-e", "--extract-bootfiles", action="store_true", dest="extract_bootfiles", help="Extract the kernel and ramdisk from the image") parser.add_option_group(imgopt) # options related to the config of your system sysopt = optparse.OptionGroup(parser, "System directory options", "These options define directories used on your system for creating the ami") sysopt.add_option("-t", "--tmpdir", type="string", dest="tmpdir", default="/var/tmp", help="Temporary directory to use (default: /var/tmp)") sysopt.add_option("", "--cache", type="string", dest="cachedir", default=None, help="Cache directory to use (default: private cache") parser.add_option_group(sysopt) imgcreate.setup_logging(parser) # debug options not recommended for "production" images # Start a shell in the chroot for post-configuration. parser.add_option("-l", "--shell", action="store_true", dest="give_shell", help=optparse.SUPPRESS_HELP) (options, args) = parser.parse_args() if not options.kscfg: raise Usage("Kickstart file must be provided") return options
def parse_options(args): parser = optparse.OptionParser() imgopt = optparse.OptionGroup(parser, "Image options", "These options define the created image.") imgopt.add_option("-c", "--config", type="string", dest="kscfg", help="Path or url to kickstart config file") imgopt.add_option( "-b", "--base-on", type="string", dest="base_on", help="Add packages to an existing live CD iso9660 image.") imgopt.add_option("-f", "--fslabel", type="string", dest="fslabel", help="File system label (default based on config name)") # Provided for img-create compatibility imgopt.add_option("-n", "--name", type="string", dest="fslabel", help=optparse.SUPPRESS_HELP) imgopt.add_option("", "--image-type", type="string", dest="image_type", help=optparse.SUPPRESS_HELP) imgopt.add_option("", "--compression-type", type="string", dest="compress_type", help="Compression type recognized by mksquashfs " "(default xz needs a 2.6.38+ kernel, gzip works " "with all kernels, lzo needs a 2.6.36+ kernel, lzma " "needs custom kernel.) Set to 'None' to force read " "from base_on.", default="xz") imgopt.add_option( "", "--releasever", type="string", dest="releasever", default=None, help="Value to substitute for $releasever in kickstart repo urls") parser.add_option_group(imgopt) # options related to the config of your system sysopt = optparse.OptionGroup( parser, "System directory options", "These options define directories used on your system for creating the live image" ) sysopt.add_option("-t", "--tmpdir", type="string", dest="tmpdir", default="/var/tmp", help="Temporary directory to use (default: /var/tmp)") sysopt.add_option("", "--cache", type="string", dest="cachedir", default=None, help="Cache directory to use (default: private cache") parser.add_option_group(sysopt) imgcreate.setup_logging(parser) # debug options not recommended for "production" images # Start a shell in the chroot for post-configuration. parser.add_option("-l", "--shell", action="store_true", dest="give_shell", help=optparse.SUPPRESS_HELP) # Don't compress the image. parser.add_option("-s", "--skip-compression", action="store_true", dest="skip_compression", help=optparse.SUPPRESS_HELP) parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize", help=optparse.SUPPRESS_HELP) (options, args) = parser.parse_args() # Pretend to be a image-creator if called with that name options.image_type = 'livecd' if options.image_type not in ('livecd', 'image'): raise Usage("'%s' is a recognized image type" % options.image_type) # image-create compatibility: Last argument is kickstart file if len(args) == 1: options.kscfg = args.pop() if len(args): raise Usage("Extra arguments given") if options.base_on and not os.path.isfile(options.base_on): raise Usage("Image file '%s' does not exist" % (options.base_on, )) if options.image_type == 'livecd': if options.fslabel and len(options.fslabel) > imgcreate.FSLABEL_MAXLEN: raise Usage("CD labels are limited to 32 characters") if options.fslabel and options.fslabel.find(" ") != -1: raise Usage("CD labels cannot contain spaces.") return options
def parse_options(args): parser = optparse.OptionParser() imgopt = optparse.OptionGroup(parser, "Image options", "These options define the created image.") imgopt.add_option("-c", "--config", type="string", dest="kscfg", help="Path or url to kickstart config file") imgopt.add_option("-b", "--base-on", type="string", dest="base_on", help="Add packages to an existing live CD iso9660 image.") imgopt.add_option("-f", "--fslabel", type="string", dest="fslabel", help="File system label (default based on config name)") # Provided for img-create compatibility imgopt.add_option("-n", "--name", type="string", dest="fslabel", help=optparse.SUPPRESS_HELP) imgopt.add_option("", "--image-type", type="string", dest="image_type", help=optparse.SUPPRESS_HELP) imgopt.add_option("", "--compression-type", type="string", dest="compress_type", help="Compression type recognized by mksquashfs " "(default xz needs a 2.6.38+ kernel, gzip works " "with all kernels, lzo needs a 2.6.36+ kernel, lzma " "needs custom kernel.) Set to 'None' to force read " "from base_on.", default="xz") imgopt.add_option("", "--releasever", type="string", dest="releasever", default=None, help="Value to substitute for $releasever in kickstart repo urls") parser.add_option_group(imgopt) # options related to the config of your system sysopt = optparse.OptionGroup(parser, "System directory options", "These options define directories used on your system for creating the live image") sysopt.add_option("-t", "--tmpdir", type="string", dest="tmpdir", default="/var/tmp", help="Temporary directory to use (default: /var/tmp)") sysopt.add_option("", "--cache", type="string", dest="cachedir", default=None, help="Cache directory to use (default: private cache") parser.add_option_group(sysopt) imgcreate.setup_logging(parser) # debug options not recommended for "production" images # Start a shell in the chroot for post-configuration. parser.add_option("-l", "--shell", action="store_true", dest="give_shell", help=optparse.SUPPRESS_HELP) # Don't compress the image. parser.add_option("-s", "--skip-compression", action="store_true", dest="skip_compression", help=optparse.SUPPRESS_HELP) parser.add_option("", "--skip-minimize", action="store_true", dest="skip_minimize", help=optparse.SUPPRESS_HELP) (options, args) = parser.parse_args() # Pretend to be a image-creator if called with that name options.image_type = 'livecd' if options.image_type not in ('livecd', 'image'): raise Usage("'%s' is a recognized image type" % options.image_type) # image-create compatibility: Last argument is kickstart file if len(args) == 1: options.kscfg = args.pop() if len(args): raise Usage("Extra arguments given") if options.base_on and not os.path.isfile(options.base_on): raise Usage("Image file '%s' does not exist" %(options.base_on,)) if options.image_type == 'livecd': if options.fslabel and len(options.fslabel) > imgcreate.FSLABEL_MAXLEN: raise Usage("CD labels are limited to 32 characters") if options.fslabel and options.fslabel.find(" ") != -1: raise Usage("CD labels cannot contain spaces.") return options