Revision ebf38064 htools/Ganeti/OpCodes.hs

b/htools/Ganeti/OpCodes.hs
26 26
-}
27 27

  
28 28
module Ganeti.OpCodes
29
    ( OpCode(..)
30
    , ReplaceDisksMode(..)
31
    , opID
32
    ) where
29
  ( OpCode(..)
30
  , ReplaceDisksMode(..)
31
  , opID
32
  ) where
33 33

  
34 34
import Text.JSON (readJSON, showJSON, makeObj, JSON)
35 35
import qualified Text.JSON as J
......
41 41

  
42 42
-- | Replace disks type.
43 43
$(declareSADT "ReplaceDisksMode"
44
     [ ("ReplaceOnPrimary",    'C.replaceDiskPri)
45
     , ("ReplaceOnSecondary",  'C.replaceDiskSec)
46
     , ("ReplaceNewSecondary", 'C.replaceDiskChg)
47
     , ("ReplaceAuto",         'C.replaceDiskAuto)
48
     ])
44
  [ ("ReplaceOnPrimary",    'C.replaceDiskPri)
45
  , ("ReplaceOnSecondary",  'C.replaceDiskSec)
46
  , ("ReplaceNewSecondary", 'C.replaceDiskChg)
47
  , ("ReplaceAuto",         'C.replaceDiskAuto)
48
  ])
49 49
$(makeJSONInstance ''ReplaceDisksMode)
50 50

  
51 51
-- | OpCode representation.
......
53 53
-- We only implement a subset of Ganeti opcodes, but only what we
54 54
-- actually use in the htools codebase.
55 55
$(genOpCode "OpCode"
56
         [ ("OpTestDelay",
57
            [ ("duration",  [t| Double   |], noDefault)
58
            , ("on_master", [t| Bool     |], noDefault)
59
            , ("on_nodes",  [t| [String] |], noDefault)
60
            ])
61
         , ("OpInstanceReplaceDisks",
62
            [ ("instance_name", [t| String           |], noDefault)
63
            , ("remote_node",   [t| Maybe String     |], noDefault)
64
            , ("mode",          [t| ReplaceDisksMode |], noDefault)
65
            , ("disks",         [t| [Int]            |], noDefault)
66
            , ("iallocator",    [t| Maybe String     |], noDefault)
67
            ])
68
         , ("OpInstanceFailover",
69
            [ ("instance_name",      [t| String       |], noDefault)
70
            , ("ignore_consistency", [t| Bool         |], noDefault)
71
            , ("target_node",        [t| Maybe String |], noDefault)
72
            ])
73
         , ("OpInstanceMigrate",
74
            [ ("instance_name",  [t| String       |], noDefault)
75
            , ("live",           [t| Bool         |], noDefault)
76
            , ("cleanup",        [t| Bool         |], noDefault)
77
            , ("allow_failover", [t| Bool         |], [| Just False |])
78
            , ("target_node",    [t| Maybe String |], noDefault)
79
            ])
80
         ])
56
  [ ("OpTestDelay",
57
     [ ("duration",  [t| Double   |], noDefault)
58
     , ("on_master", [t| Bool     |], noDefault)
59
     , ("on_nodes",  [t| [String] |], noDefault)
60
     ])
61
  , ("OpInstanceReplaceDisks",
62
     [ ("instance_name", [t| String           |], noDefault)
63
     , ("remote_node",   [t| Maybe String     |], noDefault)
64
     , ("mode",          [t| ReplaceDisksMode |], noDefault)
65
     , ("disks",         [t| [Int]            |], noDefault)
66
     , ("iallocator",    [t| Maybe String     |], noDefault)
67
     ])
68
  , ("OpInstanceFailover",
69
     [ ("instance_name",      [t| String       |], noDefault)
70
     , ("ignore_consistency", [t| Bool         |], noDefault)
71
     , ("target_node",        [t| Maybe String |], noDefault)
72
     ])
73
  , ("OpInstanceMigrate",
74
     [ ("instance_name",  [t| String       |], noDefault)
75
     , ("live",           [t| Bool         |], noDefault)
76
     , ("cleanup",        [t| Bool         |], noDefault)
77
     , ("allow_failover", [t| Bool         |], [| Just False |])
78
     , ("target_node",    [t| Maybe String |], noDefault)
79
     ])
80
  ])
81 81

  
82 82
$(genOpID ''OpCode "opID")
83 83

  
84 84
instance JSON OpCode where
85
    readJSON = loadOpCode
86
    showJSON = saveOpCode
85
  readJSON = loadOpCode
86
  showJSON = saveOpCode

Also available in: Unified diff