Revision 84d7e26b lib/backend.py

b/lib/backend.py
77 77
_IES_CA_FILE = "ca"
78 78

  
79 79
#: Valid LVS output line regex
80
_LVSLINE_REGEX = re.compile("^ *([^|]+)\|([0-9.]+)\|([^|]{6})\|?$")
80
_LVSLINE_REGEX = re.compile("^ *([^|]+)\|([^|]+)\|([0-9.]+)\|([^|]{6})\|?$")
81 81

  
82 82

  
83 83
class RPCFail(Exception):
......
554 554

  
555 555
  if constants.NV_LVLIST in what and vm_capable:
556 556
    try:
557
      val = GetVolumeList(what[constants.NV_LVLIST])
557
      val = GetVolumeList(utils.ListVolumeGroups().keys())
558 558
    except RPCFail, err:
559 559
      val = str(err)
560 560
    result[constants.NV_LVLIST] = val
......
622 622
  return result
623 623

  
624 624

  
625
def GetVolumeList(vg_name):
625
def GetVolumeList(vg_names):
626 626
  """Compute list of logical volumes and their size.
627 627

  
628
  @type vg_name: str
629
  @param vg_name: the volume group whose LVs we should list
628
  @type vg_names: list
629
  @param vg_names: the volume groups whose LVs we should list
630 630
  @rtype: dict
631 631
  @return:
632 632
      dictionary of all partions (key) with value being a tuple of
633 633
      their size (in MiB), inactive and online status::
634 634

  
635
        {'test1': ('20.06', True, True)}
635
        {'xenvg/test1': ('20.06', True, True)}
636 636

  
637 637
      in case of errors, a string is returned with the error
638 638
      details.
......
642 642
  sep = '|'
643 643
  result = utils.RunCmd(["lvs", "--noheadings", "--units=m", "--nosuffix",
644 644
                         "--separator=%s" % sep,
645
                         "-olv_name,lv_size,lv_attr", vg_name])
645
                         "-ovg_name,lv_name,lv_size,lv_attr"] + vg_names)
646 646
  if result.failed:
647 647
    _Fail("Failed to list logical volumes, lvs output: %s", result.output)
648 648

  
......
652 652
    if not match:
653 653
      logging.error("Invalid line returned from lvs output: '%s'", line)
654 654
      continue
655
    name, size, attr = match.groups()
655
    vg_name, name, size, attr = match.groups()
656 656
    inactive = attr[4] == '-'
657 657
    online = attr[5] == 'o'
658 658
    virtual = attr[0] == 'v'
......
660 660
      # we don't want to report such volumes as existing, since they
661 661
      # don't really hold data
662 662
      continue
663
    lvs[name] = (size, inactive, online)
663
    lvs[vg_name+"/"+name] = (size, inactive, online)
664 664

  
665 665
  return lvs
666 666

  

Also available in: Unified diff