Skip to content
Snippets Groups Projects
Commit 46300ac2 authored by Michele Tartara's avatar Michele Tartara
Browse files

Move Confd getCurrentTime to Utils


The Confd server implementation has a getCurrentTime function.
This commit moves it to the Utils.hs file of Confd, so that it will be
available to be used by the future Confd client as well.

Signed-off-by: default avatarMichele Tartara <mtartara@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 9f6f74b4
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,6 @@ import System.Exit
import System.IO
import System.Posix.Files
import System.Posix.Types
import System.Time
import qualified Text.JSON as J
import System.INotify
......@@ -132,12 +131,6 @@ queryInternalError = (ReplyStatusError, J.showJSON ConfdErrorInternal)
queryArgumentError :: StatusAnswer
queryArgumentError = (ReplyStatusError, J.showJSON ConfdErrorArgument)
-- | Returns the current time.
getCurrentTime :: IO Integer
getCurrentTime = do
TOD ctime _ <- getClockTime
return ctime
-- | Converter from specific error to a string format.
gntErrorToResult :: ErrorResult a -> Result a
gntErrorToResult (Bad err) = Bad (show err)
......
......@@ -31,10 +31,12 @@ module Ganeti.Confd.Utils
, parseRequest
, parseMessage
, signMessage
, getCurrentTime
) where
import qualified Data.ByteString as B
import qualified Text.JSON as J
import System.Time
import Ganeti.BasicTypes
import Ganeti.Confd.Types
......@@ -80,3 +82,9 @@ signMessage key salt msg =
, signedMsgHmac = hmac
}
where hmac = computeMac key (Just salt) msg
-- | Returns the current time.
getCurrentTime :: IO Integer
getCurrentTime = do
TOD ctime _ <- getClockTime
return ctime
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment