Revision 439e1d3f lib/backend.py
b/lib/backend.py | ||
---|---|---|
616 | 616 |
} |
617 | 617 |
|
618 | 618 |
|
619 |
def _GetHvInfo(name): |
|
619 |
def _GetHvInfo(name, hvparams, get_hv_fn=hypervisor.GetHypervisor):
|
|
620 | 620 |
"""Retrieves node information from a hypervisor. |
621 | 621 |
|
622 | 622 |
The information returned depends on the hypervisor. Common items: |
... | ... | |
628 | 628 |
- memory_total is the total number of ram in MiB |
629 | 629 |
- hv_version: the hypervisor version, if available |
630 | 630 |
|
631 |
@type hvparams: dict of string |
|
632 |
@param hvparams: the hypervisor's hvparams |
|
633 |
|
|
631 | 634 |
""" |
632 |
return hypervisor.GetHypervisor(name).GetNodeInfo() |
|
635 |
return get_hv_fn(name).GetNodeInfo(hvparams=hvparams) |
|
636 |
|
|
637 |
|
|
638 |
def _GetHvInfoAll(hv_specs, get_hv_fn=hypervisor.GetHypervisor): |
|
639 |
"""Retrieves node information for all hypervisors. |
|
640 |
|
|
641 |
See C{_GetHvInfo} for information on the output. |
|
642 |
|
|
643 |
@type hv_specs: list of pairs (string, dict of strings) |
|
644 |
@param hv_specs: list of pairs of a hypervisor's name and its hvparams |
|
645 |
|
|
646 |
""" |
|
647 |
if hv_specs is None: |
|
648 |
return None |
|
649 |
|
|
650 |
# FIXME: remove this fallback once all calls to call_node_info are fixed |
|
651 |
if (len(hv_specs) > 0) and isinstance(hv_specs[0], str): |
|
652 |
result = [] |
|
653 |
for hvname in hv_specs: |
|
654 |
result.append(_GetHvInfo(hvname, None, get_hv_fn)) |
|
655 |
return result |
|
656 |
|
|
657 |
result = [] |
|
658 |
for hvname, hvparams in hv_specs: |
|
659 |
result.append(_GetHvInfo(hvname, hvparams, get_hv_fn)) |
|
660 |
return result |
|
633 | 661 |
|
634 | 662 |
|
635 | 663 |
def _GetNamedNodeInfo(names, fn): |
... | ... | |
644 | 672 |
return map(fn, names) |
645 | 673 |
|
646 | 674 |
|
647 |
def GetNodeInfo(storage_units, hv_names, excl_stor):
|
|
675 |
def GetNodeInfo(storage_units, hv_specs, excl_stor):
|
|
648 | 676 |
"""Gives back a hash with different information about the node. |
649 | 677 |
|
650 | 678 |
@type storage_units: list of pairs (string, string) |
651 | 679 |
@param storage_units: List of pairs (storage unit, identifier) to ask for disk |
652 | 680 |
space information. In case of lvm-vg, the identifier is |
653 | 681 |
the VG name. |
654 |
@type hv_names: list of string
|
|
655 |
@param hv_names: Names of the hypervisors to ask for node information
|
|
682 |
@type hv_specs: list of pairs (string, dict of strings)
|
|
683 |
@param hv_specs: list of pairs of a hypervisor's name and its hvparams
|
|
656 | 684 |
@type excl_stor: boolean |
657 | 685 |
@param excl_stor: Whether exclusive_storage is active |
658 | 686 |
@rtype: tuple; (string, None/dict, None/dict) |
... | ... | |
666 | 694 |
(lambda storage_unit: _ApplyStorageInfoFunction(storage_unit[0], |
667 | 695 |
storage_unit[1], |
668 | 696 |
excl_stor))) |
669 |
hv_info = _GetNamedNodeInfo(hv_names, _GetHvInfo) |
|
670 |
|
|
697 |
hv_info = _GetHvInfoAll(hv_specs) |
|
671 | 698 |
return (bootid, storage_info, hv_info) |
672 | 699 |
|
673 | 700 |
|
Also available in: Unified diff