diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs index 44d90b89482383b486a1960053edd345138fee19..109ccdb5005558b8ae71b7236a568ca570de0148 100644 --- a/htools/Ganeti/HTools/Luxi.hs +++ b/htools/Ganeti/HTools/Luxi.hs @@ -39,6 +39,7 @@ import qualified Ganeti.HTools.Group as Group import qualified Ganeti.HTools.Node as Node import qualified Ganeti.HTools.Instance as Instance import Ganeti.HTools.JSON +import Ganeti.Query2 as Query2 {-# ANN module "HLint: ignore Eta reduce" #-} @@ -99,7 +100,7 @@ queryNodesMsg :: L.LuxiOp queryNodesMsg = L.Query L.QRNode ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree", "ctotal", "offline", "drained", "vm_capable", - "ndp/spindle_count", "group.uuid"] () + "ndp/spindle_count", "group.uuid"] Query2.EmptyFilter -- | The input data for instance query. queryInstancesMsg :: L.LuxiOp @@ -107,7 +108,7 @@ queryInstancesMsg = L.Query L.QRInstance ["name", "disk_usage", "be/memory", "be/vcpus", "status", "pnode", "snodes", "tags", "oper_ram", "be/auto_balance", "disk_template", - "be/spindle_use"] () + "be/spindle_use"] Query2.EmptyFilter -- | The input data for cluster query. queryClusterInfoMsg :: L.LuxiOp @@ -116,7 +117,8 @@ queryClusterInfoMsg = L.QueryClusterInfo -- | The input data for node group query. queryGroupsMsg :: L.LuxiOp queryGroupsMsg = - L.Query L.QRGroup ["uuid", "name", "alloc_policy", "ipolicy"] () + L.Query L.QRGroup ["uuid", "name", "alloc_policy", "ipolicy"] + Query2.EmptyFilter -- | Wraper over 'callMethod' doing node query. queryNodes :: L.Client -> IO (Result JSValue) diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs index 1053a15e530c568e3c20f042c3bec14873f9a9d2..4b902a7b9bc6071a6988ad0248e58def13bdb818 100644 --- a/htools/Ganeti/HTools/QC.hs +++ b/htools/Ganeti/HTools/QC.hs @@ -1854,7 +1854,7 @@ instance Arbitrary Luxi.LuxiOp where arbitrary = do lreq <- arbitrary case lreq of - Luxi.ReqQuery -> Luxi.Query <$> arbitrary <*> getFields <*> arbitrary + Luxi.ReqQuery -> Luxi.Query <$> arbitrary <*> getFields <*> genFilter Luxi.ReqQueryNodes -> Luxi.QueryNodes <$> (listOf getFQDN) <*> getFields <*> arbitrary Luxi.ReqQueryGroups -> Luxi.QueryGroups <$> arbitrary <*> diff --git a/htools/Ganeti/Luxi.hs b/htools/Ganeti/Luxi.hs index f9eacab0d880e263c6c81e1189ee0e81bf7225fd..1e59ce6519e42e292b76246d2e0a0f93e283e137 100644 --- a/htools/Ganeti/Luxi.hs +++ b/htools/Ganeti/Luxi.hs @@ -76,6 +76,7 @@ import Ganeti.HTools.Utils import Ganeti.Constants import Ganeti.Jobs (JobStatus) import Ganeti.OpCodes (OpCode) +import qualified Ganeti.Query2 as Query2 import Ganeti.THH -- * Utility functions @@ -100,11 +101,12 @@ data RecvResult = RecvConnClosed -- ^ Connection closed type JobId = Int $(declareSADT "QrViaLuxi" - [ ("QRLock", 'qrLock) + [ ("QRLock", 'qrLock) , ("QRInstance", 'qrInstance) - , ("QRNode", 'qrNode) - , ("QRGroup", 'qrGroup) - , ("QROs", 'qrOs) + , ("QRNode", 'qrNode) + , ("QRGroup", 'qrGroup) + , ("QROs", 'qrOs) + , ("QRJob", 'qrJob) ]) $(makeJSONInstance ''QrViaLuxi) @@ -113,7 +115,7 @@ $(genLuxiOp "LuxiOp" [(luxiReqQuery, [ ("what", [t| QrViaLuxi |], [| id |]) , ("fields", [t| [String] |], [| id |]) - , ("qfilter", [t| () |], [| const JSNull |]) + , ("qfilter", [t| Query2.Filter |], [| id |]) ]) , (luxiReqQueryNodes, [ ("names", [t| [String] |], [| id |]) @@ -360,9 +362,8 @@ decodeCall (LuxiCall call args) = ReqQueryClusterInfo -> do return QueryClusterInfo ReqQuery -> do - (what, fields, _) <- - fromJVal args::Result (QrViaLuxi, [String], JSValue) - return $ Query what fields () + (what, fields, qfilter) <- fromJVal args + return $ Query what fields qfilter ReqSubmitJob -> do [ops1] <- fromJVal args ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1