1 {-# LANGUAGE TemplateHaskell #-}
3 {-| Implementation of the job information.
9 Copyright (C) 2009, 2010, 2011, 2012 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)
35 import qualified Ganeti.Constants as C
36 import qualified Ganeti.THH as THH
38 -- | Our ADT for the OpCode status at runtime (while in a job).
39 $(THH.declareSADT "OpStatus"
40 [ ("OP_STATUS_QUEUED", 'C.opStatusQueued)
41 , ("OP_STATUS_WAITING", 'C.opStatusWaiting)
42 , ("OP_STATUS_CANCELING", 'C.opStatusCanceling)
43 , ("OP_STATUS_RUNNING", 'C.opStatusRunning)
44 , ("OP_STATUS_CANCELED", 'C.opStatusCanceled)
45 , ("OP_STATUS_SUCCESS", 'C.opStatusSuccess)
46 , ("OP_STATUS_ERROR", 'C.opStatusError)
48 $(THH.makeJSONInstance ''OpStatus)
50 -- | The JobStatus data type. Note that this is ordered especially
51 -- such that greater\/lesser comparison on values of this type makes
53 $(THH.declareSADT "JobStatus"
54 [ ("JOB_STATUS_QUEUED", 'C.jobStatusQueued)
55 , ("JOB_STATUS_WAITING", 'C.jobStatusWaiting)
56 , ("JOB_STATUS_CANCELING", 'C.jobStatusCanceling)
57 , ("JOB_STATUS_RUNNING", 'C.jobStatusRunning)
58 , ("JOB_STATUS_CANCELED", 'C.jobStatusCanceled)
59 , ("JOB_STATUS_SUCCESS", 'C.jobStatusSuccess)
60 , ("JOB_STATUS_ERROR", 'C.jobStatusError)
62 $(THH.makeJSONInstance ''JobStatus)