def run(self,appliance, settings): success = True target = self.resolve_appliance(appliance) self.create_directory(self.output_dir(appliance, settings)) name = "%s-live" % target.name fs_label = imgcreate.build_name(target.name, prefix=None, maxlen = imgcreate.FSLABEL_MAXLEN, suffix="-livecd") logging.info("Using label '%s' and name '%s'" % (fs_label, name)) ks = imgcreate.read_kickstart(target.kickstart) creator = imgcreate.LiveImageCreator(ks, name, fs_label) creator.tmpdir = os.path.abspath(settings["temp_directory"]) #Should these be options? creator.skip_compression = False creator.skip_minimize = False try: creator.mount(None, os.path.abspath(settings["cache_directory"])) creator.install() creator.configure() creator.unmount() creator.package(destdir=self.output_dir(appliance, settings)) except imgcreate.CreatorError, e: logging.error(u"Error creating Live CD : %s" % e) return False
def __init__(self, ksfile, name, tmpdir=None, cachedir=None, export_kernel=False, separate_images=None, output_file=None): super(ImageCreator, self).__init__( imgcreate.read_kickstart(ksfile), name, '/') self.tmpdir = tmpdir or tempfile.gettempdir() if not os.path.exists(self.tmpdir): LOG.info('Creating tmp directory') os.makedirs(self.tmpdir) self.cachedir = cachedir or os.path.join(os.getcwd(), 'cache') self.export_kernel = export_kernel self.MODULES.extend(imgcreate.kickstart.get_modules(self.ks)) self.__selinux_mountpoint = "/sys/fs/selinux" # this will mount mirror into chroot and then unmount self.__output_file = output_file self.__ensure_builddir() self.__bindmounts = [BindChrootMount('/mirror', self._instroot)] self.__separate_images = {} self.__separate_images_disks = [] self.__imgdir = None for ent in separate_images.split(): mountpoint, fs_type = ent.split(',') self.__separate_images[mountpoint] = fs_type
def __init__(self, ksfile, name, tmpdir=None, cachedir=None, export_kernel=False, separate_images=None, output_file=None): super(ImageCreator, self).__init__(imgcreate.read_kickstart(ksfile), name, '/') self.tmpdir = tmpdir or tempfile.gettempdir() if not os.path.exists(self.tmpdir): LOG.info('Creating tmp directory') os.makedirs(self.tmpdir) self.cachedir = cachedir or os.path.join(os.getcwd(), 'cache') self.export_kernel = export_kernel self.MODULES.extend(imgcreate.kickstart.get_modules(self.ks)) self.__selinux_mountpoint = "/sys/fs/selinux" # this will mount mirror into chroot and then unmount self.__output_file = output_file self.__ensure_builddir() self.__bindmounts = [BindChrootMount('/mirror', self._instroot)] self.__separate_images = {} self.__separate_images_disks = [] self.__imgdir = None for ent in separate_images.split(): mountpoint, fs_type = ent.split(',') self.__separate_images[mountpoint] = fs_type
def run(self,appliance, settings): success = True target = self.resolve_appliance(appliance) vmem = int(target.memory) vcpus = int(target.cpus) appname = target.name #TODO How pass these in format = "raw" package = "none" include = "" ks = imgcreate.read_kickstart(target.kickstart) creator = appcreate.ApplianceImageCreator(ks, appname, format, vmem, vcpus) creator.tmpdir = settings["temp_directory"] creator.checksum = target.checksum creator.appliance_version = target.version creator.appliance_release = target.release try: creator.mount("NONE", settings["cache_directory"]) creator.install() creator.configure() creator.unmount() creator.package(settings["output_directory"], package, include) except imgcreate.CreatorError, e: logging.error("Unable to create appliance : %s" % e) return 1
def main(): try: options = parse_options(sys.argv[1:]) except Usage as e: msg, no_error = e.args if no_error: out = sys.stdout ret = 0 else: out = sys.stderr ret = 2 if msg: print >> out, msg return ret if os.geteuid() != 0: print >> sys.stderr, "You must run %s as root" % sys.argv[0] return 1 if options.fslabel: fslabel = options.fslabel name = fslabel else: name = "livecd" fslabel = "LiveCD" logging.info("Using label '%s' and name '%s'" % (fslabel, name)) ks = imgcreate.read_kickstart(options.kscfg) creator = myLiveImageCreator(ks, name, fslabel=fslabel, releasever=options.releasever, tmpdir=os.path.abspath(options.tmpdir)) creator.compress_type = options.compress_type creator.skip_compression = options.skip_compression creator.skip_minimize = options.skip_minimize if options.cachedir: options.cachedir = os.path.abspath(options.cachedir) try: creator.mount(options.base_on, options.cachedir) creator.install() creator.configure() if options.give_shell: print("Launching shell. Exit to continue.") print("----------------------------------") creator.launch_shell() creator.unmount() creator.package(os.environ.get("TESTDIR", ".")) except imgcreate.CreatorError as e: logging.error(u"Error creating Live CD : %s" % e) return 1 finally: creator.cleanup() return 0
def main(): if not os.path.exists(cache_dir): os.mkdir(cache_dir) logging.getLogger().setLevel(logging.INFO) name = ooblib.image_name() kspath = os.path.join(ooblib.intermediatesdir, 'build.ks') ks = imgcreate.read_kickstart(kspath) make_iso = ooblib.read_config_bool('base', 'make_iso') if make_iso: print "Building ISO image..." creator = imgcreate.LiveImageCreator(ks, name, name, tmpdir=ooblib.builddir, cacheonly=ooblib.cacheonly) compress = ooblib.read_config_bool('base', 'compress_iso') if compress is None: compress = False creator.skip_compression = not compress else: print "Building directly into FS image..." creator = imgcreate.LoopImageCreator(ks, 'imgcreatefs', name, tmpdir=ooblib.builddir, cacheonly=ooblib.cacheonly) try: creator.mount(cachedir=cache_dir) creator.install() creator.configure() creator.unmount() if make_iso: creator.package(destdir=ooblib.outputdir) else: creator.package(destdir=ooblib.intermediatesdir) except imgcreate.CreatorError, e: logging.error("Error creating Live CD : %s" % e) return 1
def package(self, destdir="."): imgcreate.LoopImageCreator.package(self, destdir) def main(): try: options = parse_options(sys.argv[1:]) except Usage, msg: logging.error(msg) return 1 if os.geteuid() != 0: logging.error("ami-creator must be run as root") return 1 ks = imgcreate.read_kickstart(options.kscfg) name = imgcreate.build_name(options.kscfg) if options.name: name = options.name creator = AmiCreator(ks, name, "/") creator.tmpdir = os.path.abspath(options.tmpdir) if options.cachedir: options.cachedir = os.path.abspath(options.cachedir) try: creator.mount(cachedir=options.cachedir) creator.install() creator.configure() if options.extract_bootfiles: creator.extract_bootfiles()
def package(self, destdir="."): imgcreate.LoopImageCreator.package(self, destdir) def main(): try: options = parse_options(sys.argv[1:]) except Usage, msg: logging.error(msg) return 1 if os.geteuid() != 0: logging.error("ami-creator must be run as root") return 1 ks = imgcreate.read_kickstart(options.kscfg) name = imgcreate.build_name(options.kscfg) if options.name: name = options.name creator = AmiCreator(ks, name) creator.tmpdir = os.path.abspath(options.tmpdir) if options.cachedir: options.cachedir = os.path.abspath(options.cachedir) try: creator.mount(cachedir=options.cachedir) creator.install() creator.configure() if options.give_shell: print "Launching shell. Exit to continue."