module Ganeti.OpCodes
( OpCode(..)
, ReplaceDisksMode(..)
, opID
) where
import Text.JSON (readJSON, showJSON, makeObj, JSON)
import qualified Ganeti.Constants as C
import Ganeti.THH
import Ganeti.HTools.JSON
$(declareSADT "ReplaceDisksMode"
[ ("ReplaceOnPrimary", 'C.replaceDiskPri)
, ("ReplaceOnSecondary", 'C.replaceDiskSec)
, ("ReplaceNewSecondary", 'C.replaceDiskChg)
, ("ReplaceAuto", 'C.replaceDiskAuto)
])
$(makeJSONInstance ''ReplaceDisksMode)
$(genOpCode "OpCode"
[ ("OpTestDelay",
[ simpleField "duration" [t| Double |]
, simpleField "on_master" [t| Bool |]
, simpleField "on_nodes" [t| [String] |]
])
, ("OpInstanceReplaceDisks",
[ simpleField "instance_name" [t| String |]
, optionalField $ simpleField "remote_node" [t| String |]
, simpleField "mode" [t| ReplaceDisksMode |]
, simpleField "disks" [t| [Int] |]
, optionalField $ simpleField "iallocator" [t| String |]
])
, ("OpInstanceFailover",
[ simpleField "instance_name" [t| String |]
, simpleField "ignore_consistency" [t| Bool |]
, optionalField $ simpleField "target_node" [t| String |]
])
, ("OpInstanceMigrate",
[ simpleField "instance_name" [t| String |]
, simpleField "live" [t| Bool |]
, simpleField "cleanup" [t| Bool |]
, defaultField [| False |] $ simpleField "allow_failover" [t| Bool |]
, optionalField $ simpleField "target_node" [t| String |]
])
])
$(genOpID ''OpCode "opID")
instance JSON OpCode where
readJSON = loadOpCode
showJSON = saveOpCode