On Tue, Sep 25, 2012 at 06:43:46PM +0200, Agata Murawska wrote: > 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
I wonder if this is the best way - first converting to a list, then filtering, as opposed to viceversa. Anyway. > +-- | 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) What are the elements of the tuple, primary and secondary? Please document. LGTM, non need to resend. iustin
