Revision de2a5704

b/htools/Ganeti/Rpc.hs
64 64
  , RpcCallStorageList(..)
65 65
  , RpcResultStorageList(..)
66 66

  
67
  , RpcCallTestDelay(..)
68
  , RpcResultTestDelay(..)
69

  
67 70
  , rpcTimeoutFromRaw -- FIXME: Not used anywhere
68 71
  ) where
69 72

  
......
83 86
import Ganeti.Compat
84 87
import Ganeti.JSON
85 88

  
89
-- * Base RPC functionality and types
90

  
86 91
#ifndef NO_CURL
87 92
-- | The curl options used for RPC.
88 93
curlOpts :: [CurlOption]
......
243 248

  
244 249
-- * RPC calls and results
245 250

  
251
-- ** Instance info
252

  
246 253
-- | InstanceInfo
247 254
--   Returns information about a single instance.
248 255

  
......
282 289
      _ -> Left $ JsonDecodeError
283 290
           ("Expected JSObject, got " ++ show (pp_value res))
284 291

  
292
-- ** AllInstancesInfo
293

  
285 294
-- | AllInstancesInfo
286 295
--   Returns information about all running instances on the given nodes
287 296
$(buildObject "RpcCallAllInstancesInfo" "rpcCallAllInstInfo"
......
309 318
      _ -> Left $ JsonDecodeError
310 319
           ("Expected JSObject, got " ++ show (pp_value res))
311 320

  
321
-- ** InstanceList
322

  
312 323
-- | InstanceList
313 324
-- Returns the list of running instances on the given nodes.
314 325
$(buildObject "RpcCallInstanceList" "rpcCallInstList"
......
326 337
instance Rpc RpcCallInstanceList RpcResultInstanceList where
327 338
  rpcResultFill _ res = fromJSValueToRes res RpcResultInstanceList
328 339

  
340
-- ** NodeInfo
341

  
329 342
-- | NodeInfo
330 343
-- Return node information.
331 344
$(buildObject "RpcCallNodeInfo" "rpcCallNodeInfo"
......
368 381
  rpcResultFill _ res =
369 382
    fromJSValueToRes res (\(b, vg, hv) -> RpcResultNodeInfo b vg hv)
370 383

  
384
-- ** Version
385

  
371 386
-- | Version
372 387
-- Query node version.
373 388
-- Note: We can't use THH as it does not know what to do with empty dict
......
392 407
instance Rpc RpcCallVersion RpcResultVersion where
393 408
  rpcResultFill _ res = fromJSValueToRes res RpcResultVersion
394 409

  
410
-- ** StorageList
411

  
395 412
-- | StorageList
396 413
-- Get list of storage units.
397 414
-- FIXME: This may be moved to Objects
......
439 456
  rpcResultFill call res =
440 457
    let sfields = rpcCallStorageListFields call in
441 458
    fromJSValueToRes res (RpcResultStorageList . map (zip sfields))
459

  
460
-- ** TestDelay
461

  
462

  
463
-- | Call definition for test delay.
464
$(buildObject "RpcCallTestDelay" "rpcCallTestDelay"
465
  [ simpleField "duration" [t| Double |]
466
  ])
467

  
468
-- | Result definition for test delay.
469
data RpcResultTestDelay = RpcResultTestDelay
470
                          deriving Show
471

  
472
-- | Custom JSON instance for null result.
473
instance J.JSON RpcResultTestDelay where
474
  showJSON _        = J.JSNull
475
  readJSON J.JSNull = return RpcResultTestDelay
476
  readJSON _        = fail "Unable to read RpcResultTestDelay"
477

  
478
instance RpcCall RpcCallTestDelay where
479
  rpcCallName _          = "test_delay"
480
  rpcCallTimeout         = ceiling . (+ 5) . rpcCallTestDelayDuration
481
  rpcCallAcceptOffline _ = False
482
  rpcCallData _ call     = J.encode [rpcCallTestDelayDuration call]
483

  
484
instance Rpc RpcCallTestDelay RpcResultTestDelay where
485
  rpcResultFill _ res = fromJSValueToRes res id

Also available in: Unified diff