Commit ab9320ad authored by Klaus Aehlig's avatar Klaus Aehlig

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: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarPetr Pudlak <pudlak@google.com>
parent 4b550009
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment