From ab9320ad65cab0e86494ff5bc65c60a1c24818c6 Mon Sep 17 00:00:00 2001 From: Klaus Aehlig Date: Wed, 28 May 2014 18:41:45 +0200 Subject: [PATCH] Add RPC call master_node_name In Haskell, support the RPC call "master_node_name" by which a node is asked who it believes is the master node. Luxid will need this to carry out a voting. Signed-off-by: Klaus Aehlig Reviewed-by: Petr Pudlak --- src/Ganeti/Rpc.hs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/Ganeti/Rpc.hs b/src/Ganeti/Rpc.hs index 414284713..c6e3ed85f 100644 --- a/src/Ganeti/Rpc.hs +++ b/src/Ganeti/Rpc.hs @@ -76,6 +76,9 @@ module Ganeti.Rpc , RpcCallVersion(..) , RpcResultVersion(..) + , RpcCallMasterNodeName(..) + , RpcResultMasterNodeName(..) + , RpcCallStorageList(..) , RpcResultStorageList(..) @@ -815,3 +818,24 @@ instance Rpc RpcCallNodeActivateMasterIp RpcResultNodeActivateMasterIp where J.JSNull -> Right RpcResultNodeActivateMasterIp _ -> Left $ JsonDecodeError ("Expected JSNull, got " ++ show (pp_value res)) + +-- | Ask who the node believes is the master. + +$(buildObject "RpcCallMasterNodeName" "rpcCallMasterNodeName" []) + +instance RpcCall RpcCallMasterNodeName where + rpcCallName _ = "master_node_name" + rpcCallTimeout _ = rpcTimeoutToRaw Slow + rpcCallAcceptOffline _ = True + +$(buildObject "RpcResultMasterNodeName" "rpcResultMasterNodeName" + [ simpleField "master" [t| String |] + ]) + +instance Rpc RpcCallMasterNodeName RpcResultMasterNodeName where + rpcResultFill _ res = + case res of + J.JSString master -> Right . RpcResultMasterNodeName + $ J.fromJSString master + _ -> Left . JsonDecodeError . (++) "expected string, but got " . show + $ pp_value res -- GitLab