ganeti

Safe HaskellNone

Ganeti.WConfd.TempRes

Contents

Description

Pure functions for manipulating reservations of temporary objects

NOTE: Reservations aren't released specifically, they're just all released at the end of a job. This could be improved in the future.

Synopsis

The main reservation state

Aliases to make types more meaningful:

type NodeUUID = ByteString Source #

type InstanceUUID = ByteString Source #

type DiskUUID = ByteString Source #

type NetworkUUID = ByteString Source #

type DRBDMinor = Int Source #

type DRBDMap = Map NodeUUID (Map DRBDMinor DiskUUID) Source #

A map of the usage of DRBD minors

The state data structure

data IPv4ResAction Source #

Types of IPv4 reservation actions.

Constructors

IPv4Reserve 
IPv4Release 
Instances
Bounded IPv4ResAction # 
Instance details

Defined in Ganeti.WConfd.TempRes

Enum IPv4ResAction # 
Instance details

Defined in Ganeti.WConfd.TempRes

Eq IPv4ResAction # 
Instance details

Defined in Ganeti.WConfd.TempRes

Ord IPv4ResAction # 
Instance details

Defined in Ganeti.WConfd.TempRes

Show IPv4ResAction # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

showsPrec :: Int -> IPv4ResAction -> ShowS

show :: IPv4ResAction -> String

showList :: [IPv4ResAction] -> ShowS

JSON IPv4ResAction # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

readJSON :: JSValue -> Result IPv4ResAction

showJSON :: IPv4ResAction -> JSValue

readJSONs :: JSValue -> Result [IPv4ResAction]

showJSONs :: [IPv4ResAction] -> JSValue

Arbitrary IPv4ResAction 
Instance details

Defined in Test.Ganeti.WConfd.TempRes

data IPv4Reservation Source #

The values stored in the IPv4 reservation table.

Instances
Eq IPv4Reservation # 
Instance details

Defined in Ganeti.WConfd.TempRes

Ord IPv4Reservation # 
Instance details

Defined in Ganeti.WConfd.TempRes

Show IPv4Reservation # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

showsPrec :: Int -> IPv4Reservation -> ShowS

show :: IPv4Reservation -> String

showList :: [IPv4Reservation] -> ShowS

JSON IPv4Reservation # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

readJSON :: JSValue -> Result IPv4Reservation

showJSON :: IPv4Reservation -> JSValue

readJSONs :: JSValue -> Result [IPv4Reservation]

showJSONs :: [IPv4Reservation] -> JSValue

Arbitrary IPv4Reservation 
Instance details

Defined in Test.Ganeti.WConfd.TempRes

data TempRes j a Source #

A polymorphic data structure for managing temporary resources assigned to jobs.

Instances
(Eq j, Eq a) => Eq (TempRes j a) # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

(==) :: TempRes j a -> TempRes j a -> Bool

(/=) :: TempRes j a -> TempRes j a -> Bool

(Ord j, Ord a) => Ord (TempRes j a) # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

compare :: TempRes j a -> TempRes j a -> Ordering

(<) :: TempRes j a -> TempRes j a -> Bool

(<=) :: TempRes j a -> TempRes j a -> Bool

(>) :: TempRes j a -> TempRes j a -> Bool

(>=) :: TempRes j a -> TempRes j a -> Bool

max :: TempRes j a -> TempRes j a -> TempRes j a

min :: TempRes j a -> TempRes j a -> TempRes j a

(Show j, Show a) => Show (TempRes j a) # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

showsPrec :: Int -> TempRes j a -> ShowS

show :: TempRes j a -> String

showList :: [TempRes j a] -> ShowS

(Ord j, Ord a) => Semigroup (TempRes j a) # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

(<>) :: TempRes j a -> TempRes j a -> TempRes j a

sconcat :: NonEmpty (TempRes j a) -> TempRes j a

stimes :: Integral b => b -> TempRes j a -> TempRes j a

(Ord j, Ord a) => Monoid (TempRes j a) # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

mempty :: TempRes j a

mappend :: TempRes j a -> TempRes j a -> TempRes j a

mconcat :: [TempRes j a] -> TempRes j a

(JSON j, Ord j, JSON a, Ord a) => JSON (TempRes j a) # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

readJSON :: JSValue -> Result (TempRes j a)

showJSON :: TempRes j a -> JSValue

readJSONs :: JSValue -> Result [TempRes j a]

showJSONs :: [TempRes j a] -> JSValue

(Arbitrary k, Ord k, Arbitrary v, Ord v) => Arbitrary (TempRes k v) 
Instance details

Defined in Test.Ganeti.WConfd.TempRes

Methods

arbitrary :: Gen (TempRes k v)

shrink :: TempRes k v -> [TempRes k v]

mkTempRes :: MultiMap j a -> TempRes j a Source #

Create a temporary reservations from a given multi-map.

data TempResState Source #

The state of the temporary reservations

Instances
Eq TempResState # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

(==) :: TempResState -> TempResState -> Bool

(/=) :: TempResState -> TempResState -> Bool

Show TempResState # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

showsPrec :: Int -> TempResState -> ShowS

show :: TempResState -> String

showList :: [TempResState] -> ShowS

JSON TempResState # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

readJSON :: JSValue -> Result TempResState

showJSON :: TempResState -> JSValue

readJSONs :: JSValue -> Result [TempResState]

showJSONs :: [TempResState] -> JSValue

ArrayObject TempResState # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

toJSArray :: TempResState -> [JSValue] Source #

fromJSArray :: [JSValue] -> Result TempResState Source #

DictObject TempResState # 
Instance details

Defined in Ganeti.WConfd.TempRes

Methods

toDict :: TempResState -> [(String, JSValue)] Source #

fromDictWKeys :: [(String, JSValue)] -> WriterT UsedKeys Result TempResState Source #

fromDict :: [(String, JSValue)] -> Result TempResState Source #

Arbitrary TempResState 
Instance details

Defined in Test.Ganeti.WConfd.TempRes

Utility functions

DRBD functions

computeDRBDMap' :: MonadError GanetiException m => ConfigData -> TempResState -> m DRBDMap' Source #

Compute the map of used DRBD minor/nodes, including possible duplicates. An error is returned if the configuration isn't consistent (for example if a referenced disk is missing etc.).

computeDRBDMap :: MonadError GanetiException m => ConfigData -> TempResState -> m DRBDMap Source #

Compute the map of used DRBD minor/nodes. Report any duplicate entries as an error.

Unlike computeDRBDMap', includes entries for all nodes, even if empty.

allocateDRBDMinor :: (MonadError GanetiException m, MonadState TempResState m) => ConfigData -> DiskUUID -> [NodeUUID] -> m [DRBDMinor] Source #

releaseDRBDMinors :: MonadState TempResState m => DiskUUID -> m () Source #

Other temporary resources

isReserved :: (Ord a, Ord j) => a -> TempRes j a -> Bool Source #

Tests if a given value is reserved for a given job.

reserve :: (MonadError GanetiException m, Show a, Ord a, Ord j) => j -> a -> TempRes j a -> m (TempRes j a) Source #

Tries to reserve a given value for a given job.

dropReservationsFor :: (Ord a, Ord j) => j -> TempRes j a -> TempRes j a Source #

reserved :: (Ord a, Ord j) => TempRes j a -> Set a Source #

Functions common to all reservations

dropAllReservations :: ClientId -> State TempResState () Source #

Removes all resources reserved by a given job.

If a new reservation resource type is added, it must be added here as well.

IDs

MAC addresses

generateMAC :: (RandomGen g, MonadError GanetiException m, Functor m) => g -> ClientId -> Maybe NetworkUUID -> ConfigData -> StateT TempResState m MAC Source #

reserveMAC :: (MonadError GanetiException m, MonadState TempResState m, Functor m) => ClientId -> MAC -> ConfigData -> m () Source #

DRBD secrets

generateDRBDSecret :: (RandomGen g, MonadError GanetiException m, Functor m) => g -> ClientId -> ConfigData -> StateT TempResState m DRBDSecret Source #

LVs

reserveLV :: (MonadError GanetiException m, MonadState TempResState m, Functor m) => ClientId -> LogicalVolume -> ConfigData -> m () Source #

IPv4 addresses

reserveIp Source #

Arguments

:: (MonadError GanetiException m, MonadState TempResState m, Functor m) 
=> ClientId 
-> NetworkUUID 
-> Ip4Address 
-> Bool

whether to check externally reserved IPs

-> ConfigData 
-> m () 

Reserve a given IPv4 address for use by an instance.

releaseIp :: (MonadError GanetiException m, MonadState TempResState m, Functor m) => ClientId -> NetworkUUID -> Ip4Address -> m () 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.

generateIp :: (MonadError GanetiException m, MonadState TempResState m, Functor m) => ClientId -> NetworkUUID -> ConfigData -> m Ip4Address Source #

commitReleaseIp :: (MonadError GanetiException m, Functor m) => NetworkUUID -> Ip4Address -> ConfigData -> m ConfigData Source #

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

commitReservedIps :: (MonadError GanetiException m, Functor m, MonadLog m) => ClientId -> TempResState -> ConfigData -> m ConfigData 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.