ganeti

Safe HaskellNone

Ganeti.WConfd.Core

Contents

Description

The Ganeti WConfd core functions.

As TemplateHaskell require that splices be defined in a separate module, we combine all the TemplateHaskell functionality that HTools needs in this module (except the one for unittests).

Synopsis

Functions available to the RPC module

echo :: String -> WConfdMonad StringSource

Configuration related functions

readConfig :: WConfdMonad ConfigDataSource

Read the configuration.

writeConfig :: ClientId -> ConfigData -> WConfdMonad ()Source

Write the configuration, checking that an exclusive lock is held. If not, the call fails.

verifyConfig :: WConfdMonad ()Source

Explicitly run verification of the configuration. The caller doesn't need to hold the configuration lock.

Locks on the configuration (only transitional, will be removed later)

lockConfigSource

Arguments

:: ClientId 
-> Bool

set to True if the lock should be shared

-> WConfdMonad (MaybeForJSON ConfigData) 

Tries to acquire ConfigLock for the client. If the second parameter is set to True, the lock is acquired in shared mode.

If the lock was successfully acquired, returns the current configuration state.

unlockConfig :: ClientId -> WConfdMonad ()Source

Release the config lock, if the client currently holds it.

flushConfig :: WConfdMonad ()Source

Force the distribution of configuration without actually modifying it. It is not necessary to hold a lock for this operation.

Temporary reservations related functions

DRBD

MACs

DRBDSecrets

LVs

IPv4s

reserveIp :: ClientId -> NetworkUUID -> Ip4Address -> Bool -> WConfdMonad ()Source

Reserve a given IPv4 address for use by an instance.

releaseIp :: ClientId -> NetworkUUID -> Ip4Address -> WConfdMonad ()Source

Give a specific IP address back to an IP pool. The IP address is returned to the IP pool designated by network id and marked as reserved.

commitTemporaryIps :: ClientId -> WConfdMonad ()Source

Commit all reserved/released IP address to an IP pool. The IP addresses are taken from the network's IP pool and marked as reserved/free for instances.

Note that the reservations are kept, they are supposed to be cleaned when a job finishes.

commitReleaseTemporaryIp :: NetworkUUID -> Ip4Address -> WConfdMonad ()Source

Immediately release an IP address, without using the reservations pool.

listReservedIps :: ClientId -> WConfdMonad [IPv4Reservation]Source

List all IP reservations for the current client.

This function won't be needed once the corresponding calls are moved to WConfd.

Locking related functions

listLocks :: ClientId -> WConfdMonad [(GanetiLocks, OwnerState)]Source

List the locks of a given owner (i.e., a job-id lockfile pair).

listAllLocks :: WConfdMonad [GanetiLocks]Source

List all active locks.

listAllLocksOwners :: WConfdMonad [(GanetiLocks, [(ClientId, OwnerState)])]Source

List all active locks with their owners.

listLocksWaitingStatus :: WConfdMonad ([(GanetiLocks, [(ClientId, OwnerState)])], [(Integer, ClientId, [LockRequest GanetiLocks])])Source

Get full information of the lock waiting status, i.e., provide the information about all locks owners and all pending requests.

tryUpdateLocks :: ClientId -> GanetiLockRequest -> WConfdMonad [ClientId]Source

Try to update the locks of a given owner (i.e., a job-id lockfile pair). This function always returns immediately. If the lock update was possible, the empty list is returned; otherwise, the lock status is left completly unchanged, and the return value is the list of jobs which need to release some locks before this request can succeed.

updateLocksWaiting :: ClientId -> Integer -> GanetiLockRequest -> WConfdMonad [ClientId]Source

Try to update the locks of a given owner and make that a pending request if not immediately possible.

hasPendingRequest :: ClientId -> WConfdMonad BoolSource

Tell whether a given owner has pending requests.

freeLocks :: ClientId -> WConfdMonad ()Source

Free all locks of a given owner (i.e., a job-id lockfile pair).

freeLocksLevel :: ClientId -> LockLevel -> WConfdMonad ()Source

Free all locks of a given owner (i.e., a job-id lockfile pair) of a given level in the Ganeti sense (e.g., cluster, node).

downGradeLocksLevel :: ClientId -> LockLevel -> WConfdMonad ()Source

Downgrade all locks of the given level to shared.

intersectLocks :: ClientId -> [GanetiLocks] -> WConfdMonad ()Source

Intersect the possesed locks of an owner with a given set.

opportunisticLockUnion :: ClientId -> [(GanetiLocks, OwnerState)] -> WConfdMonad [GanetiLocks]Source

Opportunistically allocate locks for a given owner.

guardedOpportunisticLockUnion :: Int -> ClientId -> [(GanetiLocks, OwnerState)] -> WConfdMonad [GanetiLocks]Source

Opprtunistially allocate locks for a given owner, requesting a certain minimum of success.

Prepareation for cluster destruction

prepareClusterDestruction :: ClientId -> WConfdMonad ()Source

Prepare daemon for cluster destruction. This consists of verifying that the requester owns the BGL exclusively, transfering the BGL to WConfD itself, and modifying the configuration so that no node is the master any more. Note that, since we own the BGL exclusively, we can safely modify the configuration, as no other process can request changes.

The list of all functions exported to RPC.