Text.hs: also save the group data when serialising
authorIustin Pop <iustin@google.com>
Wed, 15 Dec 2010 17:49:12 +0000 (18:49 +0100)
committerIustin Pop <iustin@google.com>
Mon, 20 Dec 2010 12:23:45 +0000 (13:23 +0100)
This should have been in the previous patches, but sent separate for
clarity.

The live-test script is updated to read the first node from the
cluster, now that the text files don't start anymore with the node
data.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Balazs Lecz <leczb@google.com>

Ganeti/HTools/Text.hs
live-test.sh

index 2b2c725..11c2770 100644 (file)
@@ -51,6 +51,15 @@ import qualified Ganeti.HTools.Group as Group
 import qualified Ganeti.HTools.Node as Node
 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)
+
+-- | Generate group file data from a group list
+serializeGroups :: Group.List -> String
+serializeGroups = unlines . map serializeGroup . Container.elems
+
 -- | Serialize a single node
 serializeNode :: Group.List -> Node.Node -> String
 serializeNode gl node =
@@ -89,9 +98,10 @@ serializeInstances nl =
 -- | Generate complete cluster data from node and instance lists
 serializeCluster :: Group.List -> Node.List -> Instance.List -> String
 serializeCluster gl nl il =
-  let ndata = serializeNodes gl nl
+  let gdata = serializeGroups gl
+      ndata = serializeNodes gl nl
       idata = serializeInstances nl il
-  in ndata ++ ['\n'] ++ idata
+  in gdata ++ ['\n'] ++ ndata ++ ['\n'] ++ idata
 
 -- | Load a group from a field list.
 loadGroup :: (Monad m) => [String] -> m (String, Group.Group)
index c2a6d2f..3768331 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/bash
 
-# Copyright (C) 2009 Google Inc.
+# Copyright (C) 2009, 2010 Google Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -48,7 +48,7 @@ echo Testing hscan/luxi
 echo Comparing hscan results...
 diff -u $T/$RAPI.data $T/LOCAL.data
 
-FN=$(head -n1 $T/$RAPI.data|cut -d \| -f1)
+FN=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_node_list)
 FI=$($CLUSTER head -n1 /var/lib/ganeti/ssconf_instance_list)