def _load_kickstart(self): """Load the kickstart""" from pyanaconda import kickstart # Construct a commandMap with only the supported Anaconda's commands commandMap = dict( (k, kickstart.commandMap[k]) for k in SUPPORTED_KICKSTART_COMMANDS) # Prepare new data object self.data = kickstart.AnacondaKSHandler(self._addon_module_paths["ks"], commandUpdates=commandMap) kickstart_path = INPUT_KICKSTART_PATH if os.path.exists(OUTPUT_KICKSTART_PATH): log.info("using kickstart from previous run for input") kickstart_path = OUTPUT_KICKSTART_PATH log.info("parsing input kickstart %s", kickstart_path) try: # Read the installed kickstart parser = kickstart.AnacondaKSParser(self.data) parser.readKickstart(kickstart_path) log.info("kickstart parsing done") except pykickstart.errors.KickstartError as kserr: log.critical("kickstart parsing failed: %s", kserr) log.critical( "Initial Setup startup failed due to invalid kickstart file") raise InitialSetupError if external_reconfig: # set the reconfig flag in kickstart so that # relevant spokes show up self.data.firstboot.firstboot = FIRSTBOOT_RECONFIG
def setUp(self): import sys sys.modules["anaconda_log"] = Mock() sys.modules["block"] = Mock() from pyanaconda import kickstart self.kickstart = kickstart self.handler = kickstart.AnacondaKSHandler() self.ksparser = kickstart.AnacondaKSParser(self.handler)
def parse_kickstart(options, addon_paths, pass_to_boss=False): """Parse the input kickstart. If we were given a kickstart file, parse (but do not execute) that now. Otherwise, load in defaults from kickstart files shipped with the installation media. Pick up any changes from interactive-defaults.ks that would otherwise be covered by the dracut KS parser. :param options: command line/boot options :param dict addon_paths: addon paths dictionary :returns: kickstart parsed to a data model """ ksdata = None if options.ksfile and not options.liveinst: if not os.path.exists(options.ksfile): stdout_log.error("Kickstart file %s is missing.", options.ksfile) util.ipmi_report(constants.IPMI_ABORTED) sys.exit(1) flags.automatedInstall = True flags.eject = False ks_files = [options.ksfile] elif os.path.exists("/run/install/ks.cfg") and not options.liveinst: # this is to handle such cases where a user has pre-loaded a # ks.cfg onto an OEMDRV labeled device flags.automatedInstall = True flags.eject = False ks_files = ["/run/install/ks.cfg"] else: ks_files = [ "/tmp/updates/interactive-defaults.ks", "/usr/share/anaconda/interactive-defaults.ks" ] for ks in ks_files: if not os.path.exists(ks): continue kickstart.preScriptPass(ks) log.info("Parsing kickstart: " + ks) ksdata = kickstart.parseKickstart(ks, options.ksstrict) if pass_to_boss: distribute_kickstart_with_boss(ks) # Only load the first defaults file we find. break if not ksdata: ksdata = kickstart.AnacondaKSHandler(addon_paths["ks"]) return ksdata
def _load_kickstart(self): """Load the kickstart""" from pyanaconda import kickstart # Construct a commandMap with only the supported Anaconda's commands commandMap = dict( (k, kickstart.commandMap[k]) for k in SUPPORTED_KICKSTART_COMMANDS) # Prepare new data object self.data = kickstart.AnacondaKSHandler(self._addon_module_paths["ks"], commandUpdates=commandMap) kickstart_path = INPUT_KICKSTART_PATH if os.path.exists(OUTPUT_KICKSTART_PATH): log.info("using kickstart from previous run for input") kickstart_path = OUTPUT_KICKSTART_PATH log.info("parsing input kickstart %s", kickstart_path) try: # Read the installed kickstart parser = kickstart.AnacondaKSParser(self.data) parser.readKickstart(kickstart_path) log.info("kickstart parsing done") except pykickstart.errors.KickstartError as kserr: log.critical("kickstart parsing failed: %s", kserr) log.critical( "Initial Setup startup failed due to invalid kickstart file") raise InitialSetupError # if we got this far the kickstart should be valid, so send it to Boss as well boss = BOSS.get_proxy() report = KickstartReport.from_structure( boss.ReadKickstartFile(kickstart_path)) if not report.is_valid(): message = "\n\n".join(map(str, report.error_messages)) raise InitialSetupError(message) if self.external_reconfig: # set the reconfig flag in kickstart so that # relevant spokes show up services_proxy = SERVICES.get_proxy() services_proxy.SetSetupOnBoot(SETUP_ON_BOOT_RECONFIG) # Record if groups, users or root password has been set before Initial Setup # has been started, so that we don't trample over existing configuration. users_proxy = USERS.get_proxy() self._groups_already_configured = bool(users_proxy.Groups) self._users_already_configured = bool(users_proxy.Users) self._root_password_already_configured = users_proxy.IsRootPasswordSet
def parse_kickstart(ks, strict_mode=False): """Parse the given kickstart file. :param ks: a path to a kickstart file or None :param strict_mode: process warnings as errors if True :returns: kickstart parsed to a data model """ ksdata = kickstart.AnacondaKSHandler() if ks is not None: log.info("Parsing kickstart: %s", ks) kickstart.parseKickstart(ksdata, ks, strict_mode=strict_mode, pass_to_boss=True) return ksdata
def _load_kickstart(self): """Load the kickstart""" from pyanaconda import kickstart # Construct a commandMap with only the supported Anaconda's commands commandMap = dict( (k, kickstart.commandMap[k]) for k in SUPPORTED_KICKSTART_COMMANDS) # Prepare new data object self.data = kickstart.AnacondaKSHandler(self._addon_module_paths["ks"], commandUpdates=commandMap) kickstart_path = INPUT_KICKSTART_PATH if os.path.exists(OUTPUT_KICKSTART_PATH): log.info("using kickstart from previous run for input") kickstart_path = OUTPUT_KICKSTART_PATH log.info("parsing input kickstart %s", kickstart_path) try: # Read the installed kickstart parser = kickstart.AnacondaKSParser(self.data) parser.readKickstart(kickstart_path) log.info("kickstart parsing done") except pykickstart.errors.KickstartError as kserr: log.critical("kickstart parsing failed: %s", kserr) log.critical( "Initial Setup startup failed due to invalid kickstart file") raise InitialSetupError # if we got this far the kickstart should be valid, so send it to Boss as well boss = BOSS.get_proxy() boss.SplitKickstart(kickstart_path) errors = boss.DistributeKickstart() if errors: message = "\n\n".join("{error_message}".format_map(e) for e in errors) raise InitialSetupError(message) if self.external_reconfig: # set the reconfig flag in kickstart so that # relevant spokes show up services_proxy = SERVICES.get_proxy() services_proxy.SetSetupOnBoot(SETUP_ON_BOOT_RECONFIG)
def setUp(self): self.storage = InstallerStorage() # anaconda first configures disk images for (name, size) in iter(self.disks.items()): path = util.create_sparse_tempfile(name, size) self.storage.disk_images[name] = path # at this point the DMLinearDevice has correct size self.storage.setup_disk_images() # no kickstart available ksdata = kickstart.AnacondaKSHandler([]) # anaconda calls storage_initialize regardless of whether or not # this is an image install. Somewhere along the line this will # execute setup_disk_images() once more and the DMLinearDevice created # in this second execution has size 0 with patch('blivet.flags'): storage_initialize(self.storage, ksdata, [])
def setUp(self): self.blivet = Blivet() # anaconda first configures disk images for (name, size) in iter(self.disks.items()): path = util.create_sparse_tempfile(name, size) self.blivet.disk_images[name] = path # at this point the DMLinearDevice has correct size self.blivet.setup_disk_images() # emulates setting the anaconda flags which later update # blivet flags as the first thing to do in storage_initialize flags.image_install = True # no kickstart available ksdata = kickstart.AnacondaKSHandler([]) # anaconda calls storage_initialize regardless of whether or not # this is an image install. Somewhere along the line this will # execute setup_disk_images() once more and the DMLinearDevice created # in this second execution has size 0 storage_initialize(self.blivet, ksdata, [])
def setUp(self): self.handler = kickstart.AnacondaKSHandler() self.ksparser = kickstart.AnacondaKSParser(self.handler)
"/usr/share/anaconda/interactive-defaults.ks" ] for ks in ksFiles: if not os.path.exists(ks): continue kickstart.preScriptPass(ks) log.info("Parsing kickstart: " + ks) ksdata = kickstart.parseKickstart(ks) # Only load the first defaults file we find. break if not ksdata: ksdata = kickstart.AnacondaKSHandler(addon_paths["ks"]) # Pick up any changes from interactive-defaults.ks that would # otherwise be covered by the dracut KS parser. if ksdata.bootloader.extlinux: flags.extlinux = True if ksdata.rescue.rescue: flags.rescue_mode = True # reboot with kexec if ksdata.reboot.kexec: flags.kexec = True # Some kickstart commands must be executed immediately, as they affect # how anaconda operates. ksdata.logging.execute()
def parse(self, s): handler = kickstart.AnacondaKSHandler() parser = kickstart.AnacondaKSParser(handler) parser.readKickstartFromString(self.apply_section(s + "\n")) return handler
kickstart_commands = [ "user", "group", "keyboard", "lang", "rootpw", "timezone", "logging", "selinux", "firewall", ] commandMap = dict((k, kickstart.commandMap[k]) for k in kickstart_commands) # Prepare new data object data = kickstart.AnacondaKSHandler(addon_module_paths["ks"], commandUpdates=commandMap) log.info("parsing input kickstart %s", INPUT_KICKSTART_PATH) try: # Read the installed kickstart parser = kickstart.AnacondaKSParser(data) parser.readKickstart(INPUT_KICKSTART_PATH) log.info("kickstart parsing done") except pykickstart.errors.KickstartError as kserr: log.exception("kickstart parsing failed: %s" % kserr) sys.exit(1) if mode == "gui": try: # Try to import IS gui specifics log.debug("trying to import GUI")