1 {-# LANGUAGE TemplateHaskell #-}
3 {-| Implementation of the opcodes.
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
30 , ReplaceDisksMode(..)
34 import Text.JSON (readJSON, showJSON, makeObj, JSON)
36 import qualified Ganeti.Constants as C
39 import Ganeti.HTools.JSON
41 -- | Replace disks type.
42 $(declareSADT "ReplaceDisksMode"
43 [ ("ReplaceOnPrimary", 'C.replaceDiskPri)
44 , ("ReplaceOnSecondary", 'C.replaceDiskSec)
45 , ("ReplaceNewSecondary", 'C.replaceDiskChg)
46 , ("ReplaceAuto", 'C.replaceDiskAuto)
48 $(makeJSONInstance ''ReplaceDisksMode)
50 -- | OpCode representation.
52 -- We only implement a subset of Ganeti opcodes, but only what we
53 -- actually use in the htools codebase.
56 [ simpleField "duration" [t| Double |]
57 , simpleField "on_master" [t| Bool |]
58 , simpleField "on_nodes" [t| [String] |]
60 , ("OpInstanceReplaceDisks",
61 [ simpleField "instance_name" [t| String |]
62 , optionalField $ simpleField "remote_node" [t| String |]
63 , simpleField "mode" [t| ReplaceDisksMode |]
64 , simpleField "disks" [t| [Int] |]
65 , optionalField $ simpleField "iallocator" [t| String |]
67 , ("OpInstanceFailover",
68 [ simpleField "instance_name" [t| String |]
69 , simpleField "ignore_consistency" [t| Bool |]
70 , optionalField $ simpleField "target_node" [t| String |]
72 , ("OpInstanceMigrate",
73 [ simpleField "instance_name" [t| String |]
74 , simpleField "live" [t| Bool |]
75 , simpleField "cleanup" [t| Bool |]
76 , defaultField [| False |] $ simpleField "allow_failover" [t| Bool |]
77 , optionalField $ simpleField "target_node" [t| String |]
81 $(genOpID ''OpCode "opID")
83 instance JSON OpCode where