Revision ed7f7fd9
b/src/Ganeti/Luxi.hs | ||
---|---|---|
52 | 52 |
, allLuxiCalls |
53 | 53 |
) where |
54 | 54 |
|
55 |
import Control.Applicative (optional) |
|
55 | 56 |
import Control.Monad |
56 | 57 |
import qualified Data.ByteString.UTF8 as UTF8 |
57 | 58 |
import Text.JSON (encodeStrict, decodeStrict) |
... | ... | |
157 | 158 |
) |
158 | 159 |
, (luxiReqSetWatcherPause, |
159 | 160 |
[ optionalNullSerField |
160 |
$ simpleField "duration" [t| Double |] ]
|
|
161 |
$ timeAsDoubleField "duration" ]
|
|
161 | 162 |
) |
162 | 163 |
]) |
163 | 164 |
|
... | ... | |
288 | 289 |
[flag] <- fromJVal args |
289 | 290 |
return $ SetDrainFlag flag |
290 | 291 |
ReqSetWatcherPause -> do |
291 |
let duration = case args of |
|
292 |
JSArray [JSRational _ x] |
|
293 |
-> Just (fromRational x :: Double) |
|
294 |
_ -> Nothing |
|
292 |
duration <- optional $ do |
|
293 |
[x] <- fromJVal args |
|
294 |
liftM unTimeAsDoubleJSON $ fromJVal x |
|
295 | 295 |
return $ SetWatcherPause duration |
296 | 296 |
|
297 | 297 |
-- | Check that luxi responses contain the required keys and that the |
b/src/Ganeti/Query/Server.hs | ||
---|---|---|
293 | 293 |
. Config.getNode cfg . clusterMasterNode |
294 | 294 |
$ configCluster cfg |
295 | 295 |
_ <- executeRpcCall (masters ++ mcs) $ RpcCallSetWatcherPause time |
296 |
return . Ok . maybe JSNull showJSON $ time |
|
296 |
return . Ok . maybe JSNull showJSON $ fmap TimeAsDoubleJSON time
|
|
297 | 297 |
|
298 | 298 |
handleCall _ _ cfg (SetDrainFlag value) = do |
299 | 299 |
let mcs = Config.getMasterCandidates cfg |
b/src/Ganeti/Rpc.hs | ||
---|---|---|
610 | 610 |
-- | Set the watcher status |
611 | 611 |
|
612 | 612 |
$(buildObject "RpcCallSetWatcherPause" "rpcCallSetWatcherPause" |
613 |
[ simpleField "time" [t| Maybe Double |]
|
|
613 |
[ optionalField $ timeAsDoubleField "time"
|
|
614 | 614 |
]) |
615 | 615 |
|
616 | 616 |
instance RpcCall RpcCallSetWatcherPause where |
... | ... | |
618 | 618 |
rpcCallTimeout _ = rpcTimeoutToRaw Fast |
619 | 619 |
rpcCallAcceptOffline _ = False |
620 | 620 |
rpcCallData _ call = J.encode |
621 |
[ maybe J.JSNull J.showJSON $ rpcCallSetWatcherPauseTime call ] |
|
621 |
[ maybe J.JSNull (J.showJSON . TimeAsDoubleJSON) $ |
|
622 |
rpcCallSetWatcherPauseTime call ] |
|
622 | 623 |
|
623 | 624 |
$(buildObject "RpcResultSetWatcherPause" "rpcResultSetWatcherPause" []) |
624 | 625 |
|
Also available in: Unified diff