ganeti
Safe HaskellNone

Ganeti.HTools.Backend.Luxi

Description

Implementation of the LUXI loader.

Synopsis

Utility functions

getData :: MonadFail m => JSValue -> m JSValue Source #

Get values behind "data" part of the result.

parseQueryField :: MonadFail m => JSValue -> m (JSValue, JSValue) Source #

Converts a (status, value) into m value, if possible.

parseQueryRow :: MonadFail m => JSValue -> m [(JSValue, JSValue)] Source #

Parse a result row.

parseQueryResult :: MonadFail m => JSValue -> m [[(JSValue, JSValue)]] Source #

Parse an overall query result and get the [(status, value)] list for each element queried.

extractArray :: MonadFail m => JSValue -> m [[(JSValue, JSValue)]] Source #

Prepare resulting output as parsers expect it.

fromJValWithStatus :: (JSON a, MonadFail m) => (JSValue, JSValue) -> m a Source #

Testing result status for more verbose error message.

annotateConvert :: String -> String -> String -> Result a -> Result a Source #

genericConvert Source #

Arguments

:: JSON a 
=> String

The object type

-> String

The object name

-> String

The attribute we're trying to convert

-> (JSValue, JSValue)

The value we're trying to convert

-> Result a

The annotated result

Annotate errors when converting values with owner/attribute for better debugging.

convertArrayMaybe Source #

Arguments

:: JSON a 
=> String

The object type

-> String

The object name

-> String

The attribute we're trying to convert

-> (JSValue, JSValue)

The value we're trying to convert

-> Result [Maybe a]

The annotated result

Data querying functionality

queryNodesMsg :: LuxiOp Source #

The input data for node query.

queryInstancesMsg :: LuxiOp Source #

The input data for instance query.

queryClusterInfoMsg :: LuxiOp Source #

The input data for cluster query.

queryGroupsMsg :: LuxiOp Source #

The input data for node group query.

queryNodes :: Client -> IO (Result JSValue) Source #

Wraper over callMethod doing node query.

queryInstances :: Client -> IO (Result JSValue) Source #

Wraper over callMethod doing instance query.

queryClusterInfo :: Client -> IO (Result JSValue) Source #

Wrapper over callMethod doing cluster information query.

queryGroups :: Client -> IO (Result JSValue) Source #

Wrapper over callMethod doing group query.

getInstances :: NameAssoc -> JSValue -> Result [(String, Instance)] Source #

Parse a instance list in JSON format.

parseInstance :: NameAssoc -> [(JSValue, JSValue)] -> Result (String, Instance) Source #

Construct an instance from a JSON object.

getNodes :: NameAssoc -> JSValue -> Result [(String, Node)] Source #

Parse a node list in JSON format.

parseNode :: NameAssoc -> [(JSValue, JSValue)] -> Result (String, Node) Source #

Construct a node from a JSON object.

getClusterData :: JSValue -> Result ([String], IPolicy, String, Hypervisor) Source #

Parses the cluster tags.

getGroups :: JSValue -> Result [(String, Group)] Source #

Parses the cluster groups.

parseGroup :: [(JSValue, JSValue)] -> Result (String, Group) Source #

Parses a given group information.

Main loader functionality

readData Source #

Arguments

:: String

Unix socket to use as source

-> IO (Result JSValue, Result JSValue, Result JSValue, Result JSValue) 

Builds the cluster data by querying a given socket name.

parseData :: (Result JSValue, Result JSValue, Result JSValue, Result JSValue) -> Result ClusterData Source #

Converts the output of readData into the internal cluster representation.

loadData Source #

Arguments

:: String

Unix socket to use as source

-> IO (Result ClusterData) 

Top level function for data loading.