Revision c31ec06b lib/storage/bdev.py

b/lib/storage/bdev.py
753 753

  
754 754
    _CheckResult(utils.RunCmd(["lvchange", "--addtag", text, self.dev_path]))
755 755

  
756
  def _GetGrowthAvaliabilityExclStor(self):
757
    """Return how much the disk can grow with exclusive storage.
758

  
759
    @rtype: float
760
    @return: available space in Mib
761

  
762
    """
763
    pvs_info = self.GetPVInfo([self._vg_name])
764
    if not pvs_info:
765
      base.ThrowError("Cannot get information about PVs for %s", self.dev_path)
766
    std_pv_size = self._GetStdPvSize(pvs_info)
767
    free_space = sum(pvi.free - (pvi.size - std_pv_size)
768
                        for pvi in pvs_info
769
                        if pvi.name in self.pv_names)
770
    return free_space
771

  
756 772
  def Grow(self, amount, dryrun, backingstore, excl_stor):
757 773
    """Grow the logical volume.
758 774

  
......
772 788
    if dryrun:
773 789
      cmd.append("--test")
774 790
    if excl_stor:
791
      free_space = self._GetGrowthAvaliabilityExclStor()
792
      # amount is in KiB, free_space in MiB
793
      if amount > free_space * 1024:
794
        base.ThrowError("Not enough free space to grow %s: %d MiB required,"
795
                        " %d available", self.dev_path, amount / 1024,
796
                        free_space)
775 797
      # Disk growth doesn't grow the number of spindles, so we must stay within
776 798
      # our assigned volumes
777 799
      pvlist = list(self.pv_names)

Also available in: Unified diff