Commit d546d209 authored by Petr Pudlak's avatar Petr Pudlak
Browse files

Add a function for bumping the serial number to WConfd



.. and also add a lens for 'csConfigData'.
Signed-off-by: default avatarPetr Pudlak <pudlak@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent be751ab9
{-# LANGUAGE TemplateHaskell #-}
{-| Pure functions for manipulating the configuration state.
-}
......@@ -26,14 +28,19 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Ganeti.WConfd.ConfigState
( ConfigState
, csConfigData
, csConfigDataL
, mkConfigState
, bumpSerial
, needsFullDist
) where
import Control.Applicative
import Data.Function (on)
import System.Time (ClockTime(..))
import Ganeti.Lens
import Ganeti.Objects
import Ganeti.Objects.Lens
-- | In future this data type will include the current configuration
-- ('ConfigData') and the last 'FStat' of its file.
......@@ -42,11 +49,16 @@ data ConfigState = ConfigState
}
deriving (Eq, Show)
$(makeCustomLenses ''ConfigState)
-- | Creates a new configuration state.
-- This method will expand as more fields are added to 'ConfigState'.
mkConfigState :: ConfigData -> ConfigState
mkConfigState = ConfigState
bumpSerial :: (SerialNoObjectL a, TimeStampObjectL a) => ClockTime -> a -> a
bumpSerial now = set mTimeL now . over serialL succ
-- | Given two versions of the configuration, determine if its distribution
-- needs to be fully commited before returning the corresponding call to
-- WConfD.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment