def __init__(self): self.__dict__['_in_init'] = True self.usevnc = False self.vncquestion = True self.mpath = True self.debug = False self.preexisting_x11 = False self.noverifyssl = False self.automatedInstall = False self.eject = True # ksprompt is whether or not to prompt for missing ksdata self.ksprompt = True self.rescue_mode = False self.kexec = False # nosave options self.nosave_input_ks = False self.nosave_output_ks = False self.nosave_logs = False # single language options self.singlelang = False # enable SE/HMC self.hmc = False # current runtime environments self.environs = [ANACONDA_ENVIRON] # parse the boot commandline self.cmdline = KernelArguments.from_defaults() # Lock it down: no more creating new flags! self.__dict__['_in_init'] = False
def items_test(self): """Test KernelArguments access to contents with iterator.""" ka = KernelArguments.from_defaults() it = ka.items() self.assertIsInstance(it, collections.Iterable) root_seen = False for k, v in it: # pylint: disable=unused-variable if k == "root": root_seen = True self.assertTrue(root_seen)
def test_items(self): """Test KernelArguments access to contents with iterator.""" ka = KernelArguments.from_defaults() it = ka.items() assert isinstance(it, Iterable) root_seen = False for k, v in it: # pylint: disable=unused-variable if k == "root": root_seen = True assert root_seen
def __init__(self): self.__dict__['_in_init'] = True self.livecdInstall = False self.ibft = True self.nonibftiscsiboot = False self.usevnc = False self.vncquestion = True self.mpath = True self.dmraid = True self.selinux = SELINUX_DEFAULT if not selinux.is_selinux_enabled(): self.selinux = SELINUX_DISABLED self.debug = False self.armPlatform = None self.preexisting_x11 = False self.noverifyssl = False self.imageInstall = False self.automatedInstall = False self.dirInstall = False self.askmethod = False self.eject = True self.extlinux = False self.nombr = False self.gpt = False self.leavebootorder = False self.mpathFriendlyNames = True # ksprompt is whether or not to prompt for missing ksdata self.ksprompt = True self.rescue_mode = False self.kexec = False # nosave options self.nosave_input_ks = False self.nosave_output_ks = False self.nosave_logs = False # single language options self.singlelang = False # enable SE/HMC self.hmc = False # current runtime environments self.environs = [ANACONDA_ENVIRON] # parse the boot commandline self.cmdline = KernelArguments.from_defaults() # Lock it down: no more creating new flags! self.__dict__['_in_init'] = False
def parse_boot_cmdline(self, boot_cmdline): """ Parse the boot cmdline and create an appropriate Namespace instance according to the option definitions set by add_argument. boot_cmdline can be given as a string (to be parsed by KernelArguments), or a dict (or any object with .items()) of {bootarg:value} pairs. If boot_cmdline is None, the boot_cmdline data will be whatever KernelArguments reads by default (/proc/cmdline, /run/initramfs/etc/cmdline, /etc/cmdline). If an option requires a value but the boot arg doesn't provide one, we'll quietly not set anything in the Namespace. We also skip any boot options that were not specified by add_argument as we don't care about them (there will usually be quite a lot of them (rd.*, etc.). :param boot_cmdline: the Anaconda boot command line arguments :type boot_cmdline: string, dict or None :returns: an argparse Namespace instance :rtype: Namespace """ namespace = Namespace() if boot_cmdline is None: bootargs = KernelArguments.from_defaults() elif isinstance(boot_cmdline, str): bootargs = KernelArguments.from_string(boot_cmdline) else: bootargs = boot_cmdline self.deprecated_bootargs = [] # go over all options corresponding to current boot cmdline # and do any modifications necessary # NOTE: program cmdline overrides boot cmdline for arg, val in bootargs.items(): option = self._get_bootarg_option(arg) if option is None: # this boot option is unknown to Anaconda, skip it continue if option.nargs != 0 and val is None: # nargs == 0 -> the option expects one or more arguments but the # boot option was not given any, so we skip it log.warning( "boot option specified without expected number of " "arguments and will be ignored: %s", arg) continue elif option.nargs == 0 and option.const is not None: # nargs == 0 & constr == True -> store_true # (we could also check the class, but it begins with an # underscore, so it would be ugly) # special case: "mpath=0" would otherwise set mpath to True if option.const is True and val in ("0", "no", "off"): setattr(namespace, option.dest, False) # Set all other set_const cases to the const specified else: setattr(namespace, option.dest, option.const) # anaconda considers cases such as noselinux=off to be a negative # concord, which is to say that selinux will be set to False and # we hate you. continue elif type(val) is list: for item in val: option(self, namespace, item) continue option(self, namespace, val) return namespace
def parse_boot_cmdline(self, boot_cmdline): """ Parse the boot cmdline and create an appropriate Namespace instance according to the option definitions set by add_argument. boot_cmdline can be given as a string (to be parsed by KernelArguments), or a dict (or any object with .items()) of {bootarg:value} pairs. If boot_cmdline is None, the boot_cmdline data will be whatever KernelArguments reads by default (/proc/cmdline, /run/initramfs/etc/cmdline, /etc/cmdline). If an option requires a value but the boot arg doesn't provide one, we'll quietly not set anything in the Namespace. We also skip any boot options that were not specified by add_argument as we don't care about them (there will usually be quite a lot of them (rd.*, etc.). :param boot_cmdline: the Anaconda boot command line arguments :type boot_cmdline: string, dict or None :returns: an argparse Namespace instance :rtype: Namespace """ namespace = Namespace() if boot_cmdline is None: bootargs = KernelArguments.from_defaults() elif isinstance(boot_cmdline, str): bootargs = KernelArguments.from_string(boot_cmdline) else: bootargs = boot_cmdline self.deprecated_bootargs = [] # go over all options corresponding to current boot cmdline # and do any modifications necessary # NOTE: program cmdline overrides boot cmdline for arg, val in bootargs.items(): option = self._get_bootarg_option(arg) if option is None: # this boot option is unknown to Anaconda, skip it continue if option.nargs != 0 and val is None: # nargs == 0 -> the option expects one or more arguments but the # boot option was not given any, so we skip it log.warning("boot option specified without expected number of " "arguments and will be ignored: %s", arg) continue elif option.nargs == 0 and option.const is not None: # nargs == 0 & constr == True -> store_true # (we could also check the class, but it begins with an # underscore, so it would be ugly) # special case: "mpath=0" would otherwise set mpath to True if option.const is True and val in ("0", "no", "off"): setattr(namespace, option.dest, False) # Set all other set_const cases to the const specified else: setattr(namespace, option.dest, option.const) # anaconda considers cases such as noselinux=off to be a negative # concord, which is to say that selinux will be set to False and # we hate you. continue elif type(val) is list: for item in val: option(self, namespace, item) continue option(self, namespace, val) return namespace