ganeti
Safe HaskellNone

Ganeti.HTools.Backend.IAlloc

Description

Implementation of the iallocator interface.

Synopsis

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.

parseInstance Source #

Arguments

:: 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.

parseNode Source #

Arguments

:: 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.

parseGroup Source #

Arguments

:: String

The group UUID

-> JSRecord

The JSON object

-> Result (String, Group) 

Parses a group as found in the cluster group list.

parseData Source #

Arguments

:: 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.

formatResponse Source #

Arguments

:: 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.

processRelocate Source #

Arguments

:: 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.

processRequest :: AlgorithmOptions -> Request -> Result IAllocResult Source #

Process a request and return new node lists.

readRequest Source #

Arguments

:: 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.

loadData Source #

Arguments

:: FilePath

Path to IAllocator input file

-> Int

Static node memory size, see optStaticKvmNodeMemory

-> IO (Result ClusterData) 

Load the data from an iallocation request file