ganeti

Safe HaskellSafe-Infered

Ganeti.HTools.Node

Contents

Description

Module describing a node.

All updates are functional (copy-based) and return a new node with updated value.

Synopsis

Type declarations

type TagMap = Map String IntSource

data Node Source

The node type.

Constructors

Node 

Fields

name :: String

The node name

alias :: String

The shortened name (for display purposes)

tMem :: Double

Total memory (MiB)

nMem :: Int

Node memory (MiB)

fMem :: Int

Free memory (MiB)

xMem :: Int

Unaccounted memory (MiB)

tDsk :: Double

Total disk space (MiB)

fDsk :: Int

Free disk space (MiB)

tCpu :: Double

Total CPU count

tCpuSpeed :: Double

Relative CPU speed

nCpu :: Int

VCPUs used by the node OS

uCpu :: Int

Used VCPU count

tSpindles :: Int

Node spindles (spindle_count node parameter, or actual spindles, see note below)

fSpindles :: Int

Free spindles (see note below)

pList :: [Idx]

List of primary instance indices

sList :: [Idx]

List of secondary instance indices

idx :: Ndx

Internal index for book-keeping

peers :: PeerMap

Pnode to instance mapping

failN1 :: Bool

Whether the node has failed n1

rMem :: Int

Maximum memory needed for failover by primaries of this node

pMem :: Double

Percent of free memory

pDsk :: Double

Percent of free disk

pRem :: Double

Percent of reserved memory

pCpu :: Double

Ratio of virtual to physical CPUs

mDsk :: Double

Minimum free disk ratio

loDsk :: Int

Autocomputed from mDsk low disk threshold

hiCpu :: Int

Autocomputed from mCpu high cpu threshold

hiSpindles :: Double

Limit auto-computed from policy spindle_ratio and the node spindle count (see note below)

instSpindles :: Double

Spindles used by instances (see note below)

offline :: Bool

Whether the node should not be used for allocations and skipped from score computations

isMaster :: Bool

Whether the node is the master node

nTags :: [String]

The node tags for this node

utilPool :: DynUtil

Total utilisation capacity

utilLoad :: DynUtil

Sum of instance utilisation

pTags :: TagMap

Primary instance exclusion tags and their count

group :: Gdx

The node's group (index)

iPolicy :: IPolicy

The instance policy (of the node's group)

exclStorage :: Bool

Effective value of exclusive_storage

Instances

Eq Node 
Show Node 
Arbitrary Node 
Element Node 

pCpuEff :: Node -> DoubleSource

Derived parameter: ratio of virutal to pysical CPUs, weighted by CPU speed.

type AssocList = [(Ndx, Node)]Source

A simple name for the int, node association list.

type List = Container NodeSource

A simple name for a node map.

type AllocElement = (List, Instance, [Node], Score)Source

A simple name for an allocation element (here just for logistic reasons).

noSecondary :: NdxSource

Constant node index for a non-moveable instance.

Helper functions

addTag :: TagMap -> String -> TagMapSource

addTags :: TagMap -> [String] -> TagMapSource

Add multiple tags.

delTag :: TagMap -> String -> TagMapSource

delTags :: TagMap -> [String] -> TagMapSource

Remove multiple tags.

rejectAddTags :: TagMap -> [String] -> BoolSource

Check if we can add a list of tags to a tagmap.

conflictingPrimaries :: Node -> IntSource

Check how many primary instances have conflicting tags. The algorithm to compute this is to sum the count of all tags, then subtract the size of the tag map (since each tag has at least one, non-conflicting instance); this is equivalent to summing the values in the tag map minus one.

incIf :: Num a => Bool -> a -> a -> aSource

decIf :: Num a => Bool -> a -> a -> aSource

haveExclStorage :: List -> BoolSource

Is exclusive storage enabled on any node?

Initialization functions

create :: String -> Double -> Int -> Int -> Double -> Int -> Double -> Int -> Bool -> Int -> Int -> Gdx -> Bool -> NodeSource

Create a new node.

The index and the peers maps are empty, and will be need to be update later via the setIdx and buildPeers functions.

mDskToloDsk :: Double -> Double -> IntSource

mCpuTohiCpu :: Double -> Double -> IntSource

computeHiSpindles :: Double -> Int -> DoubleSource

setIdx :: Node -> Ndx -> NodeSource

Changes the index.

This is used only during the building of the data structures.

setAlias :: Node -> String -> NodeSource

Changes the alias.

This is used only during the building of the data structures.

setOffline :: Node -> Bool -> NodeSource

Sets the offline attribute.

setMaster :: Node -> Bool -> NodeSource

Sets the master attribute

setNodeTags :: Node -> [String] -> NodeSource

Sets the node tags attribute

setXmem :: Node -> Int -> NodeSource

Sets the unnaccounted memory.

setMdsk :: Node -> Double -> NodeSource

Sets the max disk usage ratio.

setMcpu :: Node -> Double -> NodeSource

Sets the max cpu usage ratio. This will update the node's ipolicy, losing sharing (but it should be a seldomly done operation).

setPolicy :: IPolicy -> Node -> NodeSource

Sets the policy.

buildPeers :: Node -> List -> NodeSource

Builds the peer map for a given node.

calcSpindleUse :: Bool -> Node -> Instance -> DoubleSource

setPri :: Node -> Instance -> NodeSource

Assigns an instance to a node as primary and update the used VCPU count, utilisation data and tags map.

setSec :: Node -> Instance -> NodeSource

Assigns an instance to a node as secondary and updates disk utilisation.

computePDsk :: Int -> Double -> DoubleSource

computeNewPDsk :: Node -> Int -> Int -> DoubleSource

Update functions

setCpuSpeed :: Node -> Double -> NodeSource

Set the CPU speed

setFmem :: Node -> Int -> NodeSource

Sets the free memory.

removePri :: Node -> Instance -> NodeSource

Removes a primary instance.

removeSec :: Node -> Instance -> NodeSource

Removes a secondary instance.

addPri :: Node -> Instance -> OpResult NodeSource

Adds a primary instance (basic version).

addPriExSource

Arguments

:: Bool

Whether to override the N+1 and other soft checks, useful if we come from a worse status (e.g. offline)

-> Node

The target node

-> Instance

The instance to add

-> OpResult Node

The result of the operation, either the new version of the node or a failure mode

Adds a primary instance (extended version).

addSec :: Node -> Instance -> Ndx -> OpResult NodeSource

Adds a secondary instance (basic version).

addSecEx :: Bool -> Node -> Instance -> Ndx -> OpResult NodeSource

Adds a secondary instance (extended version).

addSecExEx :: Bool -> Bool -> Node -> Instance -> Ndx -> OpResult NodeSource

Adds a secondary instance (doubly extended version). The first parameter tells addSecExEx to ignore disks completly. There is only one legitimate use case for this, and this is failing over a DRBD instance where the primary node is offline (and hence will become the secondary afterwards).

Stats functions

availDisk :: Node -> IntSource

Computes the amount of available disk on a given node.

iDsk :: Node -> IntSource

Computes the amount of used disk on a given node.

availMem :: Node -> IntSource

Computes the amount of available memory on a given node.

availCpu :: Node -> IntSource

Computes the amount of available memory on a given node.

iMem :: Node -> IntSource

The memory used by instances on a given node.

Node graph functions

Making of a Graph from a node/instance list

nodesToBounds :: List -> Maybe BoundsSource

filterValid :: List -> [Edge] -> [Edge]Source

mkNodeGraph :: List -> List -> Maybe GraphSource

Transform a Node + Instance list into a NodeGraph type. Returns Nothing if the node list is empty.

mkRebootNodeGraph :: List -> List -> List -> Maybe GraphSource

Transform a Nodes + Instances into a NodeGraph with all reboot exclusions. This includes edges between nodes that are the primary nodes of instances that have the same secondary node. Nodes not in the node list will not be part of the graph, but they are still considered for the edges arising from two instances having the same secondary node. Return Nothing if the node list is empty.

Display functions

showFieldSource

Arguments

:: Node

Node which we're querying

-> String

Field name

-> String

Field value as string

Return a field for a given node.

showHeader :: String -> (String, Bool)Source

Returns the header and numeric propery of a field.

list :: [String] -> Node -> [String]Source

String converter for the node list functionality.

defaultFields :: [String]Source

Constant holding the fields we're displaying by default.

computeGroups :: [Node] -> [(Gdx, [Node])]Source

Split a list of nodes into a list of (node group UUID, list of associated nodes).