Revision 35cded14 src/Ganeti/Rpc.hs

b/src/Ganeti/Rpc.hs
139 139
type ERpcError = Either RpcError
140 140

  
141 141
-- | A generic class for RPC calls.
142
class (J.JSON a) => RpcCall a where
142
class (ArrayObject a) => RpcCall a where
143 143
  -- | Give the (Python) name of the procedure.
144 144
  rpcCallName :: a -> String
145 145
  -- | Calculate the timeout value for the call execution.
146 146
  rpcCallTimeout :: a -> Int
147 147
  -- | Prepare arguments of the call to be send as POST.
148 148
  rpcCallData :: Node -> a -> String
149
  rpcCallData _ = J.encode . J.JSArray . toJSArray
149 150
  -- | Whether we accept offline nodes when making a call.
150 151
  rpcCallAcceptOffline :: a -> Bool
151 152

  
......
318 319
  rpcCallName _          = "instance_info"
319 320
  rpcCallTimeout _       = rpcTimeoutToRaw Urgent
320 321
  rpcCallAcceptOffline _ = False
321
  rpcCallData _ call     = J.encode
322
    ( rpcCallInstInfoInstance call
323
    , rpcCallInstInfoHname call
324
    )
325 322

  
326 323
instance Rpc RpcCallInstanceInfo RpcResultInstanceInfo where
327 324
  rpcResultFill _ res =
......
429 426
  rpcCallName _          = "instance_list"
430 427
  rpcCallTimeout _       = rpcTimeoutToRaw Urgent
431 428
  rpcCallAcceptOffline _ = False
432
  rpcCallData _ call     = J.encode [rpcCallInstListHypervisors call]
433 429

  
434 430
instance Rpc RpcCallInstanceList RpcResultInstanceList where
435 431
  rpcResultFill _ res = fromJSValueToRes res RpcResultInstanceList
......
518 514
  rpcCallName _          = "storage_list"
519 515
  rpcCallTimeout _       = rpcTimeoutToRaw Normal
520 516
  rpcCallAcceptOffline _ = False
521
  rpcCallData _ call     = J.encode
522
    ( rpcCallStorageListSuName call
523
    , rpcCallStorageListSuArgs call
524
    , rpcCallStorageListName call
525
    , rpcCallStorageListFields call
526
    )
527 517

  
528 518
instance Rpc RpcCallStorageList RpcResultStorageList where
529 519
  rpcResultFill call res =
......
551 541
  rpcCallName _          = "test_delay"
552 542
  rpcCallTimeout         = ceiling . (+ 5) . rpcCallTestDelayDuration
553 543
  rpcCallAcceptOffline _ = False
554
  rpcCallData _ call     = J.encode [rpcCallTestDelayDuration call]
555 544

  
556 545
instance Rpc RpcCallTestDelay RpcResultTestDelay where
557 546
  rpcResultFill _ res = fromJSValueToRes res id
......
618 607
  rpcCallName _          = "jobqueue_rename"
619 608
  rpcCallTimeout _       = rpcTimeoutToRaw Fast
620 609
  rpcCallAcceptOffline _ = False
621
  rpcCallData _ call     = J.encode [ rpcCallJobqueueRenameRename call ]
622 610

  
623 611
instance Rpc RpcCallJobqueueRename RpcResultJobqueueRename where
624 612
  rpcResultFill call res =
......
644 632
  rpcCallName _          = "set_watcher_pause"
645 633
  rpcCallTimeout _       = rpcTimeoutToRaw Fast
646 634
  rpcCallAcceptOffline _ = False
647
  rpcCallData _ call     = J.encode
648
    [ maybe J.JSNull (J.showJSON . TimeAsDoubleJSON) $
649
            rpcCallSetWatcherPauseTime call ]
650 635

  
651 636
$(buildObject "RpcResultSetWatcherPause" "rpcResultSetWatcherPause" [])
652 637

  
......
669 654
  rpcCallName _          = "jobqueue_set_drain_flag"
670 655
  rpcCallTimeout _       = rpcTimeoutToRaw Fast
671 656
  rpcCallAcceptOffline _ = False
672
  rpcCallData _ call     = J.encode [ rpcCallSetDrainFlagValue call ]
673 657

  
674 658
$(buildObject "RpcResultSetDrainFlag" "rpcResultSetDrainFalg" [])
675 659

  

Also available in: Unified diff