diff --git a/htools/Ganeti/Query/Node.hs b/htools/Ganeti/Query/Node.hs index 8809c316d36e81e7bc36083d1466af80091b2bfc..d324c39f6b254c3d192ba6725a6643b8cad78753 100644 --- a/htools/Ganeti/Query/Node.hs +++ b/htools/Ganeti/Query/Node.hs @@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA module Ganeti.Query.Node ( NodeRuntime , nodeFieldsMap + , maybeCollectLiveData ) where import Control.Applicative @@ -210,3 +211,16 @@ nodeFields = nodeFieldsMap :: FieldMap Node NodeRuntime nodeFieldsMap = Map.fromList $ map (\v@(f, _, _) -> (fdefName f, v)) nodeFields + +-- | Collect live data from RPC query if enabled. +-- +-- FIXME: Check which fields we actually need and possibly send empty +-- hvs/vgs if no info from hypervisor/volume group respectively is +-- required +maybeCollectLiveData:: Bool -> ConfigData -> [Node] -> IO [(Node, NodeRuntime)] +maybeCollectLiveData False _ nodes = + return $ zip nodes (repeat $ Left (RpcResultError "Live data disabled")) +maybeCollectLiveData True cfg nodes = do + let vgs = [clusterVolumeGroupName $ configCluster cfg] + hvs = [getDefaultHypervisor cfg] + executeRpcCall nodes (RpcCallNodeInfo vgs hvs) diff --git a/htools/Ganeti/Query/Query.hs b/htools/Ganeti/Query/Query.hs index 026b5528fb4fec057a0a1c310774e96f1652147a..eb448a33348d90648b5e4047eede7b5883525027 100644 --- a/htools/Ganeti/Query/Query.hs +++ b/htools/Ganeti/Query/Query.hs @@ -65,7 +65,6 @@ import Ganeti.Config import Ganeti.Errors import Ganeti.JQueue import Ganeti.JSON -import Ganeti.Rpc import Ganeti.Objects import Ganeti.Query.Common import Ganeti.Query.Filter @@ -105,20 +104,6 @@ getSelectedFields :: FieldMap a b -- ^ Defined fields getSelectedFields defined = map (\name -> fromMaybe (mkUnknownFDef name) $ name `Map.lookup` defined) --- | Collect live data from RPC query if enabled. --- FIXME: Check which fields we actually need and possibly send empty --- hvs/vgs if no info from hypervisor/volume group respectively --- is required -maybeCollectLiveData:: Bool -> ConfigData -> [Node] -> IO [(Node, NodeRuntime)] - -maybeCollectLiveData False _ nodes = - return $ zip nodes (repeat $ Left (RpcResultError "Live data disabled")) - -maybeCollectLiveData True cfg nodes = do - let vgs = [clusterVolumeGroupName $ configCluster cfg] - hvs = [getDefaultHypervisor cfg] - executeRpcCall nodes (RpcCallNodeInfo vgs hvs) - -- | Check whether list of queried fields contains live fields. needsLiveData :: [FieldGetter a b] -> Bool needsLiveData = any isRuntimeField