Revision 152759e4
b/lib/backend.py | ||
---|---|---|
668 | 668 |
return map(fn, names) |
669 | 669 |
|
670 | 670 |
|
671 |
def GetNodeInfo(storage_units, hv_specs, excl_stor):
|
|
671 |
def GetNodeInfo(storage_units, hv_specs): |
|
672 | 672 |
"""Gives back a hash with different information about the node. |
673 | 673 |
|
674 |
@type storage_units: list of pairs (string, string) |
|
675 |
@param storage_units: List of pairs (storage unit, identifier) to ask for disk |
|
676 |
space information. In case of lvm-vg, the identifier is |
|
677 |
the VG name. |
|
674 |
@type storage_units: list of tuples (string, string, list) |
|
675 |
@param storage_units: List of tuples (storage unit, identifier, parameters) to |
|
676 |
ask for disk space information. In case of lvm-vg, the identifier is |
|
677 |
the VG name. The parameters can contain additional, storage-type-specific |
|
678 |
parameters, for example exclusive storage for lvm storage. |
|
678 | 679 |
@type hv_specs: list of pairs (string, dict of strings) |
679 | 680 |
@param hv_specs: list of pairs of a hypervisor's name and its hvparams |
680 |
@type excl_stor: boolean |
|
681 |
@param excl_stor: Whether exclusive_storage is active |
|
682 | 681 |
@rtype: tuple; (string, None/dict, None/dict) |
683 | 682 |
@return: Tuple containing boot ID, volume group information and hypervisor |
684 | 683 |
information |
... | ... | |
687 | 686 |
bootid = utils.ReadFile(_BOOT_ID_PATH, size=128).rstrip("\n") |
688 | 687 |
storage_info = _GetNamedNodeInfo( |
689 | 688 |
storage_units, |
690 |
(lambda storage_unit: _ApplyStorageInfoFunction(storage_unit[0], |
|
691 |
storage_unit[1], |
|
692 |
excl_stor))) |
|
689 |
(lambda (storage_type, storage_key, storage_params): |
|
690 |
_ApplyStorageInfoFunction(storage_type, storage_key, storage_params))) |
|
693 | 691 |
hv_info = _GetHvInfoAll(hv_specs) |
694 | 692 |
return (bootid, storage_info, hv_info) |
695 | 693 |
|
b/lib/server/noded.py | ||
---|---|---|
724 | 724 |
"""Query node information. |
725 | 725 |
|
726 | 726 |
""" |
727 |
(storage_units, hv_specs, excl_stor) = params |
|
728 |
return backend.GetNodeInfo(storage_units, hv_specs, excl_stor) |
|
727 |
# FIXME: remove the fallback to excl_stor once all callers are |
|
728 |
# adjusted |
|
729 |
if (len(params) == 3): |
|
730 |
(legacy_storage_units, hv_specs, excl_stor) = params |
|
731 |
storage_units = NodeRequestHandler._ConvertExclStorage( |
|
732 |
legacy_storage_units, excl_stor) |
|
733 |
else: |
|
734 |
(storage_units, hv_specs) = params |
|
735 |
return backend.GetNodeInfo(storage_units, hv_specs) |
|
736 |
|
|
737 |
@staticmethod |
|
738 |
def _ConvertExclStorage(storage_units, excl_stor): |
|
739 |
result_units = [] |
|
740 |
for (storage_type, storage_key) in storage_units: |
|
741 |
if storage_type in [constants.ST_LVM_VG, constants.ST_LVM_PV]: |
|
742 |
result_units.append((storage_type, storage_key, [excl_stor])) |
|
743 |
else: |
|
744 |
result_units.append((storage_type, storage_key, [])) |
|
745 |
return result_units |
|
729 | 746 |
|
730 | 747 |
@staticmethod |
731 | 748 |
def perspective_etc_hosts_modify(params): |
b/test/py/ganeti.backend_unittest.py | ||
---|---|---|
655 | 655 |
_SOME_RESULT = None |
656 | 656 |
|
657 | 657 |
def testApplyStorageInfoFunction(self): |
658 |
excl_storage_flag = False |
|
659 | 658 |
backend._ApplyStorageInfoFunction = mock.Mock( |
660 | 659 |
return_value=self._SOME_RESULT) |
661 |
storage_units = [(st, st + "_key") for st in |
|
660 |
storage_units = [(st, st + "_key", [st + "_params"]) for st in
|
|
662 | 661 |
constants.VALID_STORAGE_TYPES] |
663 | 662 |
|
664 |
backend.GetNodeInfo(storage_units, None, excl_storage_flag)
|
|
663 |
backend.GetNodeInfo(storage_units, None) |
|
665 | 664 |
|
666 | 665 |
call_args_list = backend._ApplyStorageInfoFunction.call_args_list |
667 | 666 |
self.assertEqual(len(constants.VALID_STORAGE_TYPES), len(call_args_list)) |
668 | 667 |
for call in call_args_list: |
669 |
storage_type, storage_key, excl_storage = call[0]
|
|
668 |
storage_type, storage_key, storage_params = call[0]
|
|
670 | 669 |
self.assertEqual(storage_type + "_key", storage_key) |
670 |
self.assertEqual([storage_type + "_params"], storage_params) |
|
671 | 671 |
self.assertTrue(storage_type in constants.VALID_STORAGE_TYPES) |
672 | 672 |
|
673 | 673 |
|
Also available in: Unified diff