Skip to content
Snippets Groups Projects
Commit 6a28e02c authored by Iustin Pop's avatar Iustin Pop
Browse files

Add two more basic types


These are needed for completing the node opcode parameters.

Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent 2a8efa13
No related branches found
No related tags found
No related merge requests found
...@@ -72,8 +72,12 @@ $(genArbitrary ''CVErrorCode) ...@@ -72,8 +72,12 @@ $(genArbitrary ''CVErrorCode)
$(genArbitrary ''Hypervisor) $(genArbitrary ''Hypervisor)
$(genArbitrary ''OobCommand)
$(genArbitrary ''StorageType) $(genArbitrary ''StorageType)
$(genArbitrary ''NodeEvacMode)
instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where
arbitrary = do arbitrary = do
QuickCheck.NonEmpty lst <- arbitrary QuickCheck.NonEmpty lst <- arbitrary
...@@ -160,10 +164,18 @@ case_CVErrorCode_pyequiv = do ...@@ -160,10 +164,18 @@ case_CVErrorCode_pyequiv = do
prop_Hypervisor_serialisation :: Hypervisor -> Property prop_Hypervisor_serialisation :: Hypervisor -> Property
prop_Hypervisor_serialisation = testSerialisation prop_Hypervisor_serialisation = testSerialisation
-- | Test 'OobCommand' serialisation.
prop_OobCommand_serialisation :: OobCommand -> Property
prop_OobCommand_serialisation = testSerialisation
-- | Test 'StorageType' serialisation. -- | Test 'StorageType' serialisation.
prop_StorageType_serialisation :: StorageType -> Property prop_StorageType_serialisation :: StorageType -> Property
prop_StorageType_serialisation = testSerialisation prop_StorageType_serialisation = testSerialisation
-- | Test 'NodeEvacMode' serialisation.
prop_NodeEvacMode_serialisation :: NodeEvacMode -> Property
prop_NodeEvacMode_serialisation = testSerialisation
testSuite "Types" testSuite "Types"
[ 'prop_AllocPolicy_serialisation [ 'prop_AllocPolicy_serialisation
, 'prop_DiskTemplate_serialisation , 'prop_DiskTemplate_serialisation
...@@ -180,5 +192,7 @@ testSuite "Types" ...@@ -180,5 +192,7 @@ testSuite "Types"
, 'prop_CVErrorCode_serialisation , 'prop_CVErrorCode_serialisation
, 'case_CVErrorCode_pyequiv , 'case_CVErrorCode_pyequiv
, 'prop_Hypervisor_serialisation , 'prop_Hypervisor_serialisation
, 'prop_OobCommand_serialisation
, 'prop_StorageType_serialisation , 'prop_StorageType_serialisation
, 'prop_NodeEvacMode_serialisation
] ]
...@@ -49,13 +49,16 @@ module Ganeti.Types ...@@ -49,13 +49,16 @@ module Ganeti.Types
, NonEmpty , NonEmpty
, fromNonEmpty , fromNonEmpty
, mkNonEmpty , mkNonEmpty
, NonEmptyString
, MigrationMode(..) , MigrationMode(..)
, VerifyOptionalChecks(..) , VerifyOptionalChecks(..)
, DdmSimple(..) , DdmSimple(..)
, CVErrorCode(..) , CVErrorCode(..)
, cVErrorCodeToRaw , cVErrorCodeToRaw
, Hypervisor(..) , Hypervisor(..)
, OobCommand(..)
, StorageType(..) , StorageType(..)
, NodeEvacMode(..)
) where ) where
import qualified Text.JSON as JSON import qualified Text.JSON as JSON
...@@ -107,6 +110,9 @@ instance (JSON.JSON a) => JSON.JSON (NonEmpty a) where ...@@ -107,6 +110,9 @@ instance (JSON.JSON a) => JSON.JSON (NonEmpty a) where
showJSON = JSON.showJSON . fromNonEmpty showJSON = JSON.showJSON . fromNonEmpty
readJSON v = JSON.readJSON v >>= mkNonEmpty readJSON v = JSON.readJSON v >>= mkNonEmpty
-- | A simple type alias for non-empty strings.
type NonEmptyString = NonEmpty Char
-- * Ganeti types -- * Ganeti types
-- | Instance disk template type. -- | Instance disk template type.
...@@ -220,6 +226,16 @@ $(THH.declareSADT "Hypervisor" ...@@ -220,6 +226,16 @@ $(THH.declareSADT "Hypervisor"
]) ])
$(THH.makeJSONInstance ''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. -- | Storage type.
$(THH.declareSADT "StorageType" $(THH.declareSADT "StorageType"
[ ("StorageFile", 'C.stFile) [ ("StorageFile", 'C.stFile)
...@@ -227,3 +243,11 @@ $(THH.declareSADT "StorageType" ...@@ -227,3 +243,11 @@ $(THH.declareSADT "StorageType"
, ("StorageLvmVg", 'C.stLvmVg) , ("StorageLvmVg", 'C.stLvmVg)
]) ])
$(THH.makeJSONInstance ''StorageType) $(THH.makeJSONInstance ''StorageType)
-- | Node evac modes.
$(THH.declareSADT "NodeEvacMode"
[ ("NEvacPrimary", 'C.iallocatorNevacPri)
, ("NEvacSecondary", 'C.iallocatorNevacSec)
, ("NEvacAll", 'C.iallocatorNevacAll)
])
$(THH.makeJSONInstance ''NodeEvacMode)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment