From 46300ac2a1c5c79eb7e5c915af369530824ece8f Mon Sep 17 00:00:00 2001
From: Michele Tartara <mtartara@google.com>
Date: Tue, 11 Dec 2012 12:11:12 +0100
Subject: [PATCH] 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: Michele Tartara <mtartara@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 htools/Ganeti/Confd/Server.hs | 7 -------
 htools/Ganeti/Confd/Utils.hs  | 8 ++++++++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs
index a05d3501b..4ca0014c7 100644
--- a/htools/Ganeti/Confd/Server.hs
+++ b/htools/Ganeti/Confd/Server.hs
@@ -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)
diff --git a/htools/Ganeti/Confd/Utils.hs b/htools/Ganeti/Confd/Utils.hs
index 71f4ef006..d0e60a340 100644
--- a/htools/Ganeti/Confd/Utils.hs
+++ b/htools/Ganeti/Confd/Utils.hs
@@ -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
-- 
GitLab