From e4d8071d7f396a338e30e25373190a590288dfdd Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Wed, 15 Dec 2010 18:49:12 +0100 Subject: [PATCH] Text.hs: also save the group data when serialising 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 | 14 ++++++++++++-- live-test.sh | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs index 2b2c725ff..11c2770db 100644 --- a/Ganeti/HTools/Text.hs +++ b/Ganeti/HTools/Text.hs @@ -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) diff --git a/live-test.sh b/live-test.sh index c2a6d2fa0..37683317d 100755 --- a/live-test.sh +++ b/live-test.sh @@ -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) -- GitLab