ganeti
Safe HaskellNone

Ganeti.HTools.Loader

Description

Generic data loader.

This module holds the common code for parsing the input data after it has been loaded from external sources.

Synopsis

Types

data RqType Source #

The iallocator request type.

This type denotes what request we got from Ganeti and also holds request-specific fields.

Constructors

Allocate Instance AllocDetails (Maybe [String])

A new instance allocation, maybe with allocation restrictions

AllocateSecondary Idx

Find a suitable secondary node for disk conversion

Relocate Idx Int [Ndx]

Choose a new secondary node

NodeEvacuate [Idx] EvacMode

node-evacuate mode

ChangeGroup [Gdx] [Idx]

Multi-relocate mode

MultiAllocate [(Instance, AllocDetails)]

Multi-allocate mode

Instances

Instances details
Show RqType # 
Instance details

Defined in Ganeti.HTools.Loader

Methods

showsPrec :: Int -> RqType -> ShowS

show :: RqType -> String

showList :: [RqType] -> ShowS

data Request Source #

A complete request, as received from Ganeti.

Constructors

Request RqType ClusterData 

Instances

Instances details
Show Request # 
Instance details

Defined in Ganeti.HTools.Loader

Methods

showsPrec :: Int -> Request -> ShowS

show :: Request -> String

showList :: [Request] -> ShowS

isAllocationRequest :: RqType -> Maybe (Maybe String) Source #

Decide whether a request asks to allocate new instances; if so, also return the desired node group, if a unique node group is specified. That is, return Nothing if the request is not an allocation request, `Just Nothing`, if it is an Allocation request, but there is no unique group specified, and return `Just (Just g)` if it is an allocation request uniquely requesting Group g.

data ClusterData Source #

The cluster state.

Constructors

ClusterData 

Fields

Instances

Instances details
Eq ClusterData # 
Instance details

Defined in Ganeti.HTools.Loader

Methods

(==) :: ClusterData -> ClusterData -> Bool

(/=) :: ClusterData -> ClusterData -> Bool

Show ClusterData # 
Instance details

Defined in Ganeti.HTools.Loader

Methods

showsPrec :: Int -> ClusterData -> ShowS

show :: ClusterData -> String

showList :: [ClusterData] -> ShowS

emptyCluster :: ClusterData Source #

An empty cluster.

Functions

lookupNode :: MonadFail m => NameAssoc -> String -> String -> m Ndx Source #

Lookups a node into an assoc list.

lookupInstance :: MonadFail m => NameAssoc -> String -> m Idx Source #

Lookups an instance into an assoc list.

lookupGroup :: MonadFail m => NameAssoc -> String -> String -> m Gdx Source #

Lookups a group into an assoc list.

assignIndices :: Element a => [(String, a)] -> (NameAssoc, Container a) Source #

Given a list of elements (and their names), assign indices to them.

setMaster :: MonadFail m => NameAssoc -> List -> String -> m List Source #

Given am indexed node list, and the name of the master, mark it as such.

setLocationScore :: List -> Instance -> Instance Source #

Given the nodes with the location tags already set correctly, compute the location score for an instance.

fixNodes :: List -> Instance -> List Source #

For each instance, add its index to its primary and secondary nodes.

setNodePolicy :: List -> Node -> Node Source #

Set the node's policy to its group one. Note that this requires the group to exist (should have been checked before), otherwise it will abort with a runtime error.

updateExclTags :: [String] -> Instance -> Instance Source #

Update instance with exclusion tags list.

updateDesiredLocationTags :: [String] -> Instance -> Instance Source #

Update instance with desired location tags list.

updateMovable Source #

Arguments

:: [String]

Selected instances (if not empty)

-> [String]

Excluded instances

-> Instance

Target Instance

-> Instance

Target Instance with updated attribute

Update the movable attribute.

disableSplitMoves :: List -> Instance -> Instance Source #

Disables moves for instances with a split group.

setArPolicy Source #

Arguments

:: [String]

Cluster tags

-> List

List of node groups

-> List

List of nodes

-> List

List of instances

-> ClockTime

Current timestamp, to evaluate ArSuspended

-> List

Updated list of instances

Set the auto-repair policy for an instance.

getArPolicy :: [String] -> ClockTime -> Maybe AutoRepairPolicy Source #

Get the auto-repair policy from a list of tags.

This examines the ganeti:watcher:autorepair and ganeti:watcher:autorepair:suspend tags to determine the policy. If none of these tags are present, Nothing (and not ArNotEnabled) is returned.

longestDomain :: [String] -> String Source #

Compute the longest common suffix of a list of strings that starts with a dot.

extractExTags :: [String] -> [String] Source #

Extracts the exclusion tags from the cluster configuration.

extractDesiredLocations :: [String] -> [String] Source #

Extracts the desired locations from the instance tags.

commonSuffix :: List -> List -> String Source #

Extracts the common suffix from node/instance names.

addMigrationTags Source #

Arguments

:: [String]

cluster tags

-> Node 
-> Node 

Set the migration-related tags on a node given the cluster tags; this assumes that the node tags are already set on that node.

addLocationTags Source #

Arguments

:: [String]

cluster tags

-> Node 
-> Node 

Set the location tags on a node given the cluster tags; this assumes that the node tags are already set on that node.

mergeData Source #

Arguments

:: [(String, DynUtil)]

Instance utilisation data

-> [String]

Exclusion tags

-> [String]

Selected instances (if not empty)

-> [String]

Excluded instances

-> ClockTime

The current timestamp

-> ClusterData

Data from backends

-> Result ClusterData

Fixed cluster data

Initializer function that loads the data from a node and instance list and massages it into the correct format.

clearDynU :: ClusterData -> Result ClusterData Source #

In a cluster description, clear dynamic utilisation information.

setStaticKvmNodeMem Source #

Arguments

:: List

Nodes to update

-> Int

Static node size

-> List

Updated nodes

Update cluster data to use static node memory on KVM.

updateMemStat :: Node -> List -> Node Source #

Update node memory stat based on instance list.

updateMissing Source #

Arguments

:: List

All nodes in the cluster

-> List

All instances in the cluster

-> Int

Static node memory for KVM

-> ([String], List)

Pair of errors, update node list

Check the cluster for memory/disk allocation consistency and update stats.

nodeImem :: Node -> List -> Int Source #

Compute the amount of memory used by primary instances on a node.

nodeIdsk :: Node -> List -> Int Source #

Compute the amount of disk used by instances on a node (either primary or secondary).

eitherLive :: MonadFail m => Bool -> a -> m a -> m a Source #

Get live information or a default value