예제 #1
0
def run_grubby(args=None):
    """ Run grubby and retrieve the kernel, initrd and boot arguments

        :param list args: Arguments to pass to grubby.
        :returns: kernel path, initrd path, root device, kernel cmdline args.
        :rtype: namedtuple
        :raises: some error on failure

        The returned namedtuple contains the following attributes:
            kernel, initrd, root, args
    """
    boot_info_fields = ["kernel", "initrd", "root", "args"]
    boot_info_class = namedtuple("BootInfo", boot_info_fields)
    boot_info_args = {}

    if not args:
        args = ["--info", "DEFAULT"]

    # Run grubby and fill in the boot_info with the first values seen, exit the
    # loop when all of the needed values have been gathered.
    try:

        for line in execReadlines("grubby", args,
                                  root=conf.target.system_root):
            key, _sep, value = line.partition("=")
            value = unquote(value)

            if key in boot_info_fields:
                boot_info_args[key] = value
                boot_info_fields.remove(key)

            if not boot_info_fields:
                break
    except OSError as e:
        log.error("run_grubby failed: %s", e)
        raise GrubbyInfoError(e)

    if boot_info_fields:
        raise GrubbyInfoError("Missing values: %s" %
                              ", ".join(boot_info_fields))

    # There could be multiple initrd images defined for a boot entry, but
    # the kexec command line tool only supports passing a single initrd.
    if "initrd" in boot_info_args:
        boot_info_args["initrd"] = boot_info_args["initrd"].split(" ")[0]

    boot_info = boot_info_class(**boot_info_args)
    log.info("grubby boot info for (%s): %s", args, boot_info)
    return boot_info
예제 #2
0
파일: kexec.py 프로젝트: rvykydal/anaconda
def run_grubby(args=None):
    """ Run grubby and retrieve the kernel, initrd and boot arguments

        :param list args: Arguments to pass to grubby.
        :returns: kernel path, initrd path, root device, kernel cmdline args.
        :rtype: namedtuple
        :raises: some error on failure

        The returned namedtuple contains the following attributes:
            kernel, initrd, root, args
    """
    boot_info_fields = ["kernel", "initrd", "root", "args"]
    boot_info_class = namedtuple("BootInfo", boot_info_fields)
    boot_info_args = {}

    if not args:
        args = ["--info", "DEFAULT"]

    # Run grubby and fill in the boot_info with the first values seen, exit the
    # loop when all of the needed values have been gathered.
    try:

        for line in execReadlines("grubby", args, root=getSysroot()):
            key, _sep, value = line.partition("=")
            value = unquote(value)

            if key in boot_info_fields:
                boot_info_args[key] = value
                boot_info_fields.remove(key)

            if not boot_info_fields:
                break
    except OSError as e:
        log.error("run_grubby failed: %s", e)
        raise GrubbyInfoError(e)

    if boot_info_fields:
        raise GrubbyInfoError("Missing values: %s" % ", ".join(boot_info_fields))

    boot_info = boot_info_class(**boot_info_args)
    log.info("grubby boot info for (%s): %s", args, boot_info)
    return boot_info
예제 #3
0
파일: kexec.py 프로젝트: yaneti/anaconda
def run_grubby(args=None):
    """ Run grubby and retrieve the kernel, initrd and boot arguments

        :param list args: Arguments to pass to grubby.
        :returns: kernel path, initrd path, root device, kernel cmdline args.
        :rtype: namedtuple
        :raises: some error on failure

        The returned namedtuple contains the following attributes:
            kernel, initrd, root, args
    """
    boot_info = _BootInfo()
    attrs = list(_BootInfo._fields)

    if not args:
        args = ["--info", "DEFAULT"]

    # Run grubby and fill in the boot_info with the first values seen, exit the
    # loop when all of the needed values have been gathered.
    try:

        for line in execReadlines("grubby", args, root=getSysroot()):
            key, _sep, value = line.partition("=")
            value = unquote(value)
            if key in attrs:
                setattr(boot_info, key, value)
                attrs.remove(key)
            if not attrs:
                break
    except OSError as e:
        log.error("run_grubby failed: %s", e)
        raise GrubbyInfoError(e)

    if len(attrs) > 0:
        raise GrubbyInfoError("Missing values: %s" % ", ".join(attrs))

    log.info("grubby boot info for (%s): %s", args, boot_info)
    return boot_info
예제 #4
0
 def unquote_test(self):
     self.assertEqual(simpleconfig.unquote("plain string"), "plain string")
     self.assertEqual(simpleconfig.unquote('"double quote"'), "double quote")
     self.assertEqual(simpleconfig.unquote("'single quote'"), "single quote")
 def unquote_test(self):
     self.assertEqual(simpleconfig.unquote("plain string"), "plain string")
     self.assertEqual(simpleconfig.unquote('"double quote"'), "double quote")
     self.assertEqual(simpleconfig.unquote("'single quote'"), "single quote")
예제 #6
0
 def unquote_test(self):
     from pyanaconda.simpleconfig import unquote
     self.assertEqual(unquote("plain string"), "plain string")
     self.assertEqual(unquote('"double quote"'), "double quote")
     self.assertEqual(unquote("'single quote'"), "single quote")
예제 #7
0
 def unquote_test(self):
     from pyanaconda.simpleconfig import unquote
     self.assertEqual(unquote("plain string"), "plain string")
     self.assertEqual(unquote('"double quote"'), "double quote")
     self.assertEqual(unquote("'single quote'"), "single quote")
예제 #8
0
 def test_unquote(self):
     assert simpleconfig.unquote("plain string") == "plain string"
     assert simpleconfig.unquote('"double quote"') == "double quote"
     assert simpleconfig.unquote("'single quote'") == "single quote"