From c65621d7f7d921bfbc6886e28c69f1ba8eb965bc Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 22 Nov 2012 11:41:22 +0100 Subject: [PATCH] Move FileDriver from Objects to Types Another base type that we need in opcodes as well. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Helga Velroyen <helgav@google.com> --- htest/Test/Ganeti/Objects.hs | 2 -- htest/Test/Ganeti/Types.hs | 15 +++++++++++---- htools/Ganeti/Objects.hs | 7 ------- htools/Ganeti/Types.hs | 8 ++++++++ 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/htest/Test/Ganeti/Objects.hs b/htest/Test/Ganeti/Objects.hs index aa4e16a0c..941e71c6e 100644 --- a/htest/Test/Ganeti/Objects.hs +++ b/htest/Test/Ganeti/Objects.hs @@ -59,8 +59,6 @@ instance Arbitrary Node where <*> arbitrary <*> arbitrary <*> getFQDN <*> arbitrary <*> (Set.fromList <$> genTags) -$(genArbitrary ''FileDriver) - $(genArbitrary ''BlockDriver) $(genArbitrary ''DiskMode) diff --git a/htest/Test/Ganeti/Types.hs b/htest/Test/Ganeti/Types.hs index e3774dbcc..f345437a4 100644 --- a/htest/Test/Ganeti/Types.hs +++ b/htest/Test/Ganeti/Types.hs @@ -56,6 +56,11 @@ instance (Arbitrary a, Ord a, Num a, Show a) => (QuickCheck.Positive i) <- arbitrary Types.mkPositive i +instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where + arbitrary = do + QuickCheck.NonEmpty lst <- arbitrary + Types.mkNonEmpty lst + $(genArbitrary ''AllocPolicy) $(genArbitrary ''DiskTemplate) @@ -78,10 +83,7 @@ $(genArbitrary ''StorageType) $(genArbitrary ''NodeEvacMode) -instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where - arbitrary = do - QuickCheck.NonEmpty lst <- arbitrary - Types.mkNonEmpty lst +$(genArbitrary ''FileDriver) -- * Properties @@ -176,6 +178,10 @@ prop_StorageType_serialisation = testSerialisation prop_NodeEvacMode_serialisation :: NodeEvacMode -> Property prop_NodeEvacMode_serialisation = testSerialisation +-- | Test 'FileDriver' serialisation. +prop_FileDriver_serialisation :: FileDriver -> Property +prop_FileDriver_serialisation = testSerialisation + testSuite "Types" [ 'prop_AllocPolicy_serialisation , 'prop_DiskTemplate_serialisation @@ -195,4 +201,5 @@ testSuite "Types" , 'prop_OobCommand_serialisation , 'prop_StorageType_serialisation , 'prop_NodeEvacMode_serialisation + , 'prop_FileDriver_serialisation ] diff --git a/htools/Ganeti/Objects.hs b/htools/Ganeti/Objects.hs index 1b98db35d..f591bb988 100644 --- a/htools/Ganeti/Objects.hs +++ b/htools/Ganeti/Objects.hs @@ -202,13 +202,6 @@ $(declareSADT "DiskType" ]) $(makeJSONInstance ''DiskType) --- | The file driver type. -$(declareSADT "FileDriver" - [ ("FileLoop", 'C.fdLoop) - , ("FileBlktap", 'C.fdBlktap) - ]) -$(makeJSONInstance ''FileDriver) - -- | The persistent block driver type. Currently only one type is allowed. $(declareSADT "BlockDriver" [ ("BlockDrvManual", 'C.blockdevDriverManual) diff --git a/htools/Ganeti/Types.hs b/htools/Ganeti/Types.hs index 4420d47aa..166b41ce0 100644 --- a/htools/Ganeti/Types.hs +++ b/htools/Ganeti/Types.hs @@ -59,6 +59,7 @@ module Ganeti.Types , OobCommand(..) , StorageType(..) , NodeEvacMode(..) + , FileDriver(..) ) where import qualified Text.JSON as JSON @@ -251,3 +252,10 @@ $(THH.declareSADT "NodeEvacMode" , ("NEvacAll", 'C.iallocatorNevacAll) ]) $(THH.makeJSONInstance ''NodeEvacMode) + +-- | The file driver type. +$(THH.declareSADT "FileDriver" + [ ("FileLoop", 'C.fdLoop) + , ("FileBlktap", 'C.fdBlktap) + ]) +$(THH.makeJSONInstance ''FileDriver) -- GitLab