For some results in nodegroup queries we need agregation similar to one that is done for nodes.
Signed-off-by: Agata Murawska <[email protected]> --- htools/Ganeti/Config.hs | 21 +++++++++++++++++++++ 1 files changed, 21 insertions(+), 0 deletions(-) diff --git a/htools/Ganeti/Config.hs b/htools/Ganeti/Config.hs index 49a3f03..fd777e8 100644 --- a/htools/Ganeti/Config.hs +++ b/htools/Ganeti/Config.hs @@ -36,6 +36,9 @@ module Ganeti.Config , getInstance , getGroup , getGroupNdParams + , getGroupIpolicy + , getGroupNodes + , getGroupInstances , getGroupOfNode , getInstPrimaryNode , getInstMinorsForNode @@ -168,6 +171,24 @@ getGroupNdParams :: ConfigData -> NodeGroup -> FilledNDParams getGroupNdParams cfg ng = fillNDParams (clusterNdparams $ configCluster cfg) (groupNdparams ng) +-- | Computes a node group's ipolicy. +getGroupIpolicy :: ConfigData -> NodeGroup -> FilledIPolicy +getGroupIpolicy cfg ng = + fillIPolicy (clusterIpolicy $ configCluster cfg) (groupIpolicy ng) + +-- | Get nodes of a given node group. +getGroupNodes :: ConfigData -> String -> [Node] +getGroupNodes cfg gname = + let all_nodes = M.elems . fromContainer . configNodes $ cfg in + filter ((==gname) . nodeGroup) all_nodes + +-- | Get instances of a given node group. +getGroupInstances :: ConfigData -> String -> ([Instance], [Instance]) +getGroupInstances cfg gname = + let gnodes = map nodeName (getGroupNodes cfg gname) + ginsts = map (getNodeInstances cfg) gnodes in + (concatMap fst ginsts, concatMap snd ginsts) + -- | Looks up an instance's primary node. getInstPrimaryNode :: ConfigData -> String -> Result Node getInstPrimaryNode cfg name = -- 1.7.7.3
