From c4d98278dc11d64d903332056cf0c10c05155b32 Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Mon, 29 Nov 2010 16:52:34 +0000
Subject: [PATCH] Add a type alias for UUIDs

This is to pottentially allow easier changes later.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>
---
 Ganeti/HTools/Node.hs  | 2 +-
 Ganeti/HTools/QC.hs    | 2 +-
 Ganeti/HTools/Simu.hs  | 2 +-
 Ganeti/HTools/Text.hs  | 2 +-
 Ganeti/HTools/Types.hs | 4 ++++
 Ganeti/HTools/Utils.hs | 8 ++++----
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/Ganeti/HTools/Node.hs b/Ganeti/HTools/Node.hs
index be2a3dc8b..88a6000fc 100644
--- a/Ganeti/HTools/Node.hs
+++ b/Ganeti/HTools/Node.hs
@@ -119,7 +119,7 @@ data Node = Node
     , utilPool :: T.DynUtil -- ^ Total utilisation capacity
     , utilLoad :: T.DynUtil -- ^ Sum of instance utilisation
     , pTags    :: TagMap    -- ^ Map of primary instance tags and their count
-    , group    :: String    -- ^ The node's group (as UUID)
+    , group    :: T.GroupID -- ^ The node's group (as UUID)
     } deriving (Show, Eq)
 
 instance T.Element Node where
diff --git a/Ganeti/HTools/QC.hs b/Ganeti/HTools/QC.hs
index 5e7120ea0..8b46aa559 100644
--- a/Ganeti/HTools/QC.hs
+++ b/Ganeti/HTools/QC.hs
@@ -176,7 +176,7 @@ instance Arbitrary Node.Node where
       offl <- arbitrary
       let n = Node.create name (fromIntegral mem_t) mem_n mem_f
               (fromIntegral dsk_t) dsk_f (fromIntegral cpu_t) offl
-              Utils.defaultUUID
+              Utils.defaultGroupID
           n' = Node.buildPeers n Container.empty
       return n'
 
diff --git a/Ganeti/HTools/Simu.hs b/Ganeti/HTools/Simu.hs
index d41f4a39b..c29f3f58b 100644
--- a/Ganeti/HTools/Simu.hs
+++ b/Ganeti/HTools/Simu.hs
@@ -59,7 +59,7 @@ parseData ndata = do
                     let n = Node.create (printf "node%03d" idx)
                             (fromIntegral mem) 0 mem
                             (fromIntegral disk) disk
-                            (fromIntegral cpu) False defaultUUID
+                            (fromIntegral cpu) False defaultGroupID
                     in (idx, Node.setIdx n idx)
                   ) [1..cnt]
   return (nodes, [], [])
diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs
index 7c7fcad74..e61014d72 100644
--- a/Ganeti/HTools/Text.hs
+++ b/Ganeti/HTools/Text.hs
@@ -95,7 +95,7 @@ serializeCluster nl il =
 loadNode :: (Monad m) => [String] -> m (String, Node.Node)
 -- compatibility wrapper for old text files
 loadNode [name, tm, nm, fm, td, fd, tc, fo] =
-  loadNode [name, tm, nm, fm, td, fd, tc, fo, defaultUUID]
+  loadNode [name, tm, nm, fm, td, fd, tc, fo, defaultGroupID]
 loadNode [name, tm, nm, fm, td, fd, tc, fo, gu] = do
   new_node <-
       if any (== "?") [tm,nm,fm,td,fd,tc] || fo == "Y" then
diff --git a/Ganeti/HTools/Types.hs b/Ganeti/HTools/Types.hs
index 7cab64113..200163b9c 100644
--- a/Ganeti/HTools/Types.hs
+++ b/Ganeti/HTools/Types.hs
@@ -29,6 +29,7 @@ module Ganeti.HTools.Types
     , NameAssoc
     , Score
     , Weight
+    , GroupID
     , RSpec(..)
     , DynUtil(..)
     , zeroUtil
@@ -69,6 +70,9 @@ type Score = Double
 -- | A separate name for a weight metric.
 type Weight = Double
 
+-- | The Group UUID type
+type GroupID = String
+
 -- | The resource spec type.
 data RSpec = RSpec
     { rspecCpu  :: Int  -- ^ Requested VCPUs
diff --git a/Ganeti/HTools/Utils.hs b/Ganeti/HTools/Utils.hs
index 4cb4418a8..7ae236777 100644
--- a/Ganeti/HTools/Utils.hs
+++ b/Ganeti/HTools/Utils.hs
@@ -41,7 +41,7 @@ module Ganeti.HTools.Utils
     , tryRead
     , formatTable
     , annotateResult
-    , defaultUUID
+    , defaultGroupID
     ) where
 
 import Control.Monad (liftM)
@@ -211,6 +211,6 @@ formatTable vals numpos =
                     ) (zip3 vtrans numpos mlens)
    in transpose expnd
 
--- | Default UUID (just a string, not a real UUID)
-defaultUUID :: String
-defaultUUID = "00000000-0000-0000-0000-000000000000"
+-- | Default group UUID (just a string, not a real UUID)
+defaultGroupID :: GroupID
+defaultGroupID = "00000000-0000-0000-0000-000000000000"
-- 
GitLab