module Ganeti.Objects.Maintenance
( MaintenanceData(..)
, RepairAction(..)
, RepairStatus(..)
, Incident(..)
) where
import qualified Data.ByteString.UTF8 as UTF8
import qualified Text.JSON as J
import qualified Ganeti.Constants as C
import Ganeti.THH
import Ganeti.THH.Field
import Ganeti.Types
$(declareLADT ''String "RepairAction"
[ ("RANoop", "Ok")
, ("RALiveRepair", "live-repair")
, ("RAEvacuate", "evacuate")
, ("RAEvacuateFailover", "evacuate-failover")
])
$(makeJSONInstance ''RepairAction)
$(declareLADT ''String "RepairStatus"
[ ("RSNoted", "noted")
, ("RSPending", "pending")
, ("RSCanceled", "canceled")
, ("RSFailed", "failed")
, ("RSCompleted", "completed")
])
$(makeJSONInstance ''RepairStatus)
$(buildObject "Incident" "incident" $
[ simpleField "original" [t| J.JSValue |]
, simpleField "action" [t| RepairAction |]
, defaultField [| [] |] $ simpleField "jobs" [t| [ JobId ] |]
, simpleField "node" [t| String |]
, simpleField "repair-status" [t| RepairStatus |]
, simpleField "tag" [t| String |]
]
++ uuidFields
++ timeStampFields
++ serialFields)
instance SerialNoObject Incident where
serialOf = incidentSerial
instance TimeStampObject Incident where
cTimeOf = incidentCtime
mTimeOf = incidentMtime
instance UuidObject Incident where
uuidOf = UTF8.toString . incidentUuid
$(buildObject "MaintenanceData" "maint" $
[ defaultField [| C.maintdDefaultRoundDelay |]
$ simpleField "roundDelay" [t| Int |]
, defaultField [| [] |] $ simpleField "jobs" [t| [ JobId ] |]
, defaultField [| False |] $ simpleField "balance" [t| Bool |]
, defaultField [| 0.1 :: Double |]
$ simpleField "balanceThreshold" [t| Double |]
, defaultField [| [] |] $ simpleField "evacuated" [t| [ String ] |]
, defaultField [| [] |] $ simpleField "incidents" [t| [ Incident ] |]
]
++ timeStampFields
++ serialFields)
instance SerialNoObject MaintenanceData where
serialOf = maintSerial
instance TimeStampObject MaintenanceData where
cTimeOf = maintCtime
mTimeOf = maintMtime