Commit 1a3c5d4e authored by Bernardo Dal Seno's avatar Bernardo Dal Seno
Browse files

Add exclusive_storage parameter to node_info RPC

The flag is passed to the low-level functions that need it, but it's not
yet used. Also, RPCs get just a default value for now.
Signed-off-by: default avatarBernardo Dal Seno <>
Reviewed-by: default avatarIustin Pop <>
parent 3601d488
......@@ -374,6 +374,7 @@ instance RpcCall RpcCallNodeInfo where
rpcCallData _ call = J.encode
( rpcCallNodeInfoVolumeGroups call
, rpcCallNodeInfoHypervisors call
, False
instance Rpc RpcCallNodeInfo RpcResultNodeInfo where
......@@ -541,12 +541,12 @@ def LeaveCluster(modify_ssh_setup):
raise errors.QuitGanetiException(True, "Shutdown scheduled")
def _GetVgInfo(name):
def _GetVgInfo(name, excl_stor):
"""Retrieves information about a LVM volume group.
# TODO: GetVGInfo supports returning information for multiple VGs at once
vginfo = bdev.LogicalVolume.GetVGInfo([name])
vginfo = bdev.LogicalVolume.GetVGInfo([name], excl_stor)
if vginfo:
vg_free = int(round(vginfo[0][0], 0))
vg_size = int(round(vginfo[0][1], 0))
......@@ -589,20 +589,22 @@ def _GetNamedNodeInfo(names, fn):
return map(fn, names)
def GetNodeInfo(vg_names, hv_names):
def GetNodeInfo(vg_names, hv_names, excl_stor):
"""Gives back a hash with different information about the node.
@type vg_names: list of string
@param vg_names: Names of the volume groups to ask for disk space information
@type hv_names: list of string
@param hv_names: Names of the hypervisors to ask for node information
@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
bootid = utils.ReadFile(_BOOT_ID_PATH, size=128).rstrip("\n")
vg_info = _GetNamedNodeInfo(vg_names, _GetVgInfo)
vg_info = _GetNamedNodeInfo(vg_names, (lambda vg: _GetVgInfo(vg, excl_stor)))
hv_info = _GetNamedNodeInfo(hv_names, _GetHvInfo)
return (bootid, vg_info, hv_info)
......@@ -699,10 +699,11 @@ class LogicalVolume(BlockDev):
return data
def GetVGInfo(cls, vg_names, filter_readonly=True):
def GetVGInfo(cls, vg_names, excl_stor, filter_readonly=True):
"""Get the free space info for specific VGs.
@param vg_names: list of volume group names, if empty all will be returned
@param excl_stor: whether exclusive_storage is enabled
@param filter_readonly: whether to skip over readonly VGs
@rtype: list
......@@ -921,7 +922,7 @@ class LogicalVolume(BlockDev):
snap = LogicalVolume((self._vg_name, snap_name), None, size, self.params)
vg_info = self.GetVGInfo([self._vg_name])
vg_info = self.GetVGInfo([self._vg_name], False)
if not vg_info:
_ThrowError("Can't compute VG info for vg %s", self._vg_name)
free_size, _, _ = vg_info[0]
......@@ -5289,7 +5289,7 @@ class _NodeQuery(_QueryBase):
toquery_nodes = [name for name in nodenames if all_info[name].vm_capable]
node_data = lu.rpc.call_node_info(toquery_nodes, [lu.cfg.GetVGName()],
[lu.cfg.GetHypervisorType()], False)
live_data = dict((name, rpc.MakeLegacyNodeInfo(nresult.payload))
for (name, nresult) in node_data.items()
if not nresult.fail_msg and nresult.payload)
......@@ -6827,7 +6827,7 @@ def _CheckNodeFreeMemory(lu, node, reason, requested, hypervisor_name):
we cannot check the node
nodeinfo = lu.rpc.call_node_info([node], None, [hypervisor_name])
nodeinfo = lu.rpc.call_node_info([node], None, [hypervisor_name], False)
nodeinfo[node].Raise("Can't get data from node %s" % node,
prereq=True, ecode=errors.ECODE_ENVIRON)
(_, _, (hv_info, )) = nodeinfo[node].payload
......@@ -6888,7 +6888,7 @@ def _CheckNodesFreeDiskOnVG(lu, nodenames, vg, requested):
or we cannot check the node
nodeinfo = lu.rpc.call_node_info(nodenames, [vg], None)
nodeinfo = lu.rpc.call_node_info(nodenames, [vg], None, False)
for node in nodenames:
info = nodeinfo[node]
info.Raise("Cannot get current information from node %s" % node,
......@@ -6924,7 +6924,7 @@ def _CheckNodesPhysicalCPUs(lu, nodenames, requested, hypervisor_name):
or we cannot check the node
nodeinfo = lu.rpc.call_node_info(nodenames, None, [hypervisor_name])
nodeinfo = lu.rpc.call_node_info(nodenames, None, [hypervisor_name], None)
for node in nodenames:
info = nodeinfo[node]
info.Raise("Cannot get current information from node %s" % node,
......@@ -8740,7 +8740,7 @@ class TLMigrateInstance(Tasklet):
# Check for hypervisor version mismatch and warn the user.
nodeinfo = self.rpc.call_node_info([source_node, target_node],
None, [self.instance.hypervisor])
None, [self.instance.hypervisor], False)
for ninfo in nodeinfo.values():
ninfo.Raise("Unable to retrieve node information from node '%s'" %
......@@ -13440,7 +13440,7 @@ class LUInstanceSetParams(LogicalUnit):
instance_info = self.rpc.call_instance_info(pnode,,
nodeinfo = self.rpc.call_node_info(mem_check_list, None,
[instance.hypervisor], False)
pninfo = nodeinfo[pnode]
msg = pninfo.fail_msg
if msg:
......@@ -431,7 +431,7 @@ class IAllocator(object):
node_whitelist = None
node_data = self.rpc.call_node_info(node_list, [cfg.GetVGName()],
[hypervisor_name], False)
node_iinfo = \
......@@ -131,6 +131,17 @@ def _BlockdevGetMirrorStatusMultiPostProc(result):
return result
def _NodeInfoPreProc(node, args):
"""Prepare the exclusive_storage argument for node_info calls."""
assert len(args) == 3
# The third argument is either a dictionary with one value for each node, or
# a fixed value to be used for all the nodes
if type(args[2]) is dict:
return [args[0], args[1], args[2][node]]
return args
def _OsGetPostProc(result):
"""Post-processor for L{rpc.RpcRunner.call_os_get}.
......@@ -449,7 +460,9 @@ _NODE_CALLS = [
"Names of the volume groups to ask for disk space information"),
("hv_names", None,
"Names of the hypervisors to ask for node information"),
], None, None, "Return node information"),
("exclusive_storage", None,
"Whether exclusive storage is enabled"),
], _NodeInfoPreProc, None, "Return node information"),
("node_verify", MULTI, None, constants.RPC_TMO_NORMAL, [
("checkdict", None, None),
("cluster_name", None, None),
......@@ -687,8 +687,8 @@ class NodeRequestHandler(http.server.HttpServerHandler):
"""Query node information.
(vg_names, hv_names) = params
return backend.GetNodeInfo(vg_names, hv_names)
(vg_names, hv_names, excl_stor) = params
return backend.GetNodeInfo(vg_names, hv_names, excl_stor)
def perspective_etc_hosts_modify(params):
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