From 5cd95d46141999f258d936155120844136e9bf20 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 6 Dec 2012 16:13:18 +0100
Subject: [PATCH] Add a type for the log type in job/opcode logs

Also fixes indentation for OP_STATUS.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htest/Test/Ganeti/Types.hs |  7 +++++++
 htools/Ganeti/Types.hs     | 25 +++++++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/htest/Test/Ganeti/Types.hs b/htest/Test/Ganeti/Types.hs
index 971b974ad..711687118 100644
--- a/htest/Test/Ganeti/Types.hs
+++ b/htest/Test/Ganeti/Types.hs
@@ -132,6 +132,8 @@ $(genArbitrary ''OpSubmitPriority)
 
 $(genArbitrary ''OpStatus)
 
+$(genArbitrary ''ELogType)
+
 -- * Properties
 
 prop_AllocPolicy_serialisation :: AllocPolicy -> Property
@@ -352,6 +354,10 @@ prop_JobDependency_serialisation = testSerialisation
 prop_OpSubmitPriority_serialisation :: OpSubmitPriority -> Property
 prop_OpSubmitPriority_serialisation = testSerialisation
 
+-- | Test 'ELogType' serialisation.
+prop_ELogType_serialisation :: ELogType -> Property
+prop_ELogType_serialisation = testSerialisation
+
 testSuite "Types"
   [ 'prop_AllocPolicy_serialisation
   , 'case_AllocPolicy_order
@@ -394,4 +400,5 @@ testSuite "Types"
   , 'prop_JobId_serialisation
   , 'prop_JobDependency_serialisation
   , 'prop_OpSubmitPriority_serialisation
+  , 'prop_ELogType_serialisation
   ]
diff --git a/htools/Ganeti/Types.hs b/htools/Ganeti/Types.hs
index e24edaf63..850114c1a 100644
--- a/htools/Ganeti/Types.hs
+++ b/htools/Ganeti/Types.hs
@@ -89,6 +89,7 @@ module Ganeti.Types
   , OpStatus(..)
   , opStatusToRaw
   , opStatusFromRaw
+  , ELogType(..)
   ) where
 
 import Control.Monad (liftM)
@@ -453,12 +454,20 @@ $(THH.makeJSONInstance ''OpSubmitPriority)
 
 -- | Our ADT for the OpCode status at runtime (while in a job).
 $(THH.declareSADT "OpStatus"
-       [ ("OP_STATUS_QUEUED",    'C.opStatusQueued)
-       , ("OP_STATUS_WAITING",   'C.opStatusWaiting)
-       , ("OP_STATUS_CANCELING", 'C.opStatusCanceling)
-       , ("OP_STATUS_RUNNING",   'C.opStatusRunning)
-       , ("OP_STATUS_CANCELED",  'C.opStatusCanceled)
-       , ("OP_STATUS_SUCCESS",   'C.opStatusSuccess)
-       , ("OP_STATUS_ERROR",     'C.opStatusError)
-       ])
+  [ ("OP_STATUS_QUEUED",    'C.opStatusQueued)
+  , ("OP_STATUS_WAITING",   'C.opStatusWaiting)
+  , ("OP_STATUS_CANCELING", 'C.opStatusCanceling)
+  , ("OP_STATUS_RUNNING",   'C.opStatusRunning)
+  , ("OP_STATUS_CANCELED",  'C.opStatusCanceled)
+  , ("OP_STATUS_SUCCESS",   'C.opStatusSuccess)
+  , ("OP_STATUS_ERROR",     'C.opStatusError)
+  ])
 $(THH.makeJSONInstance ''OpStatus)
+
+-- | Type for the job message type.
+$(THH.declareSADT "ELogType"
+  [ ("ELogMessage",      'C.elogMessage)
+  , ("ELogRemoteImport", 'C.elogRemoteImport)
+  , ("ELogJqueueTest",   'C.elogJqueueTest)
+  ])
+$(THH.makeJSONInstance ''ELogType)
-- 
GitLab