From 1ba01ff70134bef829b377c26cff133f5cfd31c9 Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 10 Dec 2012 20:22:34 +0100 Subject: [PATCH] Move a node-specific function to Query.Node This shouldn't live in the main Query module, since it's too node specific. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Helga Velroyen <helgav@google.com> --- htools/Ganeti/Query/Node.hs | 14 ++++++++++++++ htools/Ganeti/Query/Query.hs | 15 --------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/htools/Ganeti/Query/Node.hs b/htools/Ganeti/Query/Node.hs index 8809c316d..d324c39f6 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 026b5528f..eb448a333 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 -- GitLab