ganeti

Safe HaskellNone

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

Instances
Eq Disk # 
Instance details

Defined in Ganeti.HTools.Instance

Methods

(==) :: Disk -> Disk -> Bool

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

Show Disk # 
Instance details

Defined in Ganeti.HTools.Instance

Methods

showsPrec :: Int -> Disk -> ShowS

show :: Disk -> String

showList :: [Disk] -> ShowS

data Instance Source #

The instance type.

Constructors

Instance 

Fields

Instances
Eq Instance # 
Instance details

Defined in Ganeti.HTools.Instance

Methods

(==) :: Instance -> Instance -> Bool

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

Show Instance # 
Instance details

Defined in Ganeti.HTools.Instance

Methods

showsPrec :: Int -> Instance -> ShowS

show :: Instance -> String

showList :: [Instance] -> ShowS

Element Instance # 
Instance details

Defined in Ganeti.HTools.Instance

Methods

nameOf :: Instance -> String Source #

allNames :: Instance -> [String] Source #

idxOf :: Instance -> Int Source #

setAlias :: Instance -> String -> Instance Source #

computeAlias :: String -> Instance -> Instance Source #

setIdx :: Instance -> Int -> Instance Source #

Arbitrary Instance 
Instance details

Defined in Test.Ganeti.HTools.Instance

isRunning :: Instance -> Bool Source #

Check if instance is running.

isOffline :: Instance -> Bool Source #

Check if instance is offline.

notOffline :: Instance -> Bool Source #

Helper to check if the instance is not offline.

instanceDown :: Instance -> Bool Source #

Check if instance is down.

applyIfOnline :: Instance -> (a -> a) -> a -> a Source #

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

usesSecMem :: Instance -> Bool Source #

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 Instance Source #

A simple name for an instance map.

Initialization

create :: String -> Int -> Int -> [Disk] -> Int -> InstanceStatus -> [String] -> Bool -> Ndx -> Ndx -> DiskTemplate -> Int -> [Nic] -> Bool -> Instance Source #

Create an instance.

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

setIdx Source #

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.

setName Source #

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.

setAlias Source #

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

setPri Source #

Arguments

:: Instance

the original instance

-> Ndx

the new primary node

-> Instance

the modified instance

Changes the primary node of the instance.

setSec Source #

Arguments

:: Instance

the original instance

-> Ndx

the new secondary node

-> Instance

the modified instance

Changes the secondary node of the instance.

setBoth Source #

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.

setMovable Source #

Arguments

:: Instance

The original instance

-> Bool

New movable flag

-> Instance

The modified instance

Sets the movable flag on an instance.

shrinkByType :: Instance -> FailMode -> Result Instance Source #

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

getTotalSpindles :: Instance -> Maybe Int Source #

Get the number of disk spindles

specOf :: Instance -> RSpec Source #

Return the spec of an instance.

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 -> Bool Source #

Checks whether the instance uses a secondary node.

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

requiredNodes :: DiskTemplate -> Int Source #

Computed the number of nodes for a given disk template.

allNodes :: Instance -> [Ndx] Source #

Computes all nodes of an instance.

usesLocalStorage :: Instance -> Bool Source #

Checks whether a given disk template uses local storage.

usesMemory :: Instance -> Bool Source #

Whether the instance uses memory on its host node. Depends on the InstanceStatus and on whether the instance is forthcoming; instances that aren't running or existent don't use memory.