From 19f38ee89e8328ac58fa1f65573f86638a373d84 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Fri, 29 May 2009 20:02:19 +0200
Subject: [PATCH] Move the RqType and Request types to Loader.hs

These two will be more generic than now, and belong somewhere else -
Loader.hs is a generic module for data loading, thus we move them there.
---
 Ganeti/HTools/IAlloc.hs | 16 +---------------
 Ganeti/HTools/Loader.hs | 22 ++++++++++++++++++++++
 Ganeti/HTools/Types.hs  |  7 ++++++-
 hail.hs                 |  1 +
 4 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/Ganeti/HTools/IAlloc.hs b/Ganeti/HTools/IAlloc.hs
index bbeb868b2..d13d568ce 100644
--- a/Ganeti/HTools/IAlloc.hs
+++ b/Ganeti/HTools/IAlloc.hs
@@ -3,11 +3,8 @@
 -}
 
 module Ganeti.HTools.IAlloc
-    (
-      parseData
+    ( parseData
     , formatResponse
-    , RqType(..)
-    , Request(..)
     ) where
 
 import Data.Either ()
@@ -22,17 +19,6 @@ import Ganeti.HTools.Loader
 import Ganeti.HTools.Utils
 import Ganeti.HTools.Types
 
--- | The request type.
-data RqType
-    = Allocate Instance.Instance Int -- ^ A new instance allocation
-    | Relocate Idx Int [Ndx]         -- ^ Move an instance to a new
-                                     -- secondary node
-    deriving (Show)
-
--- | A complete request, as received from Ganeti.
-data Request = Request RqType Node.List Instance.List String
-    deriving (Show)
-
 -- | Parse the basic specifications of an instance.
 --
 -- Instances in the cluster instance list and the instance in an
diff --git a/Ganeti/HTools/Loader.hs b/Ganeti/HTools/Loader.hs
index 0683d38cd..d409ed353 100644
--- a/Ganeti/HTools/Loader.hs
+++ b/Ganeti/HTools/Loader.hs
@@ -11,6 +11,8 @@ module Ganeti.HTools.Loader
     , lookupNode
     , lookupInstance
     , stripSuffix
+    , RqType(..)
+    , Request(..)
     ) where
 
 import Data.List
@@ -23,6 +25,26 @@ import qualified Ganeti.HTools.Node as Node
 
 import Ganeti.HTools.Types
 
+-- * Types
+
+{-| The request type.
+
+This type denotes what request we got from Ganeti and also holds
+request-specific fields.
+
+-}
+data RqType
+    = Allocate Instance.Instance Int -- ^ A new instance allocation
+    | Relocate Idx Int [Ndx]         -- ^ Move an instance to a new
+                                     -- secondary node
+    deriving (Show)
+
+-- | A complete request, as received from Ganeti.
+data Request = Request RqType Node.List Instance.List String
+    deriving (Show)
+
+-- * Functions
+
 -- | Lookups a node into an assoc list.
 lookupNode :: (Monad m) => [(String, Ndx)] -> String -> String -> m Ndx
 lookupNode ktn inst node =
diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs
index e33ab0c68..c1e467464 100644
--- a/Ganeti/HTools/Types.hs
+++ b/Ganeti/HTools/Types.hs
@@ -3,7 +3,12 @@
 -}
 
 module Ganeti.HTools.Types
-    where
+    ( Idx
+    , Ndx
+    , NameAssoc
+    , Result(..)
+    , Element(..)
+    ) where
 
 -- | The instance index type.
 type Idx = Int
diff --git a/hail.hs b/hail.hs
index 69348d125..a8b1c0766 100644
--- a/hail.hs
+++ b/hail.hs
@@ -22,6 +22,7 @@ import qualified Ganeti.HTools.Instance as Instance
 import qualified Ganeti.HTools.CLI as CLI
 import Ganeti.HTools.IAlloc
 import Ganeti.HTools.Types
+import Ganeti.HTools.Loader (RqType(..), Request(..))
 
 -- | Command line options structure.
 data Options = Options
-- 
GitLab