From 7ec2f76bf6519ad4a49f6049e5b49da71f4c2d4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dato=20Sim=C3=B3?= <dato@google.com>
Date: Wed, 12 Dec 2012 12:45:27 +0000
Subject: [PATCH] HTools/Types.hs: more auto-repair types
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

AutoRepairPolicy, AutoRepairStatus, and other auxiliary types are added.
These are used only internally by the auto-repair tool, and parsed from the
various object tags as defined in the design doc.

Signed-off-by: Dato SimΓ³ <dato@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 src/Ganeti/HTools/Types.hs | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/Ganeti/HTools/Types.hs b/src/Ganeti/HTools/Types.hs
index b006dde79..735ae5ea9 100644
--- a/src/Ganeti/HTools/Types.hs
+++ b/src/Ganeti/HTools/Types.hs
@@ -78,9 +78,14 @@ module Ganeti.HTools.Types
   , AutoRepairResult(..)
   , autoRepairResultToRaw
   , autoRepairResultFromRaw
+  , AutoRepairPolicy(..)
+  , AutoRepairSuspendTime(..)
+  , AutoRepairData(..)
+  , AutoRepairStatus(..)
   ) where
 
 import qualified Data.Map as M
+import System.Time (ClockTime)
 
 import qualified Ganeti.Constants as C
 import qualified Ganeti.THH as THH
@@ -369,3 +374,30 @@ $(THH.declareSADT "AutoRepairResult"
        , ("ArFailure", 'C.autoRepairFailure)
        , ("ArEnoperm", 'C.autoRepairEnoperm)
        ])
+
+-- | The possible auto-repair policy for a given instance.
+data AutoRepairPolicy
+  = ArEnabled AutoRepairType          -- ^ Auto-repair explicitly enabled
+  | ArSuspended AutoRepairSuspendTime -- ^ Suspended temporarily, or forever
+  | ArNotEnabled                      -- ^ Auto-repair not explicitly enabled
+  deriving (Eq, Show)
+
+-- | The suspend timeout for 'ArSuspended'.
+data AutoRepairSuspendTime = Forever         -- ^ Permanently suspended
+                           | Until ClockTime -- ^ Suspended up to a certain time
+                           deriving (Eq, Show)
+
+-- | The possible auto-repair states for any given instance.
+data AutoRepairStatus
+  = ArHealthy                      -- ^ No problems detected with the instance
+  | ArNeedsRepair AutoRepairData   -- ^ Instance has problems, no action taken
+  | ArPendingRepair AutoRepairData -- ^ Repair jobs ongoing for the instance
+  | ArFailedRepair AutoRepairData  -- ^ Some repair jobs for the instance failed
+
+-- | The data accompanying a repair operation (future, pending, or failed).
+data AutoRepairData = AutoRepairData { arType :: AutoRepairType
+                                     , arUuid :: String
+                                     , arTime :: ClockTime
+                                     , arJobs :: [JobId]
+                                     , arResult :: Maybe AutoRepairResult
+                                     }
-- 
GitLab