, NonEmpty
, fromNonEmpty
, mkNonEmpty
+ , NonEmptyString
, MigrationMode(..)
, VerifyOptionalChecks(..)
, DdmSimple(..)
+ , DdmFull(..)
, CVErrorCode(..)
, cVErrorCodeToRaw
+ , Hypervisor(..)
+ , OobCommand(..)
+ , StorageType(..)
+ , NodeEvacMode(..)
+ , FileDriver(..)
+ , InstCreateMode(..)
+ , RebootType(..)
) where
import qualified Text.JSON as JSON
showJSON = JSON.showJSON . fromNonEmpty
readJSON v = JSON.readJSON v >>= mkNonEmpty
+-- | A simple type alias for non-empty strings.
+type NonEmptyString = NonEmpty Char
+
-- * Ganeti types
-- | Instance disk template type.
, ("DdmSimpleRemove", 'C.ddmRemove)
])
$(THH.makeJSONInstance ''DdmSimple)
+
+-- | Dynamic device modification, all operations version.
+$(THH.declareSADT "DdmFull"
+ [ ("DdmFullAdd", 'C.ddmAdd)
+ , ("DdmFullRemove", 'C.ddmRemove)
+ , ("DdmFullModify", 'C.ddmModify)
+ ])
+$(THH.makeJSONInstance ''DdmFull)
+
+-- | Hypervisor type definitions.
+$(THH.declareSADT "Hypervisor"
+ [ ( "Kvm", 'C.htKvm )
+ , ( "XenPvm", 'C.htXenPvm )
+ , ( "Chroot", 'C.htChroot )
+ , ( "XenHvm", 'C.htXenHvm )
+ , ( "Lxc", 'C.htLxc )
+ , ( "Fake", 'C.htFake )
+ ])
+$(THH.makeJSONInstance ''Hypervisor)
+
+-- | Oob command type.
+$(THH.declareSADT "OobCommand"
+ [ ("OobHealth", 'C.oobHealth)
+ , ("OobPowerCycle", 'C.oobPowerCycle)
+ , ("OobPowerOff", 'C.oobPowerOff)
+ , ("OobPowerOn", 'C.oobPowerOn)
+ , ("OobPowerStatus", 'C.oobPowerStatus)
+ ])
+$(THH.makeJSONInstance ''OobCommand)
+
+-- | Storage type.
+$(THH.declareSADT "StorageType"
+ [ ("StorageFile", 'C.stFile)
+ , ("StorageLvmPv", 'C.stLvmPv)
+ , ("StorageLvmVg", 'C.stLvmVg)
+ ])
+$(THH.makeJSONInstance ''StorageType)
+
+-- | Node evac modes.
+$(THH.declareSADT "NodeEvacMode"
+ [ ("NEvacPrimary", 'C.iallocatorNevacPri)
+ , ("NEvacSecondary", 'C.iallocatorNevacSec)
+ , ("NEvacAll", 'C.iallocatorNevacAll)
+ ])
+$(THH.makeJSONInstance ''NodeEvacMode)
+
+-- | The file driver type.
+$(THH.declareSADT "FileDriver"
+ [ ("FileLoop", 'C.fdLoop)
+ , ("FileBlktap", 'C.fdBlktap)
+ ])
+$(THH.makeJSONInstance ''FileDriver)
+
+-- | The instance create mode.
+$(THH.declareSADT "InstCreateMode"
+ [ ("InstCreate", 'C.instanceCreate)
+ , ("InstImport", 'C.instanceImport)
+ , ("InstRemoteImport", 'C.instanceRemoteImport)
+ ])
+$(THH.makeJSONInstance ''InstCreateMode)
+
+-- | Reboot type.
+$(THH.declareSADT "RebootType"
+ [ ("RebootSoft", 'C.instanceRebootSoft)
+ , ("RebootHard", 'C.instanceRebootHard)
+ , ("RebootFull", 'C.instanceRebootFull)
+ ])
+$(THH.makeJSONInstance ''RebootType)