From f4c7d37aa3d8a81bb403381abdfa9d213271fb9e Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@google.com>
Date: Thu, 16 Dec 2010 14:59:43 +0100
Subject: [PATCH] Text: read/write the allocation policy

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>
---
 Ganeti/HTools/Text.hs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs
index cf990609b..e690a8295 100644
--- a/Ganeti/HTools/Text.hs
+++ b/Ganeti/HTools/Text.hs
@@ -54,7 +54,8 @@ import qualified Ganeti.HTools.Instance as Instance
 -- | Serialize a single group
 serializeGroup :: Group.Group -> String
 serializeGroup grp =
-    printf "%s|%s" (Group.name grp) (Group.uuid grp)
+    printf "%s|%s|%s" (Group.name grp) (Group.uuid grp)
+               (apolToString (Group.allocPolicy grp))
 
 -- | Generate group file data from a group list
 serializeGroups :: Group.List -> String
@@ -107,8 +108,9 @@ serializeCluster gl nl il ctags =
 
 -- | Load a group from a field list.
 loadGroup :: (Monad m) => [String] -> m (String, Group.Group)
-loadGroup [name, gid] =
-  return $ (gid, Group.create name gid AllocPreferred)
+loadGroup [name, gid, apol] = do
+  xapol <- apolFromString apol
+  return $ (gid, Group.create name gid xapol)
 
 loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'"
 
-- 
GitLab