… and use it in the Query implementation, removing the last
non-correct query field for Groups.

Signed-off-by: Iustin Pop <[email protected]>
---
 htools/Ganeti/Config.hs      |    8 ++++++++
 htools/Ganeti/Query/Group.hs |    3 ++-
 htools/Ganeti/Query/Query.hs |    3 ---
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/htools/Ganeti/Config.hs b/htools/Ganeti/Config.hs
index f88ba8a..e4df668 100644
--- a/htools/Ganeti/Config.hs
+++ b/htools/Ganeti/Config.hs
@@ -37,6 +37,7 @@ module Ganeti.Config
     , getGroup
     , getGroupNdParams
     , getGroupIpolicy
+    , getGroupDiskParams
     , getGroupNodes
     , getGroupInstances
     , getGroupOfNode
@@ -176,6 +177,13 @@ getGroupIpolicy :: ConfigData -> NodeGroup -> FilledIPolicy
 getGroupIpolicy cfg ng =
   fillIPolicy (clusterIpolicy $ configCluster cfg) (groupIpolicy ng)
 
+-- | Computes a group\'s (merged) disk params.
+getGroupDiskParams :: ConfigData -> NodeGroup -> DiskParams
+getGroupDiskParams cfg ng =
+  Container $
+  fillDict (fromContainer . clusterDiskparams $ configCluster cfg)
+           (fromContainer $ groupDiskparams ng) []
+
 -- | Get nodes of a given node group.
 getGroupNodes :: ConfigData -> String -> [Node]
 getGroupNodes cfg gname =
diff --git a/htools/Ganeti/Query/Group.hs b/htools/Ganeti/Query/Group.hs
index b76d6c3..acf9083 100644
--- a/htools/Ganeti/Query/Group.hs
+++ b/htools/Ganeti/Query/Group.hs
@@ -54,7 +54,8 @@ groupFields =
        "Custom node parameters",
      FieldSimple (rsNormal . groupNdparams))
   , (FieldDefinition "diskparams" "DiskParameters" QFTOther
-       "Disk parameters (merged)", FieldSimple (\_ -> rsNoData))
+       "Disk parameters (merged)",
+     FieldConfig (\cfg -> rsNormal . getGroupDiskParams cfg))
   , (FieldDefinition "ipolicy" "InstancePolicy" QFTOther
        "Instance policy limitations (merged)",
      FieldConfig (\cfg ng -> rsNormal (getGroupIpolicy cfg ng)))
diff --git a/htools/Ganeti/Query/Query.hs b/htools/Ganeti/Query/Query.hs
index afb5830..562fc62 100644
--- a/htools/Ganeti/Query/Query.hs
+++ b/htools/Ganeti/Query/Query.hs
@@ -177,9 +177,6 @@ queryInner cfg live (Query QRNode fields qfilter) wanted = 
runResultT $ do
   return QueryResult { qresFields = fdefs, qresData = fdata }
 
 queryInner cfg _ (Query QRGroup fields qfilter) wanted = return $ do
-  -- FIXME: want_diskparams is defaulted to false and not taken as parameter
-  -- This is because the type for DiskParams is right now too generic for 
merges
-  -- (or else I cannot see how to do this with curent implementation)
   cfilter <- compileFilter groupFieldsMap qfilter
   let selected = getSelectedFields groupFieldsMap fields
       (fdefs, fgetters) = unzip selected
-- 
1.7.10.4

Reply via email to