ganeti

Safe HaskellSafe-Infered

Ganeti.Confd.Utils

Description

Implementation of the Ganeti confd utilities.

This holds a few utility functions that could be useful in both clients and servers.

Synopsis

Documentation

getClusterHmac :: IO HashKeySource

Returns the HMAC key.

parseSignedMessage :: JSON a => HashKey -> String -> Result (String, String, a)Source

Parses a signed message.

parseRequest :: HashKey -> String -> Integer -> Result (String, ConfdRequest)Source

Message parsing. This can either result in a good, valid request message, or fail in the Result monad.

parseReply :: HashKey -> String -> String -> Result (String, ConfdReply)Source

Message parsing. This can either result in a good, valid reply message, or fail in the Result monad. It also checks that the salt in the message corresponds to the one that is expected

signMessage :: HashKey -> String -> String -> SignedMessageSource

Signs a message with a given key and salt.

data Pointer Source

Constructors

Pointer [String] 

Instances

Eq Pointer 
Show Pointer 

readInteger :: String -> Result IntSource

pointerFromString :: String -> Result PointerSource

extractValue :: JSON a => Pointer -> a -> Result JSValueSource

extractJSONPath :: JSON a => String -> a -> Result JSValueSource

Extract a JSValue from an object at the position defined by the path.

The path syntax follows RCF6901. Error is returned if the path doesn't exist, Ok if the path leads to an valid value.

JSON pointer syntax according to RFC6901:

 "/path/0/x" => Pointer ["path", "0", "x"]

This accesses 1 in the following JSON:

 { "path": { "0": { "x": 1 } } }

or the following:

 { "path": [{"x": 1}] }