Revision 319322a7
b/htools/Ganeti/Query/Node.hs | ||
---|---|---|
223 | 223 |
maybeCollectLiveData True cfg nodes = do |
224 | 224 |
let vgs = [clusterVolumeGroupName $ configCluster cfg] |
225 | 225 |
hvs = [getDefaultHypervisor cfg] |
226 |
executeRpcCall nodes (RpcCallNodeInfo vgs hvs) |
|
226 |
step n (bn, gn, em) = |
|
227 |
let ndp' = getNodeNdParams cfg n |
|
228 |
in case ndp' of |
|
229 |
Just ndp -> (bn, n : gn, |
|
230 |
(nodeName n, ndpExclusiveStorage ndp) : em) |
|
231 |
Nothing -> (n : bn, gn, em) |
|
232 |
(bnodes, gnodes, emap) = foldr step ([], [], []) nodes |
|
233 |
rpcres <- executeRpcCall gnodes (RpcCallNodeInfo vgs hvs (Map.fromList emap)) |
|
234 |
-- FIXME: The order of nodes in the result could be different from the input |
|
235 |
return $ zip bnodes (repeat $ Left (RpcResultError "Broken configuration")) |
|
236 |
++ rpcres |
b/htools/Ganeti/Rpc.hs | ||
---|---|---|
70 | 70 |
) where |
71 | 71 |
|
72 | 72 |
import Control.Arrow (second) |
73 |
import qualified Data.Map as Map |
|
74 |
import Data.Maybe (fromMaybe) |
|
73 | 75 |
import qualified Text.JSON as J |
74 | 76 |
import Text.JSON.Pretty (pp_value) |
75 | 77 |
|
... | ... | |
343 | 345 |
$(buildObject "RpcCallNodeInfo" "rpcCallNodeInfo" |
344 | 346 |
[ simpleField "volume_groups" [t| [String] |] |
345 | 347 |
, simpleField "hypervisors" [t| [Hypervisor] |] |
348 |
, simpleField "exclusive_storage" [t| Map.Map String Bool |] |
|
346 | 349 |
]) |
347 | 350 |
|
348 | 351 |
$(buildObject "VgInfo" "vgInfo" |
... | ... | |
371 | 374 |
rpcCallName _ = "node_info" |
372 | 375 |
rpcCallTimeout _ = rpcTimeoutToRaw Urgent |
373 | 376 |
rpcCallAcceptOffline _ = False |
374 |
rpcCallData _ call = J.encode
|
|
377 |
rpcCallData n call = J.encode
|
|
375 | 378 |
( rpcCallNodeInfoVolumeGroups call |
376 | 379 |
, rpcCallNodeInfoHypervisors call |
377 |
, False |
|
380 |
, fromMaybe (error $ "Programmer error: missing parameter for node named " |
|
381 |
++ nodeName n) |
|
382 |
$ Map.lookup (nodeName n) (rpcCallNodeInfoExclusiveStorage call) |
|
378 | 383 |
) |
379 | 384 |
|
380 | 385 |
instance Rpc RpcCallNodeInfo RpcResultNodeInfo where |
b/lib/cmdlib.py | ||
---|---|---|
5288 | 5288 |
# filter out non-vm_capable nodes |
5289 | 5289 |
toquery_nodes = [name for name in nodenames if all_info[name].vm_capable] |
5290 | 5290 |
|
5291 |
es_flags = rpc.GetExclusiveStorageForNodeNames(lu.cfg, toquery_nodes) |
|
5291 | 5292 |
node_data = lu.rpc.call_node_info(toquery_nodes, [lu.cfg.GetVGName()], |
5292 |
[lu.cfg.GetHypervisorType()], False)
|
|
5293 |
[lu.cfg.GetHypervisorType()], es_flags)
|
|
5293 | 5294 |
live_data = dict((name, rpc.MakeLegacyNodeInfo(nresult.payload)) |
5294 | 5295 |
for (name, nresult) in node_data.items() |
5295 | 5296 |
if not nresult.fail_msg and nresult.payload) |
... | ... | |
6888 | 6889 |
or we cannot check the node |
6889 | 6890 |
|
6890 | 6891 |
""" |
6891 |
nodeinfo = lu.rpc.call_node_info(nodenames, [vg], None, False) |
|
6892 |
es_flags = rpc.GetExclusiveStorageForNodeNames(lu.cfg, nodenames) |
|
6893 |
nodeinfo = lu.rpc.call_node_info(nodenames, [vg], None, es_flags) |
|
6892 | 6894 |
for node in nodenames: |
6893 | 6895 |
info = nodeinfo[node] |
6894 | 6896 |
info.Raise("Cannot get current information from node %s" % node, |
b/lib/masterd/iallocator.py | ||
---|---|---|
430 | 430 |
hypervisor_name = cluster_info.primary_hypervisor |
431 | 431 |
node_whitelist = None |
432 | 432 |
|
433 |
es_flags = rpc.GetExclusiveStorageForNodeNames(cfg, node_list) |
|
433 | 434 |
node_data = self.rpc.call_node_info(node_list, [cfg.GetVGName()], |
434 |
[hypervisor_name], False)
|
|
435 |
[hypervisor_name], es_flags)
|
|
435 | 436 |
node_iinfo = \ |
436 | 437 |
self.rpc.call_all_instances_info(node_list, |
437 | 438 |
cluster_info.enabled_hypervisors) |
b/lib/rpc.py | ||
---|---|---|
631 | 631 |
return [annotation_fn(disk.Copy(), ld_params) for disk in disks] |
632 | 632 |
|
633 | 633 |
|
634 |
def _GetESFlag(cfg, nodename): |
|
635 |
ni = cfg.GetNodeInfo(nodename) |
|
636 |
if ni is None: |
|
637 |
raise errors.OpPrereqError("Invalid node name %s" % nodename, |
|
638 |
errors.ECODE_NOENT) |
|
639 |
return cfg.GetNdParams(ni)[constants.ND_EXCLUSIVE_STORAGE] |
|
640 |
|
|
641 |
|
|
642 |
def GetExclusiveStorageForNodeNames(cfg, nodelist): |
|
643 |
"""Return the exclusive storage flag for all the given nodes. |
|
644 |
|
|
645 |
@type cfg: L{config.ConfigWriter} |
|
646 |
@param cfg: cluster configuration |
|
647 |
@type nodelist: list or tuple |
|
648 |
@param nodelist: node names for which to read the flag |
|
649 |
@rtype: dict |
|
650 |
@return: mapping from node names to exclusive storage flags |
|
651 |
@raise errors.OpPrereqError: if any given node name has no corresponding node |
|
652 |
|
|
653 |
""" |
|
654 |
getflag = lambda n: _GetESFlag(cfg, n) |
|
655 |
flags = map(getflag, nodelist) |
|
656 |
return dict(zip(nodelist, flags)) |
|
657 |
|
|
658 |
|
|
634 | 659 |
#: Generic encoders |
635 | 660 |
_ENCODERS = { |
636 | 661 |
rpc_defs.ED_OBJECT_DICT: _ObjectToDict, |
Also available in: Unified diff