From 48755fac7123d20a394c251cfd08dfd0bc6bdeb0 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 19 Nov 2012 16:19:18 +0100
Subject: [PATCH] Move StorageType from RPC.hs to Types.hs

This fixes a FIXME actually recommending this move :)

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
---
 htest/Test/Ganeti/Types.hs | 7 +++++++
 htools/Ganeti/Rpc.hs       | 9 ---------
 htools/Ganeti/Types.hs     | 9 +++++++++
 3 files changed, 16 insertions(+), 9 deletions(-)

diff --git a/htest/Test/Ganeti/Types.hs b/htest/Test/Ganeti/Types.hs
index d3dbd6996..23f84a557 100644
--- a/htest/Test/Ganeti/Types.hs
+++ b/htest/Test/Ganeti/Types.hs
@@ -72,6 +72,8 @@ $(genArbitrary ''CVErrorCode)
 
 $(genArbitrary ''Hypervisor)
 
+$(genArbitrary ''StorageType)
+
 instance (Arbitrary a) => Arbitrary (Types.NonEmpty a) where
   arbitrary = do
     QuickCheck.NonEmpty lst <- arbitrary
@@ -158,6 +160,10 @@ case_CVErrorCode_pyequiv = do
 prop_Hypervisor_serialisation :: Hypervisor -> Property
 prop_Hypervisor_serialisation = testSerialisation
 
+-- | Test 'StorageType' serialisation.
+prop_StorageType_serialisation :: StorageType -> Property
+prop_StorageType_serialisation = testSerialisation
+
 testSuite "Types"
   [ 'prop_AllocPolicy_serialisation
   , 'prop_DiskTemplate_serialisation
@@ -174,4 +180,5 @@ testSuite "Types"
   , 'prop_CVErrorCode_serialisation
   , 'case_CVErrorCode_pyequiv
   , 'prop_Hypervisor_serialisation
+  , 'prop_StorageType_serialisation
   ]
diff --git a/htools/Ganeti/Rpc.hs b/htools/Ganeti/Rpc.hs
index d20d4c0ca..9022e5ac4 100644
--- a/htools/Ganeti/Rpc.hs
+++ b/htools/Ganeti/Rpc.hs
@@ -59,7 +59,6 @@ module Ganeti.Rpc
   , RpcCallVersion(..)
   , RpcResultVersion(..)
 
-  , StorageType(..)
   , StorageField(..)
   , RpcCallStorageList(..)
   , RpcResultStorageList(..)
@@ -410,14 +409,6 @@ instance Rpc RpcCallVersion RpcResultVersion where
 -- ** StorageList
 
 -- | StorageList
--- Get list of storage units.
--- FIXME: This may be moved to Objects
-$(declareSADT "StorageType"
-  [ ( "STLvmPv", 'C.stLvmPv )
-  , ( "STFile",  'C.stFile )
-  , ( "STLvmVg", 'C.stLvmVg )
-  ])
-$(makeJSONInstance ''StorageType)
 
 -- FIXME: This may be moved to Objects
 $(declareSADT "StorageField"
diff --git a/htools/Ganeti/Types.hs b/htools/Ganeti/Types.hs
index 786955108..1b4708506 100644
--- a/htools/Ganeti/Types.hs
+++ b/htools/Ganeti/Types.hs
@@ -55,6 +55,7 @@ module Ganeti.Types
   , CVErrorCode(..)
   , cVErrorCodeToRaw
   , Hypervisor(..)
+  , StorageType(..)
   ) where
 
 import qualified Text.JSON as JSON
@@ -218,3 +219,11 @@ $(THH.declareSADT "Hypervisor"
   , ( "Fake",   'C.htFake )
   ])
 $(THH.makeJSONInstance ''Hypervisor)
+
+-- | Storage type.
+$(THH.declareSADT "StorageType"
+  [ ("StorageFile", 'C.stFile)
+  , ("StorageLvmPv", 'C.stLvmPv)
+  , ("StorageLvmVg", 'C.stLvmVg)
+  ])
+$(THH.makeJSONInstance ''StorageType)
-- 
GitLab