diff --git a/htools/Ganeti/Rpc.hs b/htools/Ganeti/Rpc.hs index 4ab9d7e814e83363d16f00f77f4958a5eea01f1b..c0d0cb6bbfe905bbb856b33c82e55c550bc99273 100644 --- a/htools/Ganeti/Rpc.hs +++ b/htools/Ganeti/Rpc.hs @@ -374,6 +374,7 @@ instance RpcCall RpcCallNodeInfo where rpcCallData _ call = J.encode ( rpcCallNodeInfoVolumeGroups call , rpcCallNodeInfoHypervisors call + , False ) instance Rpc RpcCallNodeInfo RpcResultNodeInfo where diff --git a/lib/backend.py b/lib/backend.py index c6e624d5253bba193afaaf71e89d3294ad743013..3b0a2caeb634127bf9c26b83dc5912b47500eced 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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 information """ 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) diff --git a/lib/bdev.py b/lib/bdev.py index 06c2d2fdbbeec6c4b86714fa5f8f6ec826031038..511988d1c3d4cc637a2059a2de3850226ba3f670 100644 --- a/lib/bdev.py +++ b/lib/bdev.py @@ -699,10 +699,11 @@ class LogicalVolume(BlockDev): return data @classmethod - 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) _IgnoreError(snap.Remove) - 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] diff --git a/lib/cmdlib.py b/lib/cmdlib.py index e46fddb444b582831980f37a35403aa798629693..eb9cb45717165aa81ec84283b18032ae745365a1 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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()]) + [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'" % ninfo.node) @@ -13440,7 +13440,7 @@ class LUInstanceSetParams(LogicalUnit): instance_info = self.rpc.call_instance_info(pnode, instance.name, instance.hypervisor) nodeinfo = self.rpc.call_node_info(mem_check_list, None, - [instance.hypervisor]) + [instance.hypervisor], False) pninfo = nodeinfo[pnode] msg = pninfo.fail_msg if msg: diff --git a/lib/masterd/iallocator.py b/lib/masterd/iallocator.py index b6a8afdc62e90a6675302f3a7302978cd8b00b58..5f339b699ae0bd08b7c1c34ed809d98508e1ea9a 100644 --- a/lib/masterd/iallocator.py +++ b/lib/masterd/iallocator.py @@ -431,7 +431,7 @@ class IAllocator(object): node_whitelist = None node_data = self.rpc.call_node_info(node_list, [cfg.GetVGName()], - [hypervisor_name]) + [hypervisor_name], False) node_iinfo = \ self.rpc.call_all_instances_info(node_list, cluster_info.enabled_hypervisors) diff --git a/lib/rpc_defs.py b/lib/rpc_defs.py index fc7b3facf5eeea62b8141564da61d579f91c7433..36b87b5d9ace6d40588b8a4df42b86059de7c73d 100644 --- a/lib/rpc_defs.py +++ b/lib/rpc_defs.py @@ -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]] + else: + 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), diff --git a/lib/server/noded.py b/lib/server/noded.py index 71e8edc323dbebf8825c939cafe58e861bf1bd50..9f068223f487c2087541a29f87dbeeaa6b430efe 100644 --- a/lib/server/noded.py +++ b/lib/server/noded.py @@ -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) @staticmethod def perspective_etc_hosts_modify(params):