diff --git a/htools/Ganeti/Config.hs b/htools/Ganeti/Config.hs index 49a3f03fac00f0fde84377fadbee944ade4446ec..f88ba8a687076a5200eadf111995b30933276608 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 (primary, secondary) 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 =