Revision 212b66c3 src/Ganeti/Query/Node.hs
b/src/Ganeti/Query/Node.hs | ||
---|---|---|
36 | 36 |
import qualified Text.JSON as J |
37 | 37 |
|
38 | 38 |
import Ganeti.Config |
39 |
import Ganeti.Common |
|
39 | 40 |
import Ganeti.Objects |
40 | 41 |
import Ganeti.JSON |
41 | 42 |
import Ganeti.Rpc |
... | ... | |
228 | 229 |
fieldsMap = |
229 | 230 |
Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) nodeFields |
230 | 231 |
|
232 |
-- | Create an RPC result for a broken node |
|
233 |
rpcResultNodeBroken :: Node -> (Node, Runtime) |
|
234 |
rpcResultNodeBroken node = (node, Left (RpcResultError "Broken configuration")) |
|
235 |
|
|
231 | 236 |
-- | Collect live data from RPC query if enabled. |
232 | 237 |
-- |
233 | 238 |
-- FIXME: Check which fields we actually need and possibly send empty |
... | ... | |
237 | 242 |
collectLiveData False _ nodes = |
238 | 243 |
return $ zip nodes (repeat $ Left (RpcResultError "Live data disabled")) |
239 | 244 |
collectLiveData True cfg nodes = do |
240 |
let storage_units = getClusterStorageUnits cfg |
|
241 |
hvs = [getDefaultHypervisorSpec cfg] |
|
242 |
step n (bn, gn, em) = |
|
243 |
let ndp' = getNodeNdParams cfg n |
|
244 |
in case ndp' of |
|
245 |
Just ndp -> (bn, n : gn, |
|
246 |
(nodeName n, ndpExclusiveStorage ndp) : em) |
|
247 |
Nothing -> (n : bn, gn, em) |
|
248 |
(bnodes, gnodes, emap) = foldr step ([], [], []) nodes |
|
249 |
rpcres <- executeRpcCall gnodes (RpcCallNodeInfo storage_units hvs |
|
250 |
(Map.fromList emap)) |
|
251 |
-- FIXME: The order of nodes in the result could be different from the input |
|
252 |
return $ zip bnodes (repeat $ Left (RpcResultError "Broken configuration")) |
|
253 |
++ rpcres |
|
245 |
let hvs = [getDefaultHypervisorSpec cfg] |
|
246 |
good_nodes = nodesWithValidConfig cfg nodes |
|
247 |
storage_units = getStorageUnitsOfNodes cfg good_nodes |
|
248 |
rpcres <- executeRpcCall good_nodes (RpcCallNodeInfo storage_units hvs) |
|
249 |
return $ fillUpList (fillPairFromMaybe rpcResultNodeBroken pickPairUnique) |
|
250 |
nodes rpcres |
|
254 | 251 |
|
255 | 252 |
-- | Looks up the default hypervisor and it's hvparams |
256 | 253 |
getDefaultHypervisorSpec :: ConfigData -> (Hypervisor, HvParams) |
Also available in: Unified diff