Revision a6e406ce

b/src/Ganeti/Query/Query.hs
69 69
import Ganeti.Errors
70 70
import Ganeti.JQueue
71 71
import Ganeti.JSON
72
import Ganeti.Logging
73
import qualified Ganeti.Luxi as L
72 74
import Ganeti.Objects
73 75
import Ganeti.Query.Common
74 76
import qualified Ganeti.Query.Export as Export
......
77 79
import qualified Ganeti.Query.Job as Query.Job
78 80
import qualified Ganeti.Query.Group as Group
79 81
import Ganeti.Query.Language
82
import qualified Ganeti.Query.Locks as Locks
80 83
import qualified Ganeti.Query.Network as Network
81 84
import qualified Ganeti.Query.Node as Node
82 85
import Ganeti.Query.Types
......
219 222
      -> IO (ErrorResult QueryResult) -- ^ Result
220 223
query cfg live (Query (ItemTypeLuxi QRJob) fields qfilter) =
221 224
  queryJobs cfg live fields qfilter
225
query _ live (Query (ItemTypeLuxi QRLock) fields qfilter) =
226
  if not live
227
    then return . Bad $ GenericError "Locks can only be queried live"
228
    else do
229
      socketpath <- defaultMasterSocket
230
      logDebug $ "Forwarding live query on locks for " ++ show fields
231
                   ++ ", " ++ show qfilter ++ " to " ++ socketpath
232
      cl <- L.getLuxiClient socketpath
233
      answer <- L.callMethod (L.Query (ItemTypeLuxi QRLock) fields qfilter) cl
234
      return
235
        . genericResult Bad
236
            (either (Bad . GenericError
237
                       . (++) "Got unparsable answer from masterd: ")
238
               Ok
239
             . J.resultToEither . J.readJSON)
240
        $ answer
241

  
222 242
query cfg live qry = queryInner cfg live qry $ getRequestedNames qry
223 243

  
244

  
224 245
-- | Dummy data collection fuction
225 246
dummyCollectLiveData :: Bool -> ConfigData -> [a] -> IO [(a, NoDataRuntime)]
226 247
dummyCollectLiveData _ _ = return . map (, NoDataRuntime)
......
344 365
queryFields (QueryFields (ItemTypeOpCode QRInstance) fields) =
345 366
  Ok $ fieldsExtractor Instance.fieldsMap fields
346 367

  
368
queryFields (QueryFields (ItemTypeLuxi QRLock) fields) =
369
  Ok $ fieldsExtractor Locks.fieldsMap fields
347 370

  
348 371
queryFields (QueryFields qkind _) =
349 372
  Bad . GenericError $ "QueryFields '" ++ show qkind ++ "' not supported"

Also available in: Unified diff