Extend Text format by marking the master node
authorKlaus Aehlig <aehlig@google.com>
Fri, 19 Apr 2013 12:58:43 +0000 (14:58 +0200)
committerKlaus Aehlig <aehlig@google.com>
Mon, 22 Apr 2013 16:43:21 +0000 (18:43 +0200)
Sometimes, e.g., for hroller, it is necessary to know which node
is the master node. Therefore this information has to be included
in the text format as well. Since we never use an offline node as
master node, we can put this information can be put in the "is
offline" field; as old versions only check this field for equality
to "Y", using "M" to indicate the master is compatible in both
directions. This also leaves room to add more roles in the future,
should we need them.

Signed-off-by: Klaus Aehlig <aehlig@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

src/Ganeti/HTools/Backend/Text.hs

index 755d8be..579ce77 100644 (file)
@@ -83,7 +83,8 @@ serializeNode gl node =
   printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s|%d" (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')
+           (if Node.offline node then 'Y' else
+              if Node.isMaster node then 'M' else 'N')
            (Group.uuid grp)
            (Node.spindleCount node)
     where grp = Container.find (Node.group node) gl
@@ -196,7 +197,8 @@ loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles] = do
         vfd <- tryRead name fd
         vtc <- tryRead name tc
         vspindles <- tryRead name spindles
-        return $ Node.create name vtm vnm vfm vtd vfd vtc False vspindles gdx
+        return . flip Node.setMaster (fo == "M") $
+          Node.create name vtm vnm vfm vtd vfd vtc False vspindles gdx
   return (name, new_node)
 
 loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu] =