Safe Haskell | None |
---|
Generic data loader.
This module holds the common code for parsing the input data after it has been loaded from external sources.
Synopsis
- data RqType
- = Allocate Instance AllocDetails (Maybe [String])
- | AllocateSecondary Idx
- | Relocate Idx Int [Ndx]
- | NodeEvacuate [Idx] EvacMode
- | ChangeGroup [Gdx] [Idx]
- | MultiAllocate [(Instance, AllocDetails)]
- data Request = Request RqType ClusterData
- isAllocationRequest :: RqType -> Maybe (Maybe String)
- data ClusterData = ClusterData {}
- emptyCluster :: ClusterData
- lookupNode :: MonadFail m => NameAssoc -> String -> String -> m Ndx
- lookupInstance :: MonadFail m => NameAssoc -> String -> m Idx
- lookupGroup :: MonadFail m => NameAssoc -> String -> String -> m Gdx
- assignIndices :: Element a => [(String, a)] -> (NameAssoc, Container a)
- setMaster :: MonadFail m => NameAssoc -> List -> String -> m List
- setLocationScore :: List -> Instance -> Instance
- fixNodes :: List -> Instance -> List
- setNodePolicy :: List -> Node -> Node
- updateExclTags :: [String] -> Instance -> Instance
- updateDesiredLocationTags :: [String] -> Instance -> Instance
- updateMovable :: [String] -> [String] -> Instance -> Instance
- disableSplitMoves :: List -> Instance -> Instance
- setArPolicy :: [String] -> List -> List -> List -> ClockTime -> List
- getArPolicy :: [String] -> ClockTime -> Maybe AutoRepairPolicy
- longestDomain :: [String] -> String
- extractExTags :: [String] -> [String]
- extractDesiredLocations :: [String] -> [String]
- commonSuffix :: List -> List -> String
- addMigrationTags :: [String] -> Node -> Node
- addLocationTags :: [String] -> Node -> Node
- mergeData :: [(String, DynUtil)] -> [String] -> [String] -> [String] -> ClockTime -> ClusterData -> Result ClusterData
- clearDynU :: ClusterData -> Result ClusterData
- setStaticKvmNodeMem :: List -> Int -> List
- updateMemStat :: Node -> List -> Node
- updateMissing :: List -> List -> Int -> ([String], List)
- nodeImem :: Node -> List -> Int
- nodeIdsk :: Node -> List -> Int
- eitherLive :: MonadFail m => Bool -> a -> m a -> m a
Types
The iallocator request type.
This type denotes what request we got from Ganeti and also holds request-specific fields.
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 |
A complete request, as received from Ganeti.
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.
Instances
Eq ClusterData # | |
Defined in Ganeti.HTools.Loader (==) :: ClusterData -> ClusterData -> Bool (/=) :: ClusterData -> ClusterData -> Bool | |
Show ClusterData # | |
Defined in Ganeti.HTools.Loader 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.
:: [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.
:: [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.
Set the migration-related tags on a node given the cluster tags; this assumes that the node tags are already set on that node.
Set the location tags on a node given the cluster tags; this assumes that the node tags are already set on that node.
:: [(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.
Update cluster data to use static node memory on KVM.
:: 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