Revision 6c00b2c7 lib/rpc.py
b/lib/rpc.py | ||
---|---|---|
586 | 586 |
result["spindles_free"] = lvm_pv_info["storage_free"] |
587 | 587 |
result["spindles_total"] = lvm_pv_info["storage_size"] |
588 | 588 |
else: |
589 |
raise errors.OpExecError("No spindle storage information available.") |
|
589 |
result["spindles_free"] = 0 |
|
590 |
result["spindles_total"] = 0 |
|
590 | 591 |
|
591 | 592 |
|
592 |
def _AddDefaultStorageInfoToLegacyNodeInfo(result, space_info): |
|
593 |
"""Extracts the storage space information of the default storage type from |
|
593 |
def _AddStorageInfoToLegacyNodeInfoByTemplate( |
|
594 |
result, space_info, disk_template): |
|
595 |
"""Extracts the storage space information of the disk template from |
|
594 | 596 |
the space info and adds it to the result dictionary. |
595 | 597 |
|
596 | 598 |
@see: C{_AddSpindlesToLegacyNodeInfo} for parameter information. |
597 | 599 |
|
598 | 600 |
""" |
599 |
# Check if there is at least one row for non-spindle storage info. |
|
600 |
no_defaults = (len(space_info) < 1) or \ |
|
601 |
(space_info[0]["type"] == constants.ST_LVM_PV and len(space_info) == 1) |
|
602 |
|
|
603 |
default_space_info = None |
|
604 |
if no_defaults: |
|
605 |
logging.warning("No storage info provided for default storage type.") |
|
601 |
if utils.storage.DiskTemplateSupportsSpaceReporting(disk_template): |
|
602 |
disk_info = utils.storage.LookupSpaceInfoByDiskTemplate( |
|
603 |
space_info, disk_template) |
|
604 |
result["name"] = disk_info["name"] |
|
605 |
result["storage_free"] = disk_info["storage_free"] |
|
606 |
result["storage_size"] = disk_info["storage_size"] |
|
606 | 607 |
else: |
607 |
default_space_info = space_info[0] |
|
608 |
|
|
609 |
if default_space_info: |
|
610 |
result["name"] = default_space_info["name"] |
|
611 |
result["storage_free"] = default_space_info["storage_free"] |
|
612 |
result["storage_size"] = default_space_info["storage_size"] |
|
608 |
# FIXME: consider displaying '-' in this case |
|
609 |
result["storage_free"] = 0 |
|
610 |
result["storage_size"] = 0 |
|
613 | 611 |
|
614 | 612 |
|
615 |
def MakeLegacyNodeInfo(data, require_spindles=False):
|
|
613 |
def MakeLegacyNodeInfo(data, disk_template):
|
|
616 | 614 |
"""Formats the data returned by L{rpc.RpcRunner.call_node_info}. |
617 | 615 |
|
618 | 616 |
Converts the data into a single dictionary. This is fine for most use cases, |
619 | 617 |
but some require information from more than one volume group or hypervisor. |
620 | 618 |
|
621 |
@param require_spindles: add spindle storage information to the legacy node |
|
622 |
info |
|
623 |
|
|
624 | 619 |
""" |
625 | 620 |
(bootid, space_info, (hv_info, )) = data |
626 | 621 |
|
627 | 622 |
ret = utils.JoinDisjointDicts(hv_info, {"bootid": bootid}) |
628 | 623 |
|
629 |
if require_spindles: |
|
630 |
_AddSpindlesToLegacyNodeInfo(ret, space_info) |
|
631 |
_AddDefaultStorageInfoToLegacyNodeInfo(ret, space_info) |
|
624 |
_AddSpindlesToLegacyNodeInfo(ret, space_info) |
|
625 |
_AddStorageInfoToLegacyNodeInfoByTemplate(ret, space_info, disk_template) |
|
632 | 626 |
|
633 | 627 |
return ret |
634 | 628 |
|
Also available in: Unified diff