Revision 1ba01ff7

b/htools/Ganeti/Query/Node.hs
26 26
module Ganeti.Query.Node
27 27
  ( NodeRuntime
28 28
  , nodeFieldsMap
29
  , maybeCollectLiveData
29 30
  ) where
30 31

  
31 32
import Control.Applicative
......
210 211
nodeFieldsMap :: FieldMap Node NodeRuntime
211 212
nodeFieldsMap =
212 213
  Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) nodeFields
214

  
215
-- | Collect live data from RPC query if enabled.
216
--
217
-- FIXME: Check which fields we actually need and possibly send empty
218
-- hvs/vgs if no info from hypervisor/volume group respectively is
219
-- required
220
maybeCollectLiveData:: Bool -> ConfigData -> [Node] -> IO [(Node, NodeRuntime)]
221
maybeCollectLiveData False _ nodes =
222
  return $ zip nodes (repeat $ Left (RpcResultError "Live data disabled"))
223
maybeCollectLiveData True cfg nodes = do
224
  let vgs = [clusterVolumeGroupName $ configCluster cfg]
225
      hvs = [getDefaultHypervisor cfg]
226
  executeRpcCall nodes (RpcCallNodeInfo vgs hvs)
b/htools/Ganeti/Query/Query.hs
65 65
import Ganeti.Errors
66 66
import Ganeti.JQueue
67 67
import Ganeti.JSON
68
import Ganeti.Rpc
69 68
import Ganeti.Objects
70 69
import Ganeti.Query.Common
71 70
import Ganeti.Query.Filter
......
105 104
getSelectedFields defined =
106 105
  map (\name -> fromMaybe (mkUnknownFDef name) $ name `Map.lookup` defined)
107 106

  
108
-- | Collect live data from RPC query if enabled.
109
-- FIXME: Check which fields we actually need and possibly send empty
110
-- hvs/vgs if no info from hypervisor/volume group respectively
111
-- is required
112
maybeCollectLiveData:: Bool -> ConfigData -> [Node] -> IO [(Node, NodeRuntime)]
113

  
114
maybeCollectLiveData False _ nodes =
115
  return $ zip nodes (repeat $ Left (RpcResultError "Live data disabled"))
116

  
117
maybeCollectLiveData True cfg nodes = do
118
  let vgs = [clusterVolumeGroupName $ configCluster cfg]
119
      hvs = [getDefaultHypervisor cfg]
120
  executeRpcCall nodes (RpcCallNodeInfo vgs hvs)
121

  
122 107
-- | Check whether list of queried fields contains live fields.
123 108
needsLiveData :: [FieldGetter a b] -> Bool
124 109
needsLiveData = any isRuntimeField

Also available in: Unified diff