[PATCH][f21] Fix handling of md fwraid names in kickstart bootloader command. (#1156354)

Anne Mulhern amulhern at redhat.com
Fri Oct 24 22:44:57 UTC 2014





----- Original Message -----
> From: "David Lehman" <dlehman at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Friday, October 24, 2014 5:33:30 PM
> Subject: [PATCH][f21] Fix handling of md fwraid names in kickstart bootloader	command. (#1156354)
> 
> udev.resolve_devspec cannot resolve md names.
> blivet.DeviceTree.resolveDevice can.
> ---
>  pyanaconda/kickstart.py | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
> index 39f5086..f75c530 100644
> --- a/pyanaconda/kickstart.py
> +++ b/pyanaconda/kickstart.py
> @@ -171,14 +171,31 @@ def getEscrowCertificate(escrowCerts, url):
>  
>      return escrowCerts[url]
>  
> -def deviceMatches(spec):
> +def deviceMatches(spec, devicetree=None):
> +    """ Return names of block devices matching the provided specification.
> +
> +        :param str spec: a device identifier (name, UUID=<uuid>, &c)
> +        :keyword devicetree: device tree to look up devices in (optional)
> +        :type devicetree: :class:`blivet.DeviceTree`

Please add rtype here, probably list of str.

> +
> +        parse methods will not have access to a devicetree, while execute
> +        methods will. The devicetree is superior in that it can resolve md
> +        array names and in that it reflects scheduled device removals, but
> for
> +        normal local disks udev.resolve_devspec should suffice.
> +    """
>      full_spec = spec
>      if not full_spec.startswith("/dev/"):
>          full_spec = os.path.normpath("/dev/" + full_spec)
>  
>      # the regular case
>      matches = udev.resolve_glob(full_spec)
> -    dev = udev.resolve_devspec(full_spec)
> +
> +    if devicetree is None:
> +        dev = udev.resolve_devspec(spec)
> +    else:
> +        # using spec here intentionally instead of full_spec

Can the comment here explain why?

> +        dev = getattr(devicetree.resolveDevice(spec), "name", None)
> +
>      # udev.resolve_devspec returns None if there's no match, but we don't
>      # want that ending up in the list.
>      if dev and dev not in matches:
> @@ -366,7 +383,7 @@ class Bootloader(commands.bootloader.F21_Bootloader):
>          diskSet = set(disk_names)
>  
>          for drive in self.driveorder[:]:
> -            matches = set(deviceMatches(drive))
> +            matches = set(deviceMatches(drive,
> devicetree=storage.devicetree))
>              if matches.isdisjoint(diskSet):
>                  log.warning("requested drive %s in boot drive order doesn't
>                  exist or cannot be used", drive)
>                  self.driveorder.remove(drive)
> @@ -374,7 +391,8 @@ class Bootloader(commands.bootloader.F21_Bootloader):
>          storage.bootloader.disk_order = self.driveorder
>  
>          if self.bootDrive:
> -            matches = set(deviceMatches(self.bootDrive))
> +            matches = set(deviceMatches(self.bootDrive,
> +                                        devicetree=storage.devicetree))
>              if len(matches) > 1:
>                  raise KickstartValueError(formatErrorMsg(self.lineno,
>                          msg=_("More than one match found for given boot
>                          drive \"%s\".") % self.bootDrive))
> --
> 1.9.3
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

- mulhern


More information about the anaconda-patches mailing list