This function is useful, also outside auto-repairs by
the maintenance daemon.

Signed-off-by: Klaus Aehlig <[email protected]>
---
 src/Ganeti/MaintD/Autorepairs.hs | 8 +-------
 src/Ganeti/Utils.hs              | 7 +++++++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/Ganeti/MaintD/Autorepairs.hs b/src/Ganeti/MaintD/Autorepairs.hs
index 161ab01..ce86d06 100644
--- a/src/Ganeti/MaintD/Autorepairs.hs
+++ b/src/Ganeti/MaintD/Autorepairs.hs
@@ -62,13 +62,7 @@ import Ganeti.MaintD.Utils (annotateOpCode)
 import Ganeti.OpCodes (OpCode(..))
 import qualified Ganeti.Path as Path
 import Ganeti.Types (JobId, JobStatus(..), TagKind(..), mkNonNegative)
-import Ganeti.Utils (newUUID)
-
--- | Log a message and return a Bad result.
-logAndBad :: String -> IO (Result a)
-logAndBad msg = do
-  logNotice msg
-  return $ Bad msg
+import Ganeti.Utils (newUUID, logAndBad)
 
 -- | Apply and remove tags form an instance indicated by `InstanceData`.
 commitChange :: L.Client
diff --git a/src/Ganeti/Utils.hs b/src/Ganeti/Utils.hs
index 57e0aa5..be23541 100644
--- a/src/Ganeti/Utils.hs
+++ b/src/Ganeti/Utils.hs
@@ -58,6 +58,7 @@ module Ganeti.Utils
   , exitWhen
   , exitUnless
   , logWarningIfBad
+  , logAndBad
   , rStripSpace
   , newUUID
   , isUUID
@@ -355,6 +356,12 @@ logWarningIfBad msg defVal (Bad s) = do
   return defVal
 logWarningIfBad _ _ (Ok v) = return v
 
+-- | Log a message and return a Bad result.
+logAndBad :: String -> IO (Result a)
+logAndBad msg = do
+  logNotice msg
+  return $ Bad msg
+
 -- | Try an IO interaction, log errors and unfold as a 'Result'.
 tryAndLogIOError :: IO a -> String -> (a -> Result b) -> IO (Result b)
 tryAndLogIOError io msg okfn =
-- 
2.4.3.573.g4eafbef

Reply via email to