Complete the instance OpCodes and parameters
[ganeti-local] / htools / Ganeti / Types.hs
index 1b47085..1b4e9f5 100644 (file)
@@ -49,13 +49,20 @@ module Ganeti.Types
   , NonEmpty
   , fromNonEmpty
   , mkNonEmpty
+  , NonEmptyString
   , MigrationMode(..)
   , VerifyOptionalChecks(..)
   , DdmSimple(..)
+  , DdmFull(..)
   , CVErrorCode(..)
   , cVErrorCodeToRaw
   , Hypervisor(..)
+  , OobCommand(..)
   , StorageType(..)
+  , NodeEvacMode(..)
+  , FileDriver(..)
+  , InstCreateMode(..)
+  , RebootType(..)
   ) where
 
 import qualified Text.JSON as JSON
@@ -107,6 +114,9 @@ instance (JSON.JSON a) => JSON.JSON (NonEmpty a) where
   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.
@@ -209,6 +219,14 @@ $(THH.declareSADT "DdmSimple"
      ])
 $(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 )
@@ -220,6 +238,16 @@ $(THH.declareSADT "Hypervisor"
   ])
 $(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)
@@ -227,3 +255,34 @@ $(THH.declareSADT "StorageType"
   , ("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)