Revision 701384a9
b/lib/cmdlib.py | ||
---|---|---|
3801 | 3801 |
errors.ECODE_NORES) |
3802 | 3802 |
|
3803 | 3803 |
|
3804 |
def _CheckNodesFreeDisk(lu, nodenames, requested): |
|
3805 |
"""Checks if nodes have enough free disk space in the default VG. |
|
3806 |
|
|
3807 |
This function check if all given nodes have the needed amount of |
|
3808 |
free disk. In case any node has less disk or we cannot get the |
|
3809 |
information from the node, this function raise an OpPrereqError |
|
3810 |
exception. |
|
3811 |
|
|
3812 |
@type lu: C{LogicalUnit} |
|
3813 |
@param lu: a logical unit from which we get configuration data |
|
3814 |
@type nodenames: C{list} |
|
3815 |
@param node: the list of node names to check |
|
3816 |
@type requested: C{int} |
|
3817 |
@param requested: the amount of disk in MiB to check for |
|
3818 |
@raise errors.OpPrereqError: if the node doesn't have enough disk, or |
|
3819 |
we cannot check the node |
|
3820 |
|
|
3821 |
""" |
|
3822 |
nodeinfo = lu.rpc.call_node_info(nodenames, lu.cfg.GetVGName(), |
|
3823 |
lu.cfg.GetHypervisorType()) |
|
3824 |
for node in nodenames: |
|
3825 |
info = nodeinfo[node] |
|
3826 |
info.Raise("Cannot get current information from node %s" % node, |
|
3827 |
prereq=True, ecode=errors.ECODE_ENVIRON) |
|
3828 |
vg_free = info.payload.get("vg_free", None) |
|
3829 |
if not isinstance(vg_free, int): |
|
3830 |
raise errors.OpPrereqError("Can't compute free disk space on node %s," |
|
3831 |
" result was '%s'" % (node, vg_free), |
|
3832 |
errors.ECODE_ENVIRON) |
|
3833 |
if requested > vg_free: |
|
3834 |
raise errors.OpPrereqError("Not enough disk space on target node %s:" |
|
3835 |
" required %d MiB, available %d MiB" % |
|
3836 |
(node, requested, vg_free), |
|
3837 |
errors.ECODE_NORES) |
|
3838 |
|
|
3839 |
|
|
3804 | 3840 |
class LUStartupInstance(LogicalUnit): |
3805 | 3841 |
"""Starts an instance. |
3806 | 3842 |
|
... | ... | |
6263 | 6299 |
|
6264 | 6300 |
# Check lv size requirements, if not adopting |
6265 | 6301 |
if req_size is not None and not self.adopt_disks: |
6266 |
nodeinfo = self.rpc.call_node_info(nodenames, self.cfg.GetVGName(), |
|
6267 |
self.op.hypervisor) |
|
6268 |
for node in nodenames: |
|
6269 |
info = nodeinfo[node] |
|
6270 |
info.Raise("Cannot get current information from node %s" % node) |
|
6271 |
info = info.payload |
|
6272 |
vg_free = info.get('vg_free', None) |
|
6273 |
if not isinstance(vg_free, int): |
|
6274 |
raise errors.OpPrereqError("Can't compute free disk space on" |
|
6275 |
" node %s" % node, errors.ECODE_ENVIRON) |
|
6276 |
if req_size > vg_free: |
|
6277 |
raise errors.OpPrereqError("Not enough disk space on target node %s." |
|
6278 |
" %d MB available, %d MB required" % |
|
6279 |
(node, vg_free, req_size), |
|
6280 |
errors.ECODE_NORES) |
|
6302 |
_CheckNodesFreeDisk(self, nodenames, req_size) |
|
6281 | 6303 |
|
6282 | 6304 |
if self.adopt_disks: # instead, we must check the adoption data |
6283 | 6305 |
all_lvs = set([i["adopt"] for i in self.disks]) |
... | ... | |
7534 | 7556 |
|
7535 | 7557 |
self.disk = instance.FindDisk(self.op.disk) |
7536 | 7558 |
|
7537 |
nodeinfo = self.rpc.call_node_info(nodenames, self.cfg.GetVGName(), |
|
7538 |
instance.hypervisor) |
|
7539 |
for node in nodenames: |
|
7540 |
info = nodeinfo[node] |
|
7541 |
info.Raise("Cannot get current information from node %s" % node) |
|
7542 |
vg_free = info.payload.get('vg_free', None) |
|
7543 |
if not isinstance(vg_free, int): |
|
7544 |
raise errors.OpPrereqError("Can't compute free disk space on" |
|
7545 |
" node %s" % node, errors.ECODE_ENVIRON) |
|
7546 |
if self.op.amount > vg_free: |
|
7547 |
raise errors.OpPrereqError("Not enough disk space on target node %s:" |
|
7548 |
" %d MiB available, %d MiB required" % |
|
7549 |
(node, vg_free, self.op.amount), |
|
7550 |
errors.ECODE_NORES) |
|
7559 |
_CheckNodesFreeDisk(self, nodenames, self.op.amount) |
|
7551 | 7560 |
|
7552 | 7561 |
def Exec(self, feedback_fn): |
7553 | 7562 |
"""Execute disk grow. |
Also available in: Unified diff