Safe Haskell | None |
---|
Parsing data from text-files.
This module holds the code for loading the cluster state from text
files, as produced by gnt-node
and gnt-instance
list
command.
Synopsis
- commaSplit :: String -> [String]
- serializeGroup :: Group -> String
- serializeGroups :: List -> String
- serializeNode :: List -> Node -> String
- serializeNodes :: List -> List -> String
- serializeInstance :: List -> Instance -> String
- serializeInstances :: List -> List -> String
- iSpecsSeparator :: Char
- serializeISpec :: ISpec -> String
- serializeDiskTemplates :: [DiskTemplate] -> String
- serializeMultipleMinMaxISpecs :: [MinMaxISpecs] -> String
- serializeIPolicy :: String -> IPolicy -> String
- serializeAllIPolicies :: IPolicy -> List -> String
- serializeCluster :: ClusterData -> String
- loadGroup :: MonadFail m => [String] -> m (String, Group)
- loadNode :: MonadFail m => NameAssoc -> [String] -> m (String, Node)
- loadInst :: NameAssoc -> [String] -> Result (String, Instance)
- loadISpec :: String -> [String] -> Result ISpec
- loadMinMaxISpecs :: String -> String -> String -> Result MinMaxISpecs
- breakISpecsPairs :: String -> [String] -> Result [(String, String)]
- loadMultipleMinMaxISpecs :: String -> [String] -> Result [MinMaxISpecs]
- loadIPolicy :: [String] -> Result (String, IPolicy)
- loadOnePolicy :: (IPolicy, List) -> String -> Result (IPolicy, List)
- loadAllIPolicies :: List -> [String] -> Result (IPolicy, List)
- loadTabular :: (MonadFail m, Element a) => [String] -> ([String] -> m (String, a)) -> m (NameAssoc, Container a)
- readData :: String -> IO String
- parseData :: String -> Result ClusterData
- loadData :: String -> IO (Result ClusterData)
Helper functions
commaSplit :: String -> [String] Source #
Simple wrapper over sepSplit
Serialisation functions
serializeGroup :: Group -> String Source #
Serialize a single group.
serializeGroups :: List -> String Source #
Generate group file data from a group list.
Serialize a single node.
serializeNodes :: List -> List -> String Source #
Generate node file data from node objects.
Serialize a single instance.
serializeInstances :: List -> List -> String Source #
Generate instance file data from instance objects.
iSpecsSeparator :: Char Source #
Separator between ISpecs (in MinMaxISpecs).
serializeISpec :: ISpec -> String Source #
Generate a spec data from a given ISpec object.
serializeDiskTemplates :: [DiskTemplate] -> String Source #
Generate disk template data.
serializeMultipleMinMaxISpecs :: [MinMaxISpecs] -> String Source #
Generate min/max instance specs data.
serializeIPolicy :: String -> IPolicy -> String Source #
Generate policy data from a given policy object.
serializeAllIPolicies :: IPolicy -> List -> String Source #
Generates the entire ipolicy section from the cluster and group objects.
serializeCluster :: ClusterData -> String Source #
Generate complete cluster data from node and instance lists.
Parsing functions
:: MonadFail m | |
=> [String] | |
-> m (String, Group) | The result, a tuple of group UUID and group object |
Load a group from a field list.
:: MonadFail m | |
=> NameAssoc | Association list with current groups |
-> [String] | Input data as a list of fields |
-> m (String, Node) | The result, a tuple o node name and node object |
Load a node from a field list.
:: NameAssoc | Association list with the current nodes |
-> [String] | Input data as a list of fields |
-> Result (String, Instance) | A tuple of instance name and the instance object |
Load an instance from a field list.
loadMinMaxISpecs :: String -> String -> String -> Result MinMaxISpecs Source #
Load a single min/max ISpec pair
breakISpecsPairs :: String -> [String] -> Result [(String, String)] Source #
Break a list of ispecs strings into a list of (min/max) ispecs pairs
loadMultipleMinMaxISpecs :: String -> [String] -> Result [MinMaxISpecs] Source #
Load a list of min/max ispecs pairs
loadIPolicy :: [String] -> Result (String, IPolicy) Source #
Loads an ipolicy from a field list.
loadAllIPolicies :: List -> [String] -> Result (IPolicy, List) Source #
Loads all policies from the policy section
:: (MonadFail m, Element a) | |
=> [String] | Input data, as a list of lines |
-> ([String] -> m (String, a)) | Conversion function |
-> m (NameAssoc, Container a) | A tuple of an association list (name to object) and a set as used in Ganeti.HTools.Container |
Convert newline and delimiter-separated text.
This function converts a text in tabular format as generated by
gnt-instance list
and gnt-node list
to a list of objects using
a supplied conversion function.
:: String | Path to the text file |
-> IO String | Contents of the file |
Load the cluser data from disk.
This is an alias to readFile
just for consistency with the other
modules.
:: String | Path to the text file |
-> IO (Result ClusterData) |
Top level function for data loading.