Commit 22381768 authored by Iustin Pop's avatar Iustin Pop
Browse files

Move the 'Hypervisor' type from Objects to Types



This is a very basic type and 'Objects' is a heavy-weight module. By
moving it to 'types' we simplify (in the future) the import chains.
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarAdeodato Simo <dato@google.com>
parent edc1acde
......@@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
module Test.Ganeti.Objects
( testObjects
, Hypervisor(..)
, Node(..)
, genEmptyCluster
) where
......@@ -51,8 +50,6 @@ import Ganeti.JSON
-- * Arbitrary instances
$(genArbitrary ''Hypervisor)
$(genArbitrary ''PartialNDParams)
instance Arbitrary Node where
......
......@@ -32,6 +32,7 @@ module Test.Ganeti.Types
, DiskTemplate(..)
, InstanceStatus(..)
, NonEmpty(..)
, Hypervisor(..)
) where
import Data.List (sort)
......@@ -69,6 +70,8 @@ $(genArbitrary ''DdmSimple)
$(genArbitrary ''CVErrorCode)
$(genArbitrary ''Hypervisor)
instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where
arbitrary = do
QuickCheck.NonEmpty lst <- arbitrary
......@@ -151,6 +154,10 @@ case_CVErrorCode_pyequiv = do
all_hs_codes = sort $ map Types.cVErrorCodeToRaw [minBound..maxBound]
assertEqual "for CVErrorCode equivalence" all_py_codes all_hs_codes
-- | Test 'Hypervisor' serialisation.
prop_Hypervisor_serialisation :: Hypervisor -> Property
prop_Hypervisor_serialisation = testSerialisation
testSuite "Types"
[ 'prop_AllocPolicy_serialisation
, 'prop_DiskTemplate_serialisation
......@@ -166,4 +173,5 @@ testSuite "Types"
, 'prop_DdmSimple_serialisation
, 'prop_CVErrorCode_serialisation
, 'case_CVErrorCode_pyequiv
, 'prop_Hypervisor_serialisation
]
......@@ -59,6 +59,7 @@ import qualified Ganeti.Constants as C
import Ganeti.Errors
import Ganeti.JSON
import Ganeti.Objects
import Ganeti.Types
-- | Type alias for the link and ip map.
type LinkIpMap = M.Map String (M.Map String String)
......
......@@ -50,7 +50,6 @@ module Ganeti.Objects
, FilledBeParams(..)
, fillBeParams
, allBeParamFields
, Hypervisor(..)
, AdminState(..)
, adminStateFromRaw
, Instance(..)
......@@ -329,19 +328,6 @@ $(buildObjectSerialisation "Disk"
, defaultField [| DiskRdWr |] $ simpleField "mode" [t| DiskMode |]
])
-- * Hypervisor definitions
-- | This may be due to change when we add hypervisor parameters.
$(declareSADT "Hypervisor"
[ ( "Kvm", 'C.htKvm )
, ( "XenPvm", 'C.htXenPvm )
, ( "Chroot", 'C.htChroot )
, ( "XenHvm", 'C.htXenHvm )
, ( "Lxc", 'C.htLxc )
, ( "Fake", 'C.htFake )
])
$(makeJSONInstance ''Hypervisor)
-- * Instance definitions
$(declareSADT "AdminState"
......
......@@ -82,6 +82,7 @@ import qualified Ganeti.Path as P
import qualified Ganeti.Constants as C
import Ganeti.Objects
import Ganeti.THH
import Ganeti.Types
import Ganeti.Compat
-- * Base RPC functionality and types
......
......@@ -54,6 +54,7 @@ module Ganeti.Types
, DdmSimple(..)
, CVErrorCode(..)
, cVErrorCodeToRaw
, Hypervisor(..)
) where
import qualified Text.JSON as JSON
......@@ -206,3 +207,14 @@ $(THH.declareSADT "DdmSimple"
, ("DdmSimpleRemove", 'C.ddmRemove)
])
$(THH.makeJSONInstance ''DdmSimple)
-- | 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)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment