Commit 152759e4 authored by Helga Velroyen's avatar Helga Velroyen
Browse files

Add general storage parameters to node info call

As described in the design doc about storage types,
we plan to generalize the RPC call "node info" wrt to
storage types. This patch extends the call by accepting
a list of storage units, that is not only identified
by storage type and identifier, but enhanced by additional
parameters. So far, only LVM storage has an additional
parameter, which is the 'exclusive storage' flag. This
patch enhances the backend code of the node info call
to be able to handle this change.
Signed-off-by: default avatarHelga Velroyen <>
Reviewed-by: default avatarThomas Thrainer <>
parent a7d524e7
......@@ -668,17 +668,16 @@ def _GetNamedNodeInfo(names, fn):
return map(fn, names)
def GetNodeInfo(storage_units, hv_specs, excl_stor):
def GetNodeInfo(storage_units, hv_specs):
"""Gives back a hash with different information about the node.
@type storage_units: list of pairs (string, string)
@param storage_units: List of pairs (storage unit, identifier) to ask for disk
space information. In case of lvm-vg, the identifier is
the VG name.
@type storage_units: list of tuples (string, string, list)
@param storage_units: List of tuples (storage unit, identifier, parameters) to
ask for disk space information. In case of lvm-vg, the identifier is
the VG name. The parameters can contain additional, storage-type-specific
parameters, for example exclusive storage for lvm storage.
@type hv_specs: list of pairs (string, dict of strings)
@param hv_specs: list of pairs of a hypervisor's name and its hvparams
@type excl_stor: boolean
@param excl_stor: Whether exclusive_storage is active
@rtype: tuple; (string, None/dict, None/dict)
@return: Tuple containing boot ID, volume group information and hypervisor
......@@ -687,9 +686,8 @@ def GetNodeInfo(storage_units, hv_specs, excl_stor):
bootid = utils.ReadFile(_BOOT_ID_PATH, size=128).rstrip("\n")
storage_info = _GetNamedNodeInfo(
(lambda storage_unit: _ApplyStorageInfoFunction(storage_unit[0],
(lambda (storage_type, storage_key, storage_params):
_ApplyStorageInfoFunction(storage_type, storage_key, storage_params)))
hv_info = _GetHvInfoAll(hv_specs)
return (bootid, storage_info, hv_info)
......@@ -724,8 +724,25 @@ class NodeRequestHandler(http.server.HttpServerHandler):
"""Query node information.
(storage_units, hv_specs, excl_stor) = params
return backend.GetNodeInfo(storage_units, hv_specs, excl_stor)
# FIXME: remove the fallback to excl_stor once all callers are
# adjusted
if (len(params) == 3):
(legacy_storage_units, hv_specs, excl_stor) = params
storage_units = NodeRequestHandler._ConvertExclStorage(
legacy_storage_units, excl_stor)
(storage_units, hv_specs) = params
return backend.GetNodeInfo(storage_units, hv_specs)
def _ConvertExclStorage(storage_units, excl_stor):
result_units = []
for (storage_type, storage_key) in storage_units:
if storage_type in [constants.ST_LVM_VG, constants.ST_LVM_PV]:
result_units.append((storage_type, storage_key, [excl_stor]))
result_units.append((storage_type, storage_key, []))
return result_units
def perspective_etc_hosts_modify(params):
......@@ -655,19 +655,19 @@ class TestGetNodeInfo(unittest.TestCase):
def testApplyStorageInfoFunction(self):
excl_storage_flag = False
backend._ApplyStorageInfoFunction = mock.Mock(
storage_units = [(st, st + "_key") for st in
storage_units = [(st, st + "_key", [st + "_params"]) for st in
backend.GetNodeInfo(storage_units, None, excl_storage_flag)
backend.GetNodeInfo(storage_units, None)
call_args_list = backend._ApplyStorageInfoFunction.call_args_list
self.assertEqual(len(constants.VALID_STORAGE_TYPES), len(call_args_list))
for call in call_args_list:
storage_type, storage_key, excl_storage = call[0]
storage_type, storage_key, storage_params = call[0]
self.assertEqual(storage_type + "_key", storage_key)
self.assertEqual([storage_type + "_params"], storage_params)
self.assertTrue(storage_type in constants.VALID_STORAGE_TYPES)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment