From f951bd093603868d39d8bf61c03c31c213bf068a Mon Sep 17 00:00:00 2001 From: Iustin Pop <iustin@google.com> Date: Thu, 16 Feb 2012 13:34:02 +0100 Subject: [PATCH] htools: support spindles in text load/save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 | 12 +++++++++--- man/htools.rst | 20 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/htools/Ganeti/HTools/Text.hs b/htools/Ganeti/HTools/Text.hs index c01376e59..4c861fabe 100644 --- a/htools/Ganeti/HTools/Text.hs +++ b/htools/Ganeti/HTools/Text.hs @@ -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. diff --git a/man/htools.rst b/man/htools.rst index 3449b4ef0..338b99c64 100644 --- a/man/htools.rst +++ b/man/htools.rst @@ -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 -- GitLab