Revision 11aa3ca5 lib/masterd/iallocator.py
b/lib/masterd/iallocator.py | ||
---|---|---|
544 | 544 |
return value |
545 | 545 |
|
546 | 546 |
@staticmethod |
547 |
def _ComputeStorageData(node_info, node_name, has_lvm): |
|
548 |
"""Extract storage data from the node info.
|
|
547 |
def _ComputeStorageDataFromNodeInfo(node_info, node_name, has_lvm):
|
|
548 |
"""Extract storage data from node info (_not_ legacy node info).
|
|
549 | 549 |
|
550 |
@type node_info: see result of RPC call 'node info'
|
|
551 |
@param node_info: the node's live information
|
|
550 |
@type node_info: see result of the RPC call node info
|
|
551 |
@param node_info: the result of the RPC call node info
|
|
552 | 552 |
@type node_name: string |
553 | 553 |
@param node_name: the node's name |
554 | 554 |
@type has_lvm: boolean |
555 |
@param has_lvm: whether or not lvm storage info was requested
|
|
555 |
@param has_lvm: whether or not LVM storage information is requested
|
|
556 | 556 |
@rtype: 4-tuple of integers |
557 | 557 |
@return: tuple of storage info (total_disk, free_disk, total_spindles, |
558 | 558 |
free_spindles) |
559 | 559 |
|
560 | 560 |
""" |
561 |
(_, space_info, _) = node_info |
|
561 | 562 |
# TODO: replace this with proper storage reporting |
562 | 563 |
if has_lvm: |
563 |
total_disk = IAllocator._GetAttributeFromNodeData(node_info, node_name, |
|
564 |
"storage_size") |
|
565 |
free_disk = IAllocator._GetAttributeFromNodeData(node_info, node_name, |
|
566 |
"storage_free") |
|
567 |
total_spindles = IAllocator._GetAttributeFromNodeData( |
|
568 |
node_info, node_name, "spindles_total") |
|
569 |
free_spindles = IAllocator._GetAttributeFromNodeData( |
|
570 |
node_info, node_name, "spindles_free") |
|
564 |
lvm_vg_info = utils.storage.LookupSpaceInfoByStorageType( |
|
565 |
space_info, constants.ST_LVM_VG) |
|
566 |
if not lvm_vg_info: |
|
567 |
raise errors.OpExecError("Node '%s' didn't return LVM vg space info." |
|
568 |
% (node_name)) |
|
569 |
total_disk = lvm_vg_info["storage_size"] |
|
570 |
free_disk = lvm_vg_info["storage_free"] |
|
571 |
lvm_pv_info = utils.storage.LookupSpaceInfoByStorageType( |
|
572 |
space_info, constants.ST_LVM_PV) |
|
573 |
if not lvm_vg_info: |
|
574 |
raise errors.OpExecError("Node '%s' didn't return LVM pv space info." |
|
575 |
% (node_name)) |
|
576 |
total_spindles = lvm_pv_info["storage_size"] |
|
577 |
free_spindles = lvm_pv_info["storage_free"] |
|
571 | 578 |
else: |
572 | 579 |
# we didn't even ask the node for VG status, so use zeros |
573 | 580 |
total_disk = free_disk = 0 |
... | ... | |
615 | 622 |
i_p_up_mem += beinfo[constants.BE_MAXMEM] |
616 | 623 |
|
617 | 624 |
(total_disk, free_disk, total_spindles, free_spindles) = \ |
618 |
self._ComputeStorageData(remote_info, ninfo.name, has_lvm) |
|
625 |
self._ComputeStorageDataFromNodeInfo(nresult.payload, ninfo.name, |
|
626 |
has_lvm) |
|
619 | 627 |
|
620 | 628 |
# compute memory used by instances |
621 | 629 |
pnr_dyn = { |
Also available in: Unified diff