From 722957084d77a5c99e42d4bb93babdf4e9ae8ec1 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sat, 25 Aug 2012 00:27:19 +0200
Subject: [PATCH] Add missing luxi query 'QueryFields'

This was missed; we add the definition and the de-serialisation
support.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>
---
 htools/Ganeti/HTools/QC.hs |  1 +
 htools/Ganeti/Luxi.hs      | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs
index fbc2d2f4a..47473d3b2 100644
--- a/htools/Ganeti/HTools/QC.hs
+++ b/htools/Ganeti/HTools/QC.hs
@@ -1954,6 +1954,7 @@ instance Arbitrary Luxi.LuxiOp where
     lreq <- arbitrary
     case lreq of
       Luxi.ReqQuery -> Luxi.Query <$> arbitrary <*> getFields <*> genFilter
+      Luxi.ReqQueryFields -> Luxi.QueryFields <$> arbitrary <*> getFields
       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 77a29b998..c7b771bb6 100644
--- a/htools/Ganeti/Luxi.hs
+++ b/htools/Ganeti/Luxi.hs
@@ -109,11 +109,15 @@ $(makeJSONInstance ''TagObject)
 
 -- | Currently supported Luxi operations and JSON serialization.
 $(genLuxiOp "LuxiOp"
-  [(luxiReqQuery,
+  [ (luxiReqQuery,
     [ ("what",    [t| Qlang.ItemType |])
     , ("fields",  [t| [String]  |])
     , ("qfilter", [t| Qlang.Filter |])
     ])
+  , (luxiReqQueryFields,
+    [ ("what",    [t| Qlang.ItemType |])
+    , ("fields",  [t| [String]  |])
+    ])
   , (luxiReqQueryNodes,
      [ ("names",  [t| [String] |])
      , ("fields", [t| [String] |])
@@ -343,6 +347,12 @@ decodeCall (LuxiCall call args) =
     ReqQuery -> do
               (what, fields, qfilter) <- fromJVal args
               return $ Query what fields qfilter
+    ReqQueryFields -> do
+              (what, fields) <- fromJVal args
+              fields' <- case fields of
+                           JSNull -> return []
+                           _ -> fromJVal fields
+              return $ QueryFields what fields'
     ReqSubmitJob -> do
               [ops1] <- fromJVal args
               ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
-- 
GitLab