On Tue, Aug 21, 2012 at 3:05 PM, Iustin Pop <[email protected]> wrote: > > 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 <[email protected]> > --- > 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 1374f33..fb1699d 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 c0dd481..21fbf59 100644 > --- a/htools/Ganeti/HTools/QC.hs > +++ b/htools/Ganeti/HTools/QC.hs > @@ -567,6 +567,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 > @@ -1824,9 +1827,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 70c7785..939302c 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 3a7fde2..78bb9fa 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 > -- > 1.7.7.3 >
LGTM
