Safe Haskell | None |
---|
Implementation of the Ganeti configuration database.
Synopsis
- type LinkIpMap = Map String (Map String String)
- readConfig :: FilePath -> IO (Result String)
- parseConfig :: String -> Result ConfigData
- encodeConfig :: ConfigData -> String
- loadConfig :: FilePath -> IO (Result ConfigData)
- saveConfig :: Handle -> ConfigData -> IO ()
- withMissingParam :: String -> (a -> ErrorResult b) -> Maybe a -> ErrorResult b
- computeDiskNodes :: Disk -> Set String
- instDiskNodes :: ConfigData -> Instance -> Set String
- instNodes :: ConfigData -> Instance -> Set String
- computeDiskSecondaryNode :: Disk -> String -> Maybe String
- getNodeInstances :: ConfigData -> String -> ([Instance], [Instance])
- getNodeRole :: ConfigData -> Node -> NodeRole
- getMasterNodes :: ConfigData -> [Node]
- getMasterCandidates :: ConfigData -> [Node]
- getMasterOrCandidates :: ConfigData -> [Node]
- getMasterNetworkParameters :: ConfigData -> MasterNetworkParameters
- getOnlineNodes :: ConfigData -> [Node]
- getDefaultNicLink :: ConfigData -> String
- getDefaultHypervisor :: ConfigData -> Hypervisor
- getInstancesIpByLink :: LinkIpMap -> String -> [String]
- getItem :: String -> String -> Map String a -> ErrorResult a
- getItem' :: String -> String -> Map ByteString a -> ErrorResult a
- getNode :: ConfigData -> String -> ErrorResult Node
- getInstance :: ConfigData -> String -> ErrorResult Instance
- getInstanceByName :: ConfigData -> String -> ErrorResult Instance
- getDisk :: ConfigData -> String -> ErrorResult Disk
- getFilterRule :: ConfigData -> String -> ErrorResult FilterRule
- getGroup :: ConfigData -> String -> ErrorResult NodeGroup
- getGroupNdParams :: ConfigData -> NodeGroup -> FilledNDParams
- getGroupIpolicy :: ConfigData -> NodeGroup -> FilledIPolicy
- getGroupDiskParams :: ConfigData -> NodeGroup -> GroupDiskParams
- getGroupNodes :: ConfigData -> String -> [Node]
- getGroupInstances :: ConfigData -> String -> ([Instance], [Instance])
- getFilledInstHvParams :: [String] -> ConfigData -> Instance -> HvParams
- getFilledInstBeParams :: ConfigData -> Instance -> ErrorResult FilledBeParams
- getFilledInstOsParams :: ConfigData -> Instance -> OsParams
- getInstPrimaryNode :: ConfigData -> String -> ErrorResult Node
- getDrbdDiskNodes :: ConfigData -> Disk -> [Node]
- getInstAllNodes :: ConfigData -> String -> ErrorResult [Node]
- getInstDisks :: ConfigData -> String -> ErrorResult [Disk]
- getInstDisksFromObj :: ConfigData -> Instance -> ErrorResult [Disk]
- collectFromDrbdDisks :: Monoid a => (String -> String -> Int -> Int -> Int -> Private DRBDSecret -> a) -> Disk -> a
- getDrbdSecretsForDisk :: Disk -> [DRBDSecret]
- getDrbdMinorsForDisk :: Disk -> [(Int, String)]
- getDrbdMinorsForNode :: String -> Disk -> [(Int, String)]
- getDrbdMinorsForInstance :: ConfigData -> Instance -> ErrorResult [(Int, String)]
- rolePrimary :: String
- roleSecondary :: String
- getInstMinorsForNode :: ConfigData -> String -> Instance -> [(String, Int, String, String, String, String)]
- buildLinkIpInstnameMap :: ConfigData -> LinkIpMap
- getGroupOfNode :: ConfigData -> Node -> Maybe NodeGroup
- getNodeNdParams :: ConfigData -> Node -> Maybe FilledNDParams
- getNetwork :: ConfigData -> String -> ErrorResult Network
- type MAC = String
- getAllMACs :: ConfigData -> [MAC]
- getAllDrbdSecrets :: ConfigData -> [DRBDSecret]
- type NodeLVsMap = MultiMap String LogicalVolume
- getInstanceLVsByNode :: ConfigData -> Instance -> ErrorResult NodeLVsMap
- getAllLVs :: ConfigData -> ErrorResult (Set LogicalVolume)
- class NdParamObject a where
- getNdParamsOf :: ConfigData -> a -> Maybe FilledNDParams
Documentation
Operations on the whole configuration
readConfig :: FilePath -> IO (Result String) Source #
Reads the config file.
parseConfig :: String -> Result ConfigData Source #
Parses the configuration file.
encodeConfig :: ConfigData -> String Source #
Encodes the configuration file.
loadConfig :: FilePath -> IO (Result ConfigData) Source #
Wrapper over readConfig
and parseConfig
.
saveConfig :: Handle -> ConfigData -> IO () Source #
Wrapper over hPutStr
and encodeConfig
.
Query functions
withMissingParam :: String -> (a -> ErrorResult b) -> Maybe a -> ErrorResult b Source #
Annotate Nothing as missing parameter and apply the given transformation otherwise
computeDiskNodes :: Disk -> Set String Source #
Computes the nodes covered by a disk.
instDiskNodes :: ConfigData -> Instance -> Set String Source #
Computes all disk-related nodes of an instance. For non-DRBD, this will be empty, for DRBD it will contain both the primary and the secondaries.
instNodes :: ConfigData -> Instance -> Set String Source #
Computes all nodes of an instance.
computeDiskSecondaryNode :: Disk -> String -> Maybe String Source #
Computes the secondary node UUID for a DRBD disk
getNodeInstances :: ConfigData -> String -> ([Instance], [Instance]) Source #
Get instances of a given node. The node is specified through its UUID. The secondary calculation is expensive and frequently called, so optimise this to allocate fewer temporary values
getNodeRole :: ConfigData -> Node -> NodeRole Source #
Computes the role of a node.
getMasterNodes :: ConfigData -> [Node] Source #
Get the list of the master nodes (usually one).
getMasterCandidates :: ConfigData -> [Node] Source #
Get the list of master candidates, not including the master itself.
getMasterOrCandidates :: ConfigData -> [Node] Source #
Get the list of master candidates, including the master.
getMasterNetworkParameters :: ConfigData -> MasterNetworkParameters Source #
Get the network parameters for the master IP address.
getOnlineNodes :: ConfigData -> [Node] Source #
Get the list of online nodes.
getDefaultNicLink :: ConfigData -> String Source #
Returns the default cluster link.
getDefaultHypervisor :: ConfigData -> Hypervisor Source #
Returns the default cluster hypervisor.
getInstancesIpByLink :: LinkIpMap -> String -> [String] Source #
Returns instances of a given link.
getItem :: String -> String -> Map String a -> ErrorResult a Source #
Generic lookup function that converts from a possible abbreviated name to a full name.
getItem' :: String -> String -> Map ByteString a -> ErrorResult a Source #
Simple lookup function, insisting on exact matches and using byte strings.
getNode :: ConfigData -> String -> ErrorResult Node Source #
Looks up a node by name or uuid.
getInstance :: ConfigData -> String -> ErrorResult Instance Source #
Looks up an instance by name or uuid.
getInstanceByName :: ConfigData -> String -> ErrorResult Instance Source #
Looks up an instance by exact name match
getDisk :: ConfigData -> String -> ErrorResult Disk Source #
Looks up a disk by uuid.
getFilterRule :: ConfigData -> String -> ErrorResult FilterRule Source #
Looks up a filter by uuid.
getGroup :: ConfigData -> String -> ErrorResult NodeGroup Source #
Looks up a node group by name or uuid.
getGroupNdParams :: ConfigData -> NodeGroup -> FilledNDParams Source #
Computes a node group's node params.
getGroupIpolicy :: ConfigData -> NodeGroup -> FilledIPolicy Source #
Computes a node group's ipolicy.
getGroupDiskParams :: ConfigData -> NodeGroup -> GroupDiskParams Source #
Computes a group's (merged) disk params.
getGroupNodes :: ConfigData -> String -> [Node] Source #
Get nodes of a given node group.
getGroupInstances :: ConfigData -> String -> ([Instance], [Instance]) Source #
Get (primary, secondary) instances of a given node group.
getFilledInstHvParams :: [String] -> ConfigData -> Instance -> HvParams Source #
Retrieves the instance hypervisor params, missing values filled with cluster defaults.
getFilledInstBeParams :: ConfigData -> Instance -> ErrorResult FilledBeParams Source #
Retrieves the instance backend params, missing values filled with cluster defaults.
getFilledInstOsParams :: ConfigData -> Instance -> OsParams Source #
Retrieves the instance os params, missing values filled with cluster defaults. This does NOT include private and secret parameters.
getInstPrimaryNode :: ConfigData -> String -> ErrorResult Node Source #
Looks up an instance's primary node.
getDrbdDiskNodes :: ConfigData -> Disk -> [Node] Source #
Retrieves all nodes hosting a DRBD disk
getInstAllNodes :: ConfigData -> String -> ErrorResult [Node] Source #
Retrieves all the nodes of the instance.
As instances not using DRBD can be sent as a parameter as well, the primary node has to be appended to the results.
getInstDisks :: ConfigData -> String -> ErrorResult [Disk] Source #
Get disks for a given instance. The instance is specified by name or uuid.
getInstDisksFromObj :: ConfigData -> Instance -> ErrorResult [Disk] Source #
Get disks for a given instance object.
:: Monoid a | |
=> (String -> String -> Int -> Int -> Int -> Private DRBDSecret -> a) | NodeA, NodeB, Port, MinorA, MinorB, Secret |
-> Disk | |
-> a |
Collects a value for all DRBD disks
getDrbdSecretsForDisk :: Disk -> [DRBDSecret] Source #
Returns the DRBD secrets of a given Disk
getDrbdMinorsForDisk :: Disk -> [(Int, String)] Source #
Returns the DRBD minors of a given Disk
getDrbdMinorsForNode :: String -> Disk -> [(Int, String)] Source #
Filters DRBD minors for a given node.
getDrbdMinorsForInstance :: ConfigData -> Instance -> ErrorResult [(Int, String)] Source #
Returns the DRBD minors of a given instance
rolePrimary :: String Source #
String for primary role.
roleSecondary :: String Source #
String for secondary role.
:: ConfigData | |
-> String | The UUID of a node. |
-> Instance | |
-> [(String, Int, String, String, String, String)] |
Gets the list of DRBD minors for an instance that are related to a given node.
buildLinkIpInstnameMap :: ConfigData -> LinkIpMap Source #
Builds link -> ip -> instname map. For instances without a name, we insert the uuid instead.
TODO: improve this by splitting it into multiple independent functions:
- abstract the "fetch instance with filled params" functionality
- abstsract the [instance] -> [(nic, instance_name)] part
- etc.
getGroupOfNode :: ConfigData -> Node -> Maybe NodeGroup Source #
Returns a node's group, with optional failure if we can't find it (configuration corrupt).
getNodeNdParams :: ConfigData -> Node -> Maybe FilledNDParams Source #
Returns a node's ndparams, filled.
Network
getNetwork :: ConfigData -> String -> ErrorResult Network Source #
Looks up a network. If looking up by uuid fails, we look up by name.
MACs
getAllMACs :: ConfigData -> [MAC] Source #
Returns all MAC addresses used in the cluster.
DRBD secrets
getAllDrbdSecrets :: ConfigData -> [DRBDSecret] Source #
LVs
type NodeLVsMap = MultiMap String LogicalVolume Source #
A map from node UUIDs to
FIXME: After adding designated types for UUIDs,
use them to replace String
here.
getAllLVs :: ConfigData -> ErrorResult (Set LogicalVolume) Source #
ND params
class NdParamObject a where Source #
Type class denoting objects which have node parameters.
getNdParamsOf :: ConfigData -> a -> Maybe FilledNDParams Source #
Instances
NdParamObject Node # | |
Defined in Ganeti.Config getNdParamsOf :: ConfigData -> Node -> Maybe FilledNDParams Source # | |
NdParamObject NodeGroup # | |
Defined in Ganeti.Config getNdParamsOf :: ConfigData -> NodeGroup -> Maybe FilledNDParams Source # | |
NdParamObject Cluster # | |
Defined in Ganeti.Config getNdParamsOf :: ConfigData -> Cluster -> Maybe FilledNDParams Source # |