root / htools / Ganeti / Jobs.hs @ 89c758c6
History | View | Annotate | Download (2.1 kB)
1 |
{-# LANGUAGE TemplateHaskell #-} |
---|---|
2 |
|
3 |
{-| Implementation of the job information. |
4 |
|
5 |
-} |
6 |
|
7 |
{- |
8 |
|
9 |
Copyright (C) 2009, 2010, 2011 Google Inc. |
10 |
|
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. |
15 |
|
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. |
20 |
|
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 |
24 |
02110-1301, USA. |
25 |
|
26 |
-} |
27 |
|
28 |
module Ganeti.Jobs |
29 |
( OpStatus(..) |
30 |
, JobStatus(..) |
31 |
) where |
32 |
|
33 |
import Text.JSON (readJSON, showJSON, JSON) |
34 |
import qualified Text.JSON as J |
35 |
|
36 |
import qualified Ganeti.Constants as C |
37 |
import qualified Ganeti.THH as THH |
38 |
|
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) |
48 |
]) |
49 |
$(THH.makeJSONInstance ''OpStatus) |
50 |
|
51 |
-- | The JobStatus data type. Note that this is ordered especially |
52 |
-- such that greater\/lesser comparison on values of this type makes |
53 |
-- sense. |
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) |
62 |
]) |
63 |
$(THH.makeJSONInstance ''JobStatus) |