ganeti
Safe HaskellNone

Ganeti.Confd.Server

Description

Implementation of the Ganeti confd server functionality.

Synopsis

Types and constants definitions

type CRef = IORef (Result (ConfigData, LinkIpMap)) Source #

What we store as configuration.

type StatusAnswer = (ConfdReplyStatus, JSValue, Int) Source #

A small type alias for readability.

queryUnknownEntry :: StatusAnswer Source #

Unknown entry standard response.

queryArgumentError :: StatusAnswer Source #

Argument error standard response.

gntErrorToResult :: ErrorResult a -> Result a Source #

Converter from specific error to a string format.

Confd base functionality

nodeRole :: ConfigData -> String -> Result ConfdNodeRole Source #

Computes the node role

getNodePipByInstanceIp :: ConfigData -> LinkIpMap -> String -> String -> StatusAnswer Source #

Does an instance ip -> instance -> primary node -> primary ip transformation.

uuidToNodeName :: ConfigData -> String -> Result String Source #

Returns a node name for a given UUID

encodeMinors :: ConfigData -> (String, Int, String, String, String, String) -> Result JSValue Source #

Encodes a list of minors into a JSON representation, converting UUIDs to names in the process

buildResponse :: (ConfigData, LinkIpMap) -> ConfdRequest -> Result StatusAnswer Source #

Builds the response to a given query.

serializeResponse :: Result StatusAnswer -> ConfdReply Source #

Creates a ConfdReply from a given answer.

Client input/output handlers

responder :: CRef -> Socket -> HashKey -> String -> SockAddr -> IO () Source #

Main loop for a given client.

respondInner :: Result (ConfigData, LinkIpMap) -> HashKey -> ConfdRequest -> String Source #

Inner helper function for a given client. This generates the final encoded message (as a string), ready to be sent out to the client.

listener :: Socket -> HashKey -> (Socket -> HashKey -> String -> SockAddr -> IO ()) -> IO () Source #

Main listener loop.

type PrepResult = (Socket, IORef (Result (ConfigData, LinkIpMap))) Source #

Type alias for prepMain results

checkMain :: CheckFn (Family, SockAddr) Source #

Check function for confd.

prepMain :: PrepFn (Family, SockAddr) PrepResult Source #

Prepare function for confd.

main :: MainFn (Family, SockAddr) PrepResult Source #

Main function.