ganeti
Safe HaskellNone

Ganeti.WConfd.ConfigWriter

Description

Implementation of functions specific to configuration management.

Synopsis

Documentation

targetToPredicate :: DistributionTarget -> Node -> Bool Source #

From a distribution target get a predicate on nodes whether it should be distributed to this node.

loadConfigFromFile :: FilePath -> ResultG (ConfigData, FStat) Source #

Loads the configuration from the file, if it hasn't been loaded yet. The function is internal and isn't thread safe.

writeConfigToFile :: (MonadBase IO m, MonadError GanetiException m, MonadLog m) => ConfigData -> FilePath -> FStat -> m FStat Source #

Writes the current configuration to the file. The function isn't thread safe. Neither distributes the configuration (to nodes and ssconf) nor updates the serial number.

Asynchronous tasks

finishOrLog :: (Show e, MonadLog m) => Priority -> String -> (a -> m ()) -> GenericResult e a -> m () Source #

Runs the given action on success, or logs an error on failure.

mkStatelessAsyncTask :: (MonadBaseControl IO m, MonadLog m, Show e, Monoid i) => Priority -> String -> (i -> ResultT e m ()) -> m (AsyncWorker i ()) Source #

Creates a stateless asynchronous task that handles errors in its actions.

mkStatefulAsyncTask :: (MonadBaseControl IO m, MonadLog m, Show e, Monoid i) => Priority -> String -> s -> (s -> i -> ResultT e m s) -> m (AsyncWorker i ()) Source #

Creates an asynchronous task that handles errors in its actions. If an error occurs, it's logged and the internal state remains unchanged.

saveConfigAsyncTask Source #

Arguments

:: FilePath

Path to the config file

-> FStat

The initial state of the config. file

-> IO ConfigState

An action to read the current config

-> [AsyncWorker DistributionTarget ()]

Workers to be triggered afterwards

-> ResultG (AsyncWorker (Any, DistributionTarget) ()) 

Construct an asynchronous worker whose action is to save the configuration to the master file. The worker's action reads the configuration using the given IO action and uses FStat to check if the configuration hasn't been modified by another process.

If Any of the input requests is true, given additional worker will be executed synchronously after sucessfully writing the configuration file. Otherwise, they'll be just triggered asynchronously.

execRpcCallAndLog :: Rpc a b => [Node] -> a -> ResultG () Source #

Performs a RPC call on the given list of nodes and logs any failures. If any of the calls fails, fail the computation with failError.

distMCsAsyncTask Source #

Arguments

:: RuntimeEnts 
-> FilePath

Path to the config file

-> IO ConfigState

An action to read the current config

-> ResultG (AsyncWorker DistributionTarget ()) 

Construct an asynchronous worker whose action is to distribute the configuration to master candidates.

distSSConfAsyncTask Source #

Arguments

:: IO ConfigState

An action to read the current config

-> ResultG (AsyncWorker DistributionTarget ()) 

Construct an asynchronous worker whose action is to construct SSConf and distribute it to master candidates. The worker's action reads the configuration using the given IO action, computes the current SSConf, compares it to the previous version, and if different, distributes it.