ganeti

Safe HaskellSafe-Infered

Ganeti.HTools.Instance

Contents

Description

Module describing an instance.

The instance data type holds very few fields, the algorithm intelligence is in the Node and Cluster modules.

Synopsis

Type declarations

data Disk Source

Constructors

Disk 

Fields

dskSize :: Int

Size in bytes

dskSpindles :: Maybe Int

Number of spindles

Instances

Eq Disk 
Show Disk 

data Instance Source

The instance type.

Constructors

Instance 

Fields

name :: String

The instance name

alias :: String

The shortened name

mem :: Int

Memory of the instance

dsk :: Int

Total disk usage of the instance

disks :: [Disk]

Sizes of the individual disks

vcpus :: Int

Number of VCPUs

runSt :: InstanceStatus

Original run status

pNode :: Ndx

Original primary node

sNode :: Ndx

Original secondary node

idx :: Idx

Internal index

util :: DynUtil

Dynamic resource usage

movable :: Bool

Can and should the instance be moved?

autoBalance :: Bool

Is the instance auto-balanced?

diskTemplate :: DiskTemplate

The disk template of the instance

spindleUse :: Int

The numbers of used spindles

allTags :: [String]

List of all instance tags

exclTags :: [String]

List of instance exclusion tags

arPolicy :: AutoRepairPolicy

Instance's auto-repair policy

nics :: [Nic]

NICs of the instance

Instances

Eq Instance 
Show Instance 
Arbitrary Instance 
Element Instance 

isRunning :: Instance -> BoolSource

Check if instance is running.

isOffline :: Instance -> BoolSource

Check if instance is offline.

notOffline :: Instance -> BoolSource

Helper to check if the instance is not offline.

instanceDown :: Instance -> BoolSource

Check if instance is down.

applyIfOnline :: Instance -> (a -> a) -> a -> aSource

Apply the function if the instance is online. Otherwise use the initial value

usesSecMem :: Instance -> BoolSource

Helper for determining whether an instance's memory needs to be taken into account for secondary memory reservation.

localStorageTemplates :: [DiskTemplate]Source

Constant holding the local storage templates.

Note: Currently Ganeti only exports node total/free disk space for LVM-based storage; file-based storage is ignored in this model, so even though file-based storage uses in reality disk space on the node, in our model it won't affect it and we can't compute whether there is enough disk space for a file-based instance. Therefore we will treat this template as 'foreign' storage.

type AssocList = [(Idx, Instance)]Source

A simple name for the int, instance association list.

type List = Container InstanceSource

A simple name for an instance map.

Initialization

create :: String -> Int -> Int -> [Disk] -> Int -> InstanceStatus -> [String] -> Bool -> Ndx -> Ndx -> DiskTemplate -> Int -> [Nic] -> InstanceSource

Create an instance.

Some parameters are not initialized by function, and must be set later (via setIdx for example).

setIdxSource

Arguments

:: Instance

The original instance

-> Idx

New index

-> Instance

The modified instance

Changes the index.

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

setNameSource

Arguments

:: Instance

The original instance

-> String

New name

-> Instance

The modified instance

Changes the name.

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

setAliasSource

Arguments

:: Instance

The original instance

-> String

New alias

-> Instance

The modified instance

Changes the alias.

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

Update functions

setPriSource

Arguments

:: Instance

the original instance

-> Ndx

the new primary node

-> Instance

the modified instance

Changes the primary node of the instance.

setSecSource

Arguments

:: Instance

the original instance

-> Ndx

the new secondary node

-> Instance

the modified instance

Changes the secondary node of the instance.

setBothSource

Arguments

:: Instance

the original instance

-> Ndx

new primary node index

-> Ndx

new secondary node index

-> Instance

the modified instance

Changes both nodes of the instance.

setMovableSource

Arguments

:: Instance

The original instance

-> Bool

New movable flag

-> Instance

The modified instance

Sets the movable flag on an instance.

shrinkByType :: Instance -> FailMode -> Result InstanceSource

Try to shrink the instance based on the reason why we can't allocate it.

getTotalSpindles :: Instance -> Maybe IntSource

Get the number of disk spindles

specOf :: Instance -> RSpecSource

Return the spec of an instance.

instCompareISpec :: Ordering -> Instance -> ISpec -> Bool -> OpResult ()Source

instBelowISpec :: Instance -> ISpec -> Bool -> OpResult ()Source

Checks if an instance is smaller than a given spec.

instAboveISpec :: Instance -> ISpec -> Bool -> OpResult ()Source

Checks if an instance is bigger than a given spec.

instMatchesPolicy :: Instance -> IPolicy -> Bool -> OpResult ()Source

Checks if an instance matches a policy.

hasSecondary :: Instance -> BoolSource

Checks whether the instance uses a secondary node.

Note: This should be reconciled with sNode == noSecondary.

requiredNodes :: DiskTemplate -> IntSource

Computed the number of nodes for a given disk template.

allNodes :: Instance -> [Ndx]Source

Computes all nodes of an instance.

usesLocalStorage :: Instance -> BoolSource

Checks whether a given disk template uses local storage.