Skip to content
Snippets Groups Projects
Commit 1ba01ff7 authored by Iustin Pop's avatar Iustin Pop
Browse files

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: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent a7e484c4
No related branches found
No related tags found
No related merge requests found
......@@ -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)
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment