diff --git a/htest/Test/Ganeti/Objects.hs b/htest/Test/Ganeti/Objects.hs index 941e71c6e71db8e049f2601f973a99bd1c6df044..b59cc13de898f48465f816283e3de117e499210a 100644 --- a/htest/Test/Ganeti/Objects.hs +++ b/htest/Test/Ganeti/Objects.hs @@ -85,8 +85,6 @@ $(genArbitrary ''PartialBeParams) $(genArbitrary ''AdminState) -$(genArbitrary ''NICMode) - $(genArbitrary ''PartialNicParams) $(genArbitrary ''PartialNic) diff --git a/htest/Test/Ganeti/Types.hs b/htest/Test/Ganeti/Types.hs index 4bd0acdfdae6f506a818dcb604134d9a2490ebac..6a662acc9c2bb337e967e45ffee4bb811a54e4e8 100644 --- a/htest/Test/Ganeti/Types.hs +++ b/htest/Test/Ganeti/Types.hs @@ -103,6 +103,8 @@ $(genArbitrary ''IAllocatorTestDir) $(genArbitrary ''IAllocatorMode) +$(genArbitrary ''NICMode) + -- * Properties prop_AllocPolicy_serialisation :: AllocPolicy -> Property @@ -231,6 +233,17 @@ case_IAllocatorMode_pyequiv = do all_hs_codes = sort $ map Types.iAllocatorModeToRaw [minBound..maxBound] assertEqual "for IAllocatorMode equivalence" all_py_codes all_hs_codes +-- | Test 'NICMode' serialisation. +prop_NICMode_serialisation :: NICMode -> Property +prop_NICMode_serialisation = testSerialisation + +-- | Tests equivalence with Python, based on Constants.hs code. +case_NICMode_pyequiv :: Assertion +case_NICMode_pyequiv = do + let all_py_codes = sort C.nicValidModes + all_hs_codes = sort $ map Types.nICModeToRaw [minBound..maxBound] + assertEqual "for NICMode equivalence" all_py_codes all_hs_codes + testSuite "Types" [ 'prop_AllocPolicy_serialisation , 'prop_DiskTemplate_serialisation @@ -258,4 +271,6 @@ testSuite "Types" , 'prop_IAllocatorTestDir_serialisation , 'prop_IAllocatorMode_serialisation , 'case_IAllocatorMode_pyequiv + , 'prop_NICMode_serialisation + , 'case_NICMode_pyequiv ] diff --git a/htools/Ganeti/Objects.hs b/htools/Ganeti/Objects.hs index f591bb98891a7c073e21d18ae754eeb14f092a08..54c58a1336325f23de2f5425dd481e7ab9d9c514 100644 --- a/htools/Ganeti/Objects.hs +++ b/htools/Ganeti/Objects.hs @@ -33,7 +33,6 @@ module Ganeti.Objects , vTypeFromRaw , HvParams , OsParams - , NICMode(..) , PartialNicParams(..) , FilledNicParams(..) , fillNicParams @@ -168,12 +167,6 @@ roleDescription NRMaster = "master" -- * NIC definitions -$(declareSADT "NICMode" - [ ("NMBridged", 'C.nicModeBridged) - , ("NMRouted", 'C.nicModeRouted) - ]) -$(makeJSONInstance ''NICMode) - $(buildParam "Nic" "nicp" [ simpleField "mode" [t| NICMode |] , simpleField "link" [t| String |] diff --git a/htools/Ganeti/Types.hs b/htools/Ganeti/Types.hs index 659a8045a5fb19eccd17c365e77373f3ed0a011f..824af9c85c08bf686b2f83a64c085a770e8e71a3 100644 --- a/htools/Ganeti/Types.hs +++ b/htools/Ganeti/Types.hs @@ -67,6 +67,8 @@ module Ganeti.Types , IAllocatorTestDir(..) , IAllocatorMode(..) , iAllocatorModeToRaw + , NICMode(..) + , nICModeToRaw ) where import qualified Text.JSON as JSON @@ -314,3 +316,10 @@ $(THH.declareSADT "IAllocatorMode" , ("IAllocatorChangeGroup", 'C.iallocatorModeChgGroup) ]) $(THH.makeJSONInstance ''IAllocatorMode) + +-- | Netork mode. +$(THH.declareSADT "NICMode" + [ ("NMBridged", 'C.nicModeBridged) + , ("NMRouted", 'C.nicModeRouted) + ]) +$(THH.makeJSONInstance ''NICMode)