Revision b9e12624 src/Ganeti/Rpc.hs
b/src/Ganeti/Rpc.hs | ||
---|---|---|
49 | 49 |
, RpcCallAllInstancesInfo(..) |
50 | 50 |
, RpcResultAllInstancesInfo(..) |
51 | 51 |
|
52 |
, InstanceConsoleInfoParams(..) |
|
53 |
, InstanceConsoleInfo(..) |
|
54 |
, RpcCallInstanceConsoleInfo(..) |
|
55 |
, RpcResultInstanceConsoleInfo(..) |
|
56 |
|
|
52 | 57 |
, RpcCallInstanceList(..) |
53 | 58 |
, RpcResultInstanceList(..) |
54 | 59 |
|
... | ... | |
246 | 251 |
|
247 | 252 |
-- ** Instance info |
248 | 253 |
|
249 |
-- | InstanceInfo |
|
250 |
-- Returns information about a single instance. |
|
251 |
|
|
254 |
-- | Returns information about a single instance |
|
252 | 255 |
$(buildObject "RpcCallInstanceInfo" "rpcCallInstInfo" |
253 | 256 |
[ simpleField "instance" [t| String |] |
254 | 257 |
, simpleField "hname" [t| Hypervisor |] |
... | ... | |
287 | 290 |
|
288 | 291 |
-- ** AllInstancesInfo |
289 | 292 |
|
290 |
-- | AllInstancesInfo |
|
291 |
-- Returns information about all running instances on the given nodes |
|
293 |
-- | Returns information about all running instances on the given nodes |
|
292 | 294 |
$(buildObject "RpcCallAllInstancesInfo" "rpcCallAllInstInfo" |
293 | 295 |
[ simpleField "hypervisors" [t| [(Hypervisor, HvParams)] |] ]) |
294 | 296 |
|
... | ... | |
316 | 318 |
_ -> Left $ JsonDecodeError |
317 | 319 |
("Expected JSObject, got " ++ show (pp_value res)) |
318 | 320 |
|
321 |
-- ** InstanceConsoleInfo |
|
322 |
|
|
323 |
-- | Returns information about how to access instances on the given node |
|
324 |
$(buildObject "InstanceConsoleInfoParams" "instConsInfoParams" |
|
325 |
[ simpleField "instance" [t| Instance |] |
|
326 |
, simpleField "node" [t| Node |] |
|
327 |
, simpleField "hvParams" [t| HvParams |] |
|
328 |
, simpleField "beParams" [t| FilledBeParams |] |
|
329 |
]) |
|
330 |
|
|
331 |
$(buildObject "RpcCallInstanceConsoleInfo" "rpcCallInstConsInfo" |
|
332 |
[ simpleField "instanceInfo" [t| [(String, InstanceConsoleInfoParams)] |] ]) |
|
333 |
|
|
334 |
$(buildObject "InstanceConsoleInfo" "instConsInfo" |
|
335 |
[ simpleField "instance" [t| String |] |
|
336 |
, simpleField "kind" [t| String |] |
|
337 |
, optionalField $ |
|
338 |
simpleField "message" [t| String |] |
|
339 |
, optionalField $ |
|
340 |
simpleField "host" [t| String |] |
|
341 |
, optionalField $ |
|
342 |
simpleField "port" [t| Int |] |
|
343 |
, optionalField $ |
|
344 |
simpleField "user" [t| String |] |
|
345 |
, optionalField $ |
|
346 |
simpleField "command" [t| [String] |] |
|
347 |
, optionalField $ |
|
348 |
simpleField "display" [t| String |] |
|
349 |
]) |
|
350 |
|
|
351 |
$(buildObject "RpcResultInstanceConsoleInfo" "rpcResInstConsInfo" |
|
352 |
[ simpleField "instancesInfo" [t| [(String, InstanceConsoleInfo)] |] ]) |
|
353 |
|
|
354 |
instance RpcCall RpcCallInstanceConsoleInfo where |
|
355 |
rpcCallName _ = "instance_console_info" |
|
356 |
rpcCallTimeout _ = rpcTimeoutToRaw Urgent |
|
357 |
rpcCallAcceptOffline _ = False |
|
358 |
rpcCallData _ call = J.encode . |
|
359 |
GenericContainer $ Map.fromList (rpcCallInstConsInfoInstanceInfo call) |
|
360 |
|
|
361 |
instance Rpc RpcCallInstanceConsoleInfo RpcResultInstanceConsoleInfo where |
|
362 |
rpcResultFill _ res = |
|
363 |
case res of |
|
364 |
J.JSObject res' -> |
|
365 |
let res'' = map (second J.readJSON) (J.fromJSObject res') |
|
366 |
:: [(String, J.Result InstanceConsoleInfo)] in |
|
367 |
case sanitizeDictResults res'' of |
|
368 |
Left err -> Left err |
|
369 |
Right instInfos -> Right $ RpcResultInstanceConsoleInfo instInfos |
|
370 |
_ -> Left $ JsonDecodeError |
|
371 |
("Expected JSObject, got " ++ show (pp_value res)) |
|
372 |
|
|
319 | 373 |
-- ** InstanceList |
320 | 374 |
|
321 |
-- | InstanceList |
|
322 |
-- Returns the list of running instances on the given nodes. |
|
375 |
-- | Returns the list of running instances on the given nodes |
|
323 | 376 |
$(buildObject "RpcCallInstanceList" "rpcCallInstList" |
324 | 377 |
[ simpleField "hypervisors" [t| [Hypervisor] |] ]) |
325 | 378 |
|
... | ... | |
337 | 390 |
|
338 | 391 |
-- ** NodeInfo |
339 | 392 |
|
340 |
-- | NodeInfo |
|
341 |
-- Return node information. |
|
393 |
-- | Returns node information |
|
342 | 394 |
$(buildObject "RpcCallNodeInfo" "rpcCallNodeInfo" |
343 | 395 |
[ simpleField "storage_units" [t| Map.Map String [StorageUnit] |] |
344 | 396 |
, simpleField "hypervisors" [t| [ (Hypervisor, HvParams) ] |] |
Also available in: Unified diff