Revision 508c7d70
b/src/Ganeti/Query/Query.hs | ||
---|---|---|
70 | 70 |
import Ganeti.Errors |
71 | 71 |
import Ganeti.JQueue |
72 | 72 |
import Ganeti.JSON |
73 |
import Ganeti.Logging |
|
74 |
import qualified Ganeti.Luxi as L |
|
73 | 75 |
import Ganeti.Objects |
74 | 76 |
import Ganeti.Query.Common |
75 | 77 |
import qualified Ganeti.Query.Export as Export |
... | ... | |
78 | 80 |
import qualified Ganeti.Query.Job as Query.Job |
79 | 81 |
import qualified Ganeti.Query.Group as Group |
80 | 82 |
import Ganeti.Query.Language |
83 |
import qualified Ganeti.Query.Locks as Locks |
|
81 | 84 |
import qualified Ganeti.Query.Network as Network |
82 | 85 |
import qualified Ganeti.Query.Node as Node |
83 | 86 |
import Ganeti.Query.Types |
... | ... | |
228 | 231 |
-> IO (ErrorResult QueryResult) -- ^ Result |
229 | 232 |
query cfg live (Query (ItemTypeLuxi QRJob) fields qfilter) = |
230 | 233 |
queryJobs cfg live fields qfilter |
234 |
query _ live (Query (ItemTypeLuxi QRLock) fields qfilter) = |
|
235 |
if not live |
|
236 |
then return . Bad $ GenericError "Locks can only be queried live" |
|
237 |
else do |
|
238 |
socketpath <- defaultMasterSocket |
|
239 |
logDebug $ "Forwarding live query on locks for " ++ show fields |
|
240 |
++ ", " ++ show qfilter ++ " to " ++ socketpath |
|
241 |
cl <- L.getLuxiClient socketpath |
|
242 |
answer <- L.callMethod (L.Query (ItemTypeLuxi QRLock) fields qfilter) cl |
|
243 |
return |
|
244 |
. genericResult Bad |
|
245 |
(either (Bad . GenericError |
|
246 |
. (++) "Got unparsable answer from masterd: ") |
|
247 |
Ok |
|
248 |
. J.resultToEither . J.readJSON) |
|
249 |
$ answer |
|
250 |
|
|
231 | 251 |
query cfg live qry = queryInner cfg live qry $ getRequestedNames qry |
232 | 252 |
|
253 |
|
|
233 | 254 |
-- | Dummy data collection fuction |
234 | 255 |
dummyCollectLiveData :: Bool -> ConfigData -> [a] -> IO [(a, NoDataRuntime)] |
235 | 256 |
dummyCollectLiveData _ _ = return . map (, NoDataRuntime) |
... | ... | |
353 | 374 |
queryFields (QueryFields (ItemTypeOpCode QRInstance) fields) = |
354 | 375 |
Ok $ fieldsExtractor Instance.fieldsMap fields |
355 | 376 |
|
377 |
queryFields (QueryFields (ItemTypeLuxi QRLock) fields) = |
|
378 |
Ok $ fieldsExtractor Locks.fieldsMap fields |
|
356 | 379 |
|
357 | 380 |
queryFields (QueryFields qkind _) = |
358 | 381 |
Bad . GenericError $ "QueryFields '" ++ show qkind ++ "' not supported" |
Also available in: Unified diff