Revision 59726e15 lib/bdev.py

b/lib/bdev.py
537 537
    pvs_info = cls.GetPVInfo([vg_name])
538 538
    if not pvs_info:
539 539
      _ThrowError("Can't compute PV info for vg %s", vg_name)
540
    pvs_info.sort()
541
    pvs_info.reverse()
540
    pvs_info.sort(key=(lambda pv: pv.free), reverse=True)
542 541

  
543
    pvlist = [pv[1] for pv in pvs_info]
542
    pvlist = [pv.name for pv in pvs_info]
544 543
    if compat.any(":" in v for v in pvlist):
545 544
      _ThrowError("Some of your PVs have the invalid character ':' in their"
546 545
                  " name, this is not supported - please filter them out"
547 546
                  " in lvm.conf using either 'filter' or 'preferred_names'")
548
    free_size = sum([pv[0] for pv in pvs_info])
547
    free_size = sum([pv.free for pv in pvs_info])
549 548
    current_pvs = len(pvlist)
550 549
    desired_stripes = params[constants.LDP_STRIPES]
551 550
    stripes = min(current_pvs, desired_stripes)
......
613 612
    @param filter_allocatable: whether to skip over unallocatable PVs
614 613

  
615 614
    @rtype: list
616
    @return: list of tuples (free_space, name) with free_space in mebibytes
615
    @return: list of objects.LvmPvInfo objects
617 616

  
618 617
    """
619 618
    try:
620 619
      info = cls._GetVolumeInfo("pvs", ["pv_name", "vg_name", "pv_free",
621
                                        "pv_attr"])
620
                                        "pv_attr", "pv_size"])
622 621
    except errors.GenericError, err:
623 622
      logging.error("Can't get PV information: %s", err)
624 623
      return None
625 624

  
626 625
    data = []
627
    for pv_name, vg_name, pv_free, pv_attr in info:
626
    for (pv_name, vg_name, pv_free, pv_attr, pv_size) in info:
628 627
      # (possibly) skip over pvs which are not allocatable
629 628
      if filter_allocatable and pv_attr[0] != "a":
630 629
        continue
631 630
      # (possibly) skip over pvs which are not in the right volume group(s)
632 631
      if vg_names and vg_name not in vg_names:
633 632
        continue
634
      data.append((float(pv_free), pv_name, vg_name))
633
      pvi = objects.LvmPvInfo(name=pv_name, vg_name=vg_name,
634
                              size=float(pv_size), free=float(pv_free),
635
                              attributes=pv_attr)
636
      data.append(pvi)
635 637

  
636 638
    return data
637 639

  

Also available in: Unified diff