Revision 518023a9

b/htools/Ganeti/Qlang.hs
294 294
data QueryFields = QueryFields ItemType Fields
295 295

  
296 296
-- | Query2 Fields result.
297
data QueryFieldsResult = QueryFieldsResult [ FieldDefinition ]
297
$(buildObject "QueryFieldsResult" "qfieldres"
298
  [ simpleField "fields" [t| [FieldDefinition ] |]
299
  ])
b/htools/Ganeti/Query/Query.hs
25 25

  
26 26
module Ganeti.Query.Query
27 27
    ( query
28
    , queryFields
28 29
    ) where
29 30

  
30 31
import Data.Maybe (fromMaybe)
......
79 80

  
80 81
query _ (Query qkind _ _) =
81 82
  return . Bad $ "Query '" ++ show qkind ++ "' not supported"
83

  
84
-- | Query fields call.
85
queryFields :: QueryFields -> Result QueryFieldsResult
86
queryFields (QueryFields QRNode fields) =
87
  let selected = if null fields
88
                   then map snd $ Map.toAscList nodeFieldsMap
89
                   else getSelectedFields nodeFieldsMap fields
90
  in Ok $ QueryFieldsResult (map fst selected)
91

  
92
queryFields (QueryFields qkind _) =
93
  Bad $ "QueryFields '" ++ show qkind ++ "' not supported"
b/htools/Ganeti/Queryd.hs
131 131
  result <- query cfg (Qlang.Query qkind qfields qfilter)
132 132
  return $ J.showJSON <$> result
133 133

  
134
handleCall _ (QueryFields qkind qfields) = do
135
  let result = queryFields (Qlang.QueryFields qkind qfields)
136
  return $ J.showJSON <$> result
137

  
134 138
handleCall _ op =
135 139
  return . Bad $ "Luxi call '" ++ strOfOp op ++ "' not implemented"
136 140

  

Also available in: Unified diff