htools: support spindles in text load/save
authorIustin Pop <iustin@google.com>
Thu, 16 Feb 2012 12:34:02 +0000 (13:34 +0100)
committerIustin Pop <iustin@google.com>
Wed, 29 Feb 2012 14:16:41 +0000 (15:16 +0100)
If missing, we'll default to 1 spindle.

This also updates the text file format with the ipolicy, which was
forgotten.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

htools/Ganeti/HTools/Text.hs
man/htools.rst

index c01376e..4c861fa 100644 (file)
@@ -78,11 +78,12 @@ serializeNode :: Group.List -- ^ The list of groups (needed for group uuid)
               -> Node.Node  -- ^ The node to be serialised
               -> String
 serializeNode gl node =
-  printf "%s|%.0f|%d|%d|%.0f|%d|%.0f|%c|%s" (Node.name 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')
            (Group.uuid grp)
+           (Node.spindleCount node)
     where grp = Container.find (Node.group node) gl
 
 -- | Generate node file data from node objects.
@@ -177,7 +178,7 @@ loadNode :: (Monad m) =>
          -> [String]              -- ^ Input data as a list of fields
          -> m (String, Node.Node) -- ^ The result, a tuple o node name
                                   -- and node object
-loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu] = do
+loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, spindles] = do
   gdx <- lookupGroup ktg name gu
   new_node <-
       if any (== "?") [tm,nm,fm,td,fd,tc] || fo == "Y" then
@@ -189,8 +190,13 @@ loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu] = do
         vtd <- tryRead name td
         vfd <- tryRead name fd
         vtc <- tryRead name tc
-        return $ Node.create name vtm vnm vfm vtd vfd vtc False 1 gdx
+        vspindles <- tryRead name spindles
+        return $ 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] =
+  loadNode ktg [name, tm, nm, fm, td, fd, tc, fo, gu, "1"]
+
 loadNode _ s = fail $ "Invalid/incomplete node data: '" ++ show s ++ "'"
 
 -- | Load an instance from a field list.
index 3449b4e..338b99c 100644 (file)
@@ -156,6 +156,7 @@ support all options. Some common options are:
   - node physical cores
   - offline field (as ``Y`` or ``N``)
   - group UUID
+  - node spindle count
 
   The third section contains instance data, with the fields:
 
@@ -170,8 +171,23 @@ support all options. Some common options are:
   - instance disk type (e.g. ``plain`` or ``drbd``)
   - instance tags
 
-  The fourth and last section contains the cluster tags, with one tag
-  per line (no columns/no column processing).
+  The fourth section contains the cluster tags, with one tag per line
+  (no columns/no column processing).
+
+  The fifth section contains the ipolicies of the cluster and the node
+  groups, in the following format (separated by ``|``):
+
+  - owner (empty if cluster, group name otherwise)
+  - standard, min, max instance specs, containing the following values
+    separated by commas:
+    - memory size
+    - cpu count
+    - disk size
+    - disk count
+    - nic count
+  - disk templates
+  - vcpu ratio
+  - spindle ratio
 
 -m *cluster*
   Backend specification: collect data directly from the *cluster* given