Safe Haskell | Safe-Infered |
---|
Module describing a node.
All updates are functional (copy-based) and return a new node with updated value.
- type TagMap = Map String Int
- data Node = Node {
- name :: String
- alias :: String
- tMem :: Double
- nMem :: Int
- fMem :: Int
- fMemForth :: Int
- xMem :: Int
- tDsk :: Double
- fDsk :: Int
- fDskForth :: Int
- tCpu :: Double
- tCpuSpeed :: Double
- nCpu :: Int
- uCpu :: Int
- uCpuForth :: Int
- tSpindles :: Int
- fSpindles :: Int
- fSpindlesForth :: Int
- pList :: [Idx]
- pListForth :: [Idx]
- sList :: [Idx]
- sListForth :: [Idx]
- idx :: Ndx
- peers :: PeerMap
- failN1 :: Bool
- failN1Forth :: Bool
- rMem :: Int
- rMemForth :: Int
- pMem :: Double
- pMemForth :: Double
- pDsk :: Double
- pDskForth :: Double
- pRem :: Double
- pRemForth :: Double
- pCpu :: Double
- pCpuForth :: Double
- mDsk :: Double
- loDsk :: Int
- hiCpu :: Int
- hiSpindles :: Double
- instSpindles :: Double
- instSpindlesForth :: Double
- offline :: Bool
- isMaster :: Bool
- nTags :: [String]
- utilPool :: DynUtil
- utilLoad :: DynUtil
- utilLoadForth :: DynUtil
- pTags :: TagMap
- group :: Gdx
- iPolicy :: IPolicy
- exclStorage :: Bool
- migTags :: Set String
- rmigTags :: Set String
- locationTags :: Set String
- locationScore :: Int
- instanceMap :: Map (String, String) Int
- pCpuEff :: Node -> Double
- pCpuEffForth :: Node -> Double
- type AssocList = [(Ndx, Node)]
- type List = Container Node
- noSecondary :: Ndx
- addTag :: Ord k => Map k Int -> k -> Map k Int
- addTags :: Ord k => Map k Int -> [k] -> Map k Int
- delTag :: Ord k => Map k Int -> k -> Map k Int
- delTags :: Ord k => Map k Int -> [k] -> Map k Int
- rejectAddTags :: TagMap -> [String] -> Bool
- conflictingPrimaries :: Node -> Int
- incIf :: Num a => Bool -> a -> a -> a
- decIf :: Num a => Bool -> a -> a -> a
- haveExclStorage :: List -> Bool
- create :: String -> Double -> Int -> Int -> Double -> Int -> Double -> Int -> Bool -> Int -> Int -> Gdx -> Bool -> Node
- mDskToloDsk :: Double -> Double -> Int
- mCpuTohiCpu :: Double -> Double -> Int
- computeHiSpindles :: Double -> Int -> Double
- setIdx :: Node -> Ndx -> Node
- setAlias :: Node -> String -> Node
- setOffline :: Node -> Bool -> Node
- setMaster :: Node -> Bool -> Node
- setNodeTags :: Node -> [String] -> Node
- setMigrationTags :: Node -> Set String -> Node
- setRecvMigrationTags :: Node -> Set String -> Node
- setLocationTags :: Node -> Set String -> Node
- setXmem :: Node -> Int -> Node
- setMdsk :: Node -> Double -> Node
- setMcpu :: Node -> Double -> Node
- setPolicy :: IPolicy -> Node -> Node
- computeMaxRes :: PeerMap -> Elem
- buildPeers :: Node -> List -> Node
- calcSpindleUse :: Bool -> Node -> Instance -> Double
- calcSpindleUseForth :: Bool -> Node -> Instance -> Double
- calcNewFreeSpindles :: Bool -> Node -> Instance -> Int
- calcNewFreeSpindlesForth :: Bool -> Node -> Instance -> Int
- calcFmemOfflineOrForthcoming :: Node -> Container Instance -> Int
- getInstanceDsrdLocScore :: Node -> Instance -> Int
- getLocationExclusionPairs :: Node -> Instance -> [(String, String)]
- setPri :: Node -> Instance -> Node
- setSec :: Node -> Instance -> Node
- computePDsk :: Int -> Double -> Double
- computeNewPDsk :: Node -> Int -> Int -> Double
- getPolicyHealth :: Node -> OpResult ()
- setCpuSpeed :: Node -> Double -> Node
- removePri :: Node -> Instance -> Node
- removeSec :: Node -> Instance -> Node
- addPri :: Node -> Instance -> OpResult Node
- addPriEx :: Bool -> Node -> Instance -> OpResult Node
- addSec :: Node -> Instance -> Ndx -> OpResult Node
- addSecEx :: Bool -> Node -> Instance -> Ndx -> OpResult Node
- addSecExEx :: Bool -> Bool -> Node -> Instance -> Ndx -> OpResult Node
- checkMigration :: Node -> Node -> OpResult ()
- availDisk :: Node -> Int
- iDsk :: Node -> Int
- availMem :: Node -> Int
- availCpu :: Node -> Int
- iMem :: Node -> Int
- instanceToEdges :: Instance -> [Edge]
- instancesToEdges :: List -> [Edge]
- nodesToBounds :: List -> Maybe Bounds
- nodeToSharedSecondaryEdge :: List -> Node -> [Edge]
- filterValid :: List -> [Edge] -> [Edge]
- mkNodeGraph :: List -> List -> Maybe Graph
- mkRebootNodeGraph :: List -> List -> List -> Maybe Graph
- showField :: Node -> String -> String
- showHeader :: String -> (String, Bool)
- list :: [String] -> Node -> [String]
- genOpSetOffline :: Monad m => Node -> Bool -> m OpCode
- genOobCommand :: Monad m => [Node] -> OobCommand -> m OpCode
- genPowerOnOpCodes :: Monad m => [Node] -> m [OpCode]
- genPowerOffOpCodes :: Monad m => [Node] -> m [OpCode]
- genAddTagsOpCode :: Node -> [String] -> OpCode
- defaultFields :: [String]
- computeGroups :: [Node] -> [(Gdx, [Node])]
Type declarations
The node type.
Node | |
|
pCpuEff :: Node -> DoubleSource
Derived parameter: ratio of virutal to physical CPUs, weighted by CPU speed.
pCpuEffForth :: Node -> DoubleSource
Derived parameter: ratio of virutal to physical CPUs, weighted by CPU speed and taking forthcoming instances into account.
Constant node index for a non-moveable instance.
Helper functions
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.
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.
setNodeTags :: Node -> [String] -> NodeSource
Sets the node tags attribute
setMigrationTags :: Node -> Set String -> NodeSource
Set migration tags
setRecvMigrationTags :: Node -> Set String -> NodeSource
Set the migration tags a node is able to receive
setLocationTags :: Node -> Set String -> NodeSource
Set the location tags
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).
computeMaxRes :: PeerMap -> ElemSource
buildPeers :: Node -> List -> NodeSource
Builds the peer map for a given node.
calcSpindleUse :: Bool -> Node -> Instance -> DoubleSource
calcSpindleUseForth :: Bool -> Node -> Instance -> DoubleSource
calcNewFreeSpindles :: Bool -> Node -> Instance -> IntSource
calcNewFreeSpindlesForth :: Bool -> Node -> Instance -> IntSource
calcFmemOfflineOrForthcoming :: Node -> Container Instance -> IntSource
getInstanceDsrdLocScore :: Node -> Instance -> IntSource
getLocationExclusionPairs :: Node -> Instance -> [(String, String)]Source
setPri :: Node -> Instance -> NodeSource
Assigns an instance to a node as primary and update the used VCPU count, utilisation data, tags map and desired location score.
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
Diagnostic functions
getPolicyHealth :: Node -> OpResult ()Source
For a node diagnose whether it conforms with all policies. The type is chosen to represent that of a no-op node operation.
Update functions
setCpuSpeed :: Node -> Double -> NodeSource
Set the CPU speed
:: Bool | Whether to override the N+1 and other soft checks, useful if we come from a worse status (e.g. offline). If this is True, forthcoming instances may exceed available Node resources. |
-> 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).
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).
checkMigration :: Node -> Node -> OpResult ()Source
Predicate on whether migration is supported between two nodes.
Stats functions
Node graph functions
Making of a Graph from a node/instance list
instanceToEdges :: Instance -> [Edge]Source
instancesToEdges :: List -> [Edge]Source
nodesToBounds :: List -> Maybe BoundsSource
nodeToSharedSecondaryEdge :: List -> Node -> [Edge]Source
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
:: 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.
genOpSetOffline :: Monad m => Node -> Bool -> m OpCodeSource
genOobCommand :: Monad m => [Node] -> OobCommand -> m OpCodeSource
genPowerOnOpCodes :: Monad m => [Node] -> m [OpCode]Source
Generate OpCode for powering on a list of nodes
genPowerOffOpCodes :: Monad m => [Node] -> m [OpCode]Source
Generate OpCodes for powering off a list of nodes
genAddTagsOpCode :: Node -> [String] -> OpCodeSource
Generate OpCodes for adding tags to a node
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).