ganeti

Safe HaskellNone

Ganeti.WConfd.ConfigModifications

Contents

Description

The WConfd functions for direct configuration manipulation

This module contains the client functions exported by WConfD for specific configuration manipulation.

Synopsis

Documentation

type DiskUUID = StringSource

type InstanceUUID = StringSource

type NodeUUID = StringSource

accessor functions

getters

getAllLVs :: ConfigState -> Set StringSource

Gets all logical volumes in the cluster

getAllIDs :: ConfigState -> Set StringSource

Gets the ids of nodes, instances, node groups, networks, disks, nics, and the cluster itself.

getAllMACs :: ConfigState -> Set StringSource

isIdentical :: (Eq a, SerialNoObjectL a, TimeStampObjectL a) => ClockTime -> a -> a -> BoolSource

Checks if the two objects are equal, excluding timestamps. The serial number of current must be one greater than that of target.

If this is true, it implies that the update RPC updated the config, but did not successfully return.

checkSerial :: SerialNoObject a => a -> a -> GenericResult GanetiException ()Source

Checks if the two objects given have the same serial number

replaceIn :: (UuidObject a, TimeStampObjectL a, SerialNoObjectL a) => ClockTime -> a -> Container a -> GenericResult GanetiException (Container a)Source

Updates an object present in a container. The presence of the object in the container is determined by the uuid of the object.

A check that serial number of the object is consistent with the serial number of the object in the container is performed.

If the check passes, the object's serial number is incremented, and modification time is updated, and then is inserted into the container.

updateConfigIfNecessary :: (Monad m, MonadError GanetiException m, Eq a, UuidObject a, SerialNoObjectL a, TimeStampObjectL a) => ClockTime -> a -> (ConfigState -> Container a) -> (ConfigState -> m ((Int, ClockTime), ConfigState)) -> ConfigState -> m ((Int, ClockTime), ConfigState)Source

Utility fuction that combines the two possible actions that could be taken when given a target.

If the target is identical to the current value, we return the modification time of the current value, and not change the config.

If not, we update the config.

UUID config checks

checkUUIDpresent :: UuidObject a => ConfigState -> a -> BoolSource

Checks if the config has the given UUID

checkUniqueUUID :: UuidObject a => ConfigState -> a -> BoolSource

Checks if the given UUID is new (i.e., no in the config)

RPC checks

addInstanceChecks :: Instance -> Bool -> ConfigState -> GenericResult GanetiException ()Source

Verifications done before adding an instance. Currently confirms that the instance's macs are not in use, and that the instance's UUID being present (or not present) in the config based on weather the instance is being replaced (or not).

TODO: add more verifications to this call; the client should have a lock on the name of the instance.

Pure config modifications functions

Monadic config modification functions which can return errors

RPCs

addInstance :: Instance -> ClientId -> Bool -> WConfdMonad BoolSource

Add a new instance to the configuration, release DRBD minors, and commit temporary IPs, all while temporarily holding the config lock. Return True upon success and False if the config lock was not available and the client should retry.

detachInstanceDisk :: InstanceUUID -> DiskUUID -> WConfdMonad BoolSource

Detach a disk from an instance.

removeInstanceDisk :: InstanceUUID -> DiskUUID -> WConfdMonad BoolSource

Detach a disk from an instance and remove it from the config.

removeInstance :: InstanceUUID -> WConfdMonad BoolSource

Remove the instance from the configuration.

allocatePort :: WConfdMonad (MaybeForJSON Int)Source

Allocate a port. The port will be taken from the available port pool or from the default port range (and in this case we increase highest_used_port).

addTcpUdpPort :: Int -> WConfdMonad BoolSource

Adds a new port to the available port pool.

setInstancePrimaryNode :: InstanceUUID -> NodeUUID -> WConfdMonad BoolSource

Sets the primary node of an existing instance

updateCluster :: Cluster -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON))Source

The configuration is updated by the provided cluster

updateNode :: Node -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON))Source

The configuration is updated by the provided node

updateInstance :: Instance -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON))Source

The configuration is updated by the provided instance

updateNodeGroup :: NodeGroup -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON))Source

The configuration is updated by the provided nodegroup

updateNetwork :: Network -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON))Source

The configuration is updated by the provided network

updateDisk :: Disk -> WConfdMonad (MaybeForJSON (Int, TimeAsDoubleJSON))Source

The configuration is updated by the provided disk

changeAndBump :: (SerialNoObjectL a, TimeStampObjectL a) => Simple Setter ConfigState a -> (a -> a) -> WConfdMonad BoolSource

Set a particular value and bump serial in the hosting structure. Arguments are a setter to focus on the part of the configuration that gets serial-bumped, and a modification of that part. The function will do the change and bump the serial in the WConfdMonad temporarily acquiring the configuration lock. Return True if that succeeded and False if the configuration lock was not available; no change is done in the latter case.

changeAndBumpMaint :: (MaintenanceData -> MaintenanceData) -> WConfdMonad BoolSource

Change and bump part of the maintenance part of the configuration.

setMaintdRoundDelay :: Int -> WConfdMonad BoolSource

Set the maintenance intervall.

clearMaintdJobs :: WConfdMonad BoolSource

Clear the list of current maintenance jobs.

appendMaintdJobs :: [JobId] -> WConfdMonad BoolSource

Append new jobs to the list of current maintenace jobs, if not alread present.

setMaintdBalance :: Bool -> WConfdMonad BoolSource

Set the autobalance flag.

setMaintdBalanceThreshold :: Double -> WConfdMonad BoolSource

Set the auto-balance threshold.

addMaintdEvacuated :: [String] -> WConfdMonad BoolSource

Add a name to the list of recently evacuated instances.

rmMaintdEvacuated :: String -> WConfdMonad BoolSource

Remove a name from the list of recently evacuated instances.

updateMaintdIncident :: Incident -> WConfdMonad BoolSource

Update an incident to the list of known incidents; if the incident, as identified by the UUID, is not present, it is added.

rmMaintdIncident :: String -> WConfdMonad BoolSource

Remove an incident from the list of known incidents.

The list of functions exported to RPC.