Revision a1860404

b/lib/backend.py
592 592
    }
593 593

  
594 594

  
595
def _GetVgSpindlesInfo(name, excl_stor):
596
  """Retrieves information about spindles in an LVM volume group.
597

  
598
  @type name: string
599
  @param name: VG name
600
  @type excl_stor: bool
601
  @param excl_stor: exclusive storage
602
  @rtype: dict
603
  @return: dictionary whose keys are "name", "vg_free", "vg_size" for VG name,
604
      free spindles, total spindles respectively
605

  
606
  """
607
  if excl_stor:
608
    (vg_free, vg_size) = bdev.LogicalVolume.GetVgSpindlesInfo(name)
609
  else:
610
    vg_free = 0
611
    vg_size = 0
612
  return {
613
    "name": name,
614
    "vg_free": vg_free,
615
    "vg_size": vg_size,
616
    }
617

  
618

  
595 619
def _GetHvInfo(name):
596 620
  """Retrieves node information from a hypervisor.
597 621

  
......
653 677
  constants.ST_DISKLESS: None,
654 678
  constants.ST_EXT: None,
655 679
  constants.ST_FILE: None,
680
  constants.ST_LVM_PV: _GetVgSpindlesInfo,
656 681
  constants.ST_LVM_VG: _GetVgInfo,
657 682
  constants.ST_RADOS: None,
658 683
}
b/lib/storage/bdev.py
407 407
    return data
408 408

  
409 409
  @classmethod
410
  def _GetRawFreePvInfo(cls, vg_name):
411
    """Return info (size/free) about PVs.
412

  
413
    @type vg_name: string
414
    @param vg_name: VG name
415
    @rtype: tuple
416
    @return: (standard_pv_size_in_MiB, number_of_free_pvs, total_number_of_pvs)
417

  
418
    """
419
    pvs_info = cls.GetPVInfo([vg_name])
420
    if not pvs_info:
421
      pv_size = 0.0
422
      free_pvs = 0
423
      num_pvs = 0
424
    else:
425
      pv_size = cls._GetStdPvSize(pvs_info)
426
      free_pvs = len(cls._GetEmptyPvNames(pvs_info))
427
      num_pvs = len(pvs_info)
428
    return (pv_size, free_pvs, num_pvs)
429

  
430
  @classmethod
410 431
  def _GetExclusiveStorageVgFree(cls, vg_name):
411 432
    """Return the free disk space in the given VG, in exclusive storage mode.
412 433

  
......
415 436
    @rtype: float
416 437
    @return: free space in MiB
417 438
    """
418
    pvs_info = cls.GetPVInfo([vg_name])
419
    if not pvs_info:
420
      return 0.0
421
    pv_size = cls._GetStdPvSize(pvs_info)
422
    num_pvs = len(cls._GetEmptyPvNames(pvs_info))
423
    return pv_size * num_pvs
439
    (pv_size, free_pvs, _) = cls._GetRawFreePvInfo(vg_name)
440
    return pv_size * free_pvs
441

  
442
  @classmethod
443
  def GetVgSpindlesInfo(cls, vg_name):
444
    """Get the free space info for specific VGs.
445

  
446
    @param vg_name: volume group name
447
    @rtype: tuple
448
    @return: (free_spindles, total_spindles)
449

  
450
    """
451
    (_, free_pvs, num_pvs) = cls._GetRawFreePvInfo(vg_name)
452
    return (free_pvs, num_pvs)
424 453

  
425 454
  @classmethod
426 455
  def GetVGInfo(cls, vg_names, excl_stor, filter_readonly=True):

Also available in: Unified diff