1 {-# LANGUAGE TemplateHaskell #-}
3 {-| Implementation of the job information.
9 Copyright (C) 2009, 2010, 2011 Google Inc.
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
16 This program is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
33 import Text.JSON (readJSON, showJSON, JSON)
34 import qualified Text.JSON as J
36 import qualified Ganeti.Constants as C
37 import qualified Ganeti.THH as THH
39 -- | Our ADT for the OpCode status at runtime (while in a job).
40 $(THH.declareSADT "OpStatus"
41 [ ("OP_STATUS_QUEUED", 'C.opStatusQueued)
42 , ("OP_STATUS_WAITING", 'C.opStatusWaiting)
43 , ("OP_STATUS_CANCELING", 'C.opStatusCanceling)
44 , ("OP_STATUS_RUNNING", 'C.opStatusRunning)
45 , ("OP_STATUS_CANCELED", 'C.opStatusCanceled)
46 , ("OP_STATUS_SUCCESS", 'C.opStatusSuccess)
47 , ("OP_STATUS_ERROR", 'C.opStatusError)
49 $(THH.makeJSONInstance ''OpStatus)
51 -- | The JobStatus data type. Note that this is ordered especially
52 -- such that greater\/lesser comparison on values of this type makes
54 $(THH.declareSADT "JobStatus"
55 [ ("JOB_STATUS_QUEUED", 'C.jobStatusQueued)
56 , ("JOB_STATUS_WAITING", 'C.jobStatusWaiting)
57 , ("JOB_STATUS_CANCELING", 'C.jobStatusCanceling)
58 , ("JOB_STATUS_RUNNING", 'C.jobStatusRunning)
59 , ("JOB_STATUS_CANCELED", 'C.jobStatusCanceled)
60 , ("JOB_STATUS_SUCCESS", 'C.jobStatusSuccess)
61 , ("JOB_STATUS_ERROR", 'C.jobStatusError)
63 $(THH.makeJSONInstance ''JobStatus)