Revision 6180d6bb

b/lib/cmdlib.py
4767 4767
                                 errors.ECODE_NORES)
4768 4768

  
4769 4769

  
4770
def _CheckNodesFreeDisk(lu, nodenames, requested):
4771
  """Checks if nodes have enough free disk space in the default VG.
4772

  
4773
  This function check if all given nodes have the needed amount of
4774
  free disk. In case any node has less disk or we cannot get the
4775
  information from the node, this function raise an OpPrereqError
4776
  exception.
4777

  
4778
  @type lu: C{LogicalUnit}
4779
  @param lu: a logical unit from which we get configuration data
4780
  @type nodenames: C{list}
4781
  @param nodenames: the list of node names to check
4782
  @type requested: C{int}
4783
  @param requested: the amount of disk in MiB to check for
4784
  @raise errors.OpPrereqError: if the node doesn't have enough disk, or
4785
      we cannot check the node
4786

  
4787
  """
4788
  nodeinfo = lu.rpc.call_node_info(nodenames, lu.cfg.GetVGName(),
4789
                                   lu.cfg.GetHypervisorType())
4790
  for node in nodenames:
4791
    info = nodeinfo[node]
4792
    info.Raise("Cannot get current information from node %s" % node,
4793
               prereq=True, ecode=errors.ECODE_ENVIRON)
4794
    vg_free = info.payload.get("vg_free", None)
4795
    if not isinstance(vg_free, int):
4796
      raise errors.OpPrereqError("Can't compute free disk space on node %s,"
4797
                                 " result was '%s'" % (node, vg_free),
4798
                                 errors.ECODE_ENVIRON)
4799
    if requested > vg_free:
4800
      raise errors.OpPrereqError("Not enough disk space on target node %s:"
4801
                                 " required %d MiB, available %d MiB" %
4802
                                 (node, requested, vg_free),
4803
                                 errors.ECODE_NORES)
4804

  
4805

  
4806 4770
class LUStartupInstance(LogicalUnit):
4807 4771
  """Starts an instance.
4808 4772

  

Also available in: Unified diff