Safe Haskell | None |
---|
Implementation of the iallocator interface.
Synopsis
- type IAllocResult = (String, JSValue, List, List)
- parseNic :: String -> JSRecord -> Result Nic
- parseBaseInstance :: String -> JSRecord -> Result (String, Instance)
- parseInstance :: NameAssoc -> String -> JSRecord -> Result (String, Instance)
- parseNode :: NameAssoc -> String -> JSRecord -> Result (String, Node)
- parseGroup :: String -> JSRecord -> Result (String, Group)
- parseData :: ClockTime -> String -> Int -> Result ([String], Request)
- formatResponse :: Bool -> String -> JSValue -> String
- describeSolution :: GenericAllocSolution a -> String
- formatAllocate :: List -> GenericAllocSolution a -> Result IAllocResult
- formatAllocateSecondary :: List -> GenericAllocSolution a -> Result IAllocResult
- formatMultiAlloc :: (List, List, GenericAllocSolutionList a) -> Result IAllocResult
- formatNodeEvac :: List -> List -> List -> (List, List, EvacSolution) -> Result IAllocResult
- processRelocate :: AlgorithmOptions -> List -> List -> List -> Idx -> Int -> [Ndx] -> Result (List, List, [Ndx])
- formatRelocate :: (List, List, [Ndx]) -> Result IAllocResult
- processRequest :: AlgorithmOptions -> Request -> Result IAllocResult
- readRequest :: FilePath -> Int -> IO Request
- formatIAllocResult :: Result IAllocResult -> (Maybe (List, List), String)
- runIAllocator :: AlgorithmOptions -> Request -> (Maybe (List, List), String)
- loadData :: FilePath -> Int -> IO (Result ClusterData)
Documentation
type IAllocResult = (String, JSValue, List, List) Source #
Type alias for the result of an IAllocator call.
parseNic :: String -> JSRecord -> Result Nic Source #
Parse a NIC within an instance (in a creation request)
parseBaseInstance :: String -> JSRecord -> Result (String, Instance) Source #
Parse the basic specifications of an instance.
Instances in the cluster instance list and the instance in an
Allocate
request share some common properties, which are read by
this function.
:: NameAssoc | The node name-to-index association list |
-> String | The name of the instance |
-> JSRecord | The JSON object |
-> Result (String, Instance) |
Parses an instance as found in the cluster instance list.
:: NameAssoc | The group association |
-> String | The node's name |
-> JSRecord | The JSON object |
-> Result (String, Node) |
Parses a node as found in the cluster node list.
Parses a group as found in the cluster group list.
:: ClockTime | The current time |
-> String | The JSON message as received from Ganeti |
-> Int | Static node memory size, see optStaticKvmNodeMemory |
-> Result ([String], Request) | Result tuple |
Top-level parser.
The result is a tuple of eventual warning messages and the parsed
request; if parsing the input data fails, we'll return a Bad
value.
:: Bool | Whether the request was successful |
-> String | Information text |
-> JSValue | The JSON encoded result |
-> String | The full JSON-formatted message |
Formats the result into a valid IAllocator response message.
describeSolution :: GenericAllocSolution a -> String Source #
Flatten the log of a solution into a string.
formatAllocate :: List -> GenericAllocSolution a -> Result IAllocResult Source #
Convert allocation/relocation results into the result format.
formatAllocateSecondary :: List -> GenericAllocSolution a -> Result IAllocResult Source #
Convert allocation/relocation results into the result format.
formatMultiAlloc :: (List, List, GenericAllocSolutionList a) -> Result IAllocResult Source #
Convert multi allocation results into the result format.
formatNodeEvac :: List -> List -> List -> (List, List, EvacSolution) -> Result IAllocResult Source #
Convert a node-evacuation/change group result.
:: AlgorithmOptions | |
-> List | The group list |
-> List | The node list |
-> List | The instance list |
-> Idx | The index of the instance to move |
-> Int | The number of nodes required |
-> [Ndx] | Nodes which should not be used |
-> Result (List, List, [Ndx]) | Solution list |
Runs relocate for a single instance.
This is wrapper over the tryNodeEvac
function that is run
with a single instance (ours), and further it checks that the
result it got (in the nodes field) is actually consistent, as
tryNodeEvac is designed to output primarily an opcode list, not a
node list.
formatRelocate :: (List, List, [Ndx]) -> Result IAllocResult Source #
processRequest :: AlgorithmOptions -> Request -> Result IAllocResult Source #
Process a request and return new node lists.
:: FilePath | Path to IAllocator input file |
-> Int | Static node memory size, see optStaticKvmNodeMemory |
-> IO Request |
Reads the request from the data file(s).
formatIAllocResult :: Result IAllocResult -> (Maybe (List, List), String) Source #
Format an IAlloc result to maybe the new cluster and a response.
runIAllocator :: AlgorithmOptions -> Request -> (Maybe (List, List), String) Source #
Main iallocator pipeline.
:: FilePath | Path to IAllocator input file |
-> Int | Static node memory size, see optStaticKvmNodeMemory |
-> IO (Result ClusterData) |
Load the data from an iallocation request file