From 90d033ef3b3f37ea15cb891fe1bb57308d3ebbfa Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 3 Oct 2012 00:45:12 +0100 Subject: [PATCH] Add function for getting a group's merged disk params MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit β¦ and use it in the Query implementation, removing the last non-correct query field for Groups. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Michael Hanselmann <hansmi@google.com> --- 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 55cb492cf..a35c5d237 100644 --- a/htools/Ganeti/Config.hs +++ b/htools/Ganeti/Config.hs @@ -38,6 +38,7 @@ module Ganeti.Config , getGroup , getGroupNdParams , getGroupIpolicy + , getGroupDiskParams , getGroupNodes , getGroupInstances , getGroupOfNode @@ -187,6 +188,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 b76d6c3ea..acf908381 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 0b4e7f6b4..f9d7f4679 100644 --- a/htools/Ganeti/Query/Query.hs +++ b/htools/Ganeti/Query/Query.hs @@ -175,9 +175,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 -- GitLab