Jobs.hs 2.07 KB
Newer Older
1
2
{-# LANGUAGE TemplateHaskell #-}

3
4
5
6
7
8
{-| Implementation of the job information.

-}

{-

Iustin Pop's avatar
Iustin Pop committed
9
Copyright (C) 2009, 2010, 2011, 2012 Google Inc.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301, USA.

-}

module Ganeti.Jobs
29
30
31
  ( OpStatus(..)
  , JobStatus(..)
  ) where
32
33
34

import Text.JSON (readJSON, showJSON, JSON)

35
import qualified Ganeti.Constants as C
36
import qualified Ganeti.THH as THH
37

38
-- | Our ADT for the OpCode status at runtime (while in a job).
39
$(THH.declareSADT "OpStatus"
40
41
42
43
44
45
46
47
       [ ("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)
       ])
48
$(THH.makeJSONInstance ''OpStatus)
Iustin Pop's avatar
Iustin Pop committed
49

50
-- | The JobStatus data type. Note that this is ordered especially
51
-- such that greater\/lesser comparison on values of this type makes
52
-- sense.
53
$(THH.declareSADT "JobStatus"
54
55
56
57
58
59
60
61
       [ ("JOB_STATUS_QUEUED",    'C.jobStatusQueued)
       , ("JOB_STATUS_WAITING",   'C.jobStatusWaiting)
       , ("JOB_STATUS_CANCELING", 'C.jobStatusCanceling)
       , ("JOB_STATUS_RUNNING",   'C.jobStatusRunning)
       , ("JOB_STATUS_CANCELED",  'C.jobStatusCanceled)
       , ("JOB_STATUS_SUCCESS",   'C.jobStatusSuccess)
       , ("JOB_STATUS_ERROR",     'C.jobStatusError)
       ])
62
$(THH.makeJSONInstance ''JobStatus)