From 8a9ee1e90d20bb5b3c2a1a9bfeaaf7979cbdeb89 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Sun, 19 Aug 2012 01:22:37 +0200
Subject: [PATCH] Remove obsolete QrViaLuxi type

The actual query definitions are now in Qlang.hs, so let's use the
ItemType from there instead of luxi-defined type (which is also
incomplete).

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Agata Murawska <agatamurawska@google.com>
---
 htools/Ganeti/HTools/Luxi.hs | 16 ++++++++--------
 htools/Ganeti/HTools/QC.hs   |  6 +++---
 htools/Ganeti/Luxi.hs        | 13 +------------
 htools/Ganeti/Qlang.hs       |  1 +
 4 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/htools/Ganeti/HTools/Luxi.hs b/htools/Ganeti/HTools/Luxi.hs
index 1374f3311..fb1699dd0 100644
--- a/htools/Ganeti/HTools/Luxi.hs
+++ b/htools/Ganeti/HTools/Luxi.hs
@@ -98,17 +98,17 @@ genericConvert otype oname oattr =
 -- | The input data for node query.
 queryNodesMsg :: L.LuxiOp
 queryNodesMsg =
-  L.Query L.QRNode ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree",
-                    "ctotal", "offline", "drained", "vm_capable",
-                    "ndp/spindle_count", "group.uuid"] Qlang.EmptyFilter
+  L.Query Qlang.QRNode ["name", "mtotal", "mnode", "mfree", "dtotal", "dfree",
+                        "ctotal", "offline", "drained", "vm_capable",
+                        "ndp/spindle_count", "group.uuid"] Qlang.EmptyFilter
 
 -- | The input data for instance query.
 queryInstancesMsg :: L.LuxiOp
 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"] Qlang.EmptyFilter
+  L.Query Qlang.QRInstance ["name", "disk_usage", "be/memory", "be/vcpus",
+                            "status", "pnode", "snodes", "tags", "oper_ram",
+                            "be/auto_balance", "disk_template",
+                            "be/spindle_use"] Qlang.EmptyFilter
 
 -- | The input data for cluster query.
 queryClusterInfoMsg :: L.LuxiOp
@@ -117,7 +117,7 @@ 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 Qlang.QRGroup ["uuid", "name", "alloc_policy", "ipolicy"]
    Qlang.EmptyFilter
 
 -- | Wraper over 'callMethod' doing node query.
diff --git a/htools/Ganeti/HTools/QC.hs b/htools/Ganeti/HTools/QC.hs
index 825bea437..8705ad164 100644
--- a/htools/Ganeti/HTools/QC.hs
+++ b/htools/Ganeti/HTools/QC.hs
@@ -590,6 +590,9 @@ genFilter' n = do
         n'' = max n' 2 -- but we don't want empty or 1-element lists,
                        -- so use this for and/or filter list length
 
+instance Arbitrary Qlang.ItemType where
+  arbitrary = elements [minBound..maxBound]
+
 -- * Actual tests
 
 -- ** Utils tests
@@ -1847,9 +1850,6 @@ testSuite "JSON"
 instance Arbitrary Luxi.LuxiReq where
   arbitrary = elements [minBound..maxBound]
 
-instance Arbitrary Luxi.QrViaLuxi where
-  arbitrary = elements [minBound..maxBound]
-
 instance Arbitrary Luxi.LuxiOp where
   arbitrary = do
     lreq <- arbitrary
diff --git a/htools/Ganeti/Luxi.hs b/htools/Ganeti/Luxi.hs
index 70c778543..939302c23 100644
--- a/htools/Ganeti/Luxi.hs
+++ b/htools/Ganeti/Luxi.hs
@@ -27,7 +27,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
 module Ganeti.Luxi
   ( LuxiOp(..)
-  , QrViaLuxi(..)
   , ResultStatus(..)
   , LuxiReq(..)
   , Client
@@ -100,20 +99,10 @@ data RecvResult = RecvConnClosed    -- ^ Connection closed
 -- | The Ganeti job type.
 type JobId = Int
 
-$(declareSADT "QrViaLuxi"
-  [ ("QRLock",     'qrLock)
-  , ("QRInstance", 'qrInstance)
-  , ("QRNode",     'qrNode)
-  , ("QRGroup",    'qrGroup)
-  , ("QROs",       'qrOs)
-  , ("QRJob",      'qrJob)
-  ])
-$(makeJSONInstance ''QrViaLuxi)
-
 -- | Currently supported Luxi operations and JSON serialization.
 $(genLuxiOp "LuxiOp"
   [(luxiReqQuery,
-    [ ("what",    [t| QrViaLuxi |])
+    [ ("what",    [t| Qlang.ItemType |])
     , ("fields",  [t| [String]  |])
     , ("qfilter", [t| Qlang.Filter |])
     ])
diff --git a/htools/Ganeti/Qlang.hs b/htools/Ganeti/Qlang.hs
index 3a7fde2b2..78bb9fa0c 100644
--- a/htools/Ganeti/Qlang.hs
+++ b/htools/Ganeti/Qlang.hs
@@ -34,6 +34,7 @@ module Ganeti.Qlang
     , QueryFieldsResult(..)
     , FieldDefinition(..)
     , ResultEntry(..)
+    , ItemType(..)
     ) where
 
 import Control.Applicative
-- 
GitLab