From b370735455de5bd82205cda535a2318bf725572d Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Mon, 22 Nov 2010 15:33:13 +0000 Subject: [PATCH] Text: read/save the node group UUID Compatibility with old text files is kept by using the default UUID if the file (or even some records) don't have a UUID. Signed-off-by: Iustin Pop <iustin@google.com> Reviewed-by: Balazs Lecz <leczb@google.com> --- Ganeti/HTools/Text.hs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/Ganeti/HTools/Text.hs b/Ganeti/HTools/Text.hs index 5b8d95598..7c7fcad74 100644 --- a/Ganeti/HTools/Text.hs +++ b/Ganeti/HTools/Text.hs @@ -53,10 +53,11 @@ import qualified Ganeti.HTools.Instance as Instance -- | Serialize a single node serializeNode :: Node.Node -> String serializeNode node = - printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c" (Node.name node) + printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s" (Node.name node) (Node.tMem node) (Node.nMem node) (Node.fMem node) (Node.tDsk node) (Node.fDsk node) (Node.tCpu node) (if Node.offline node then 'Y' else 'N') + (Node.group node) -- | Generate node file data from node objects serializeNodes :: Node.List -> String @@ -92,10 +93,13 @@ serializeCluster nl il = -- | Load a node from a field list. loadNode :: (Monad m) => [String] -> m (String, Node.Node) -loadNode [name, tm, nm, fm, td, fd, tc, fo] = do +-- 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, gu] = do new_node <- if any (== "?") [tm,nm,fm,td,fd,tc] || fo == "Y" then - return $ Node.create name 0 0 0 0 0 0 True defaultUUID + return $ Node.create name 0 0 0 0 0 0 True gu else do vtm <- tryRead name tm vnm <- tryRead name nm @@ -103,7 +107,7 @@ loadNode [name, tm, nm, fm, td, fd, tc, fo] = do vtd <- tryRead name td vfd <- tryRead name fd vtc <- tryRead name tc - return $ Node.create name vtm vnm vfm vtd vfd vtc False defaultUUID + return $ Node.create name vtm vnm vfm vtd vfd vtc False gu return (name, new_node) loadNode s = fail $ "Invalid/incomplete node data: '" ++ show s ++ "'" -- GitLab