From: Thomas Thrainer Date: Fri, 24 May 2013 08:03:02 +0000 (+0200) Subject: Support group networks in Text backend X-Git-Tag: v2.8.0beta1~46 X-Git-Url: https://code.grnet.gr/git/ganeti-local/commitdiff_plain/a0be8f1a137566e9ed0f864eeeb785a0ab3bbc00 Support group networks in Text backend The Text backend now parses network UUID (comma separated) and serializes them in the same form. The test data is adapted to the new format. Signed-off-by: Thomas Thrainer Reviewed-by: Guido Trotter --- diff --git a/man/htools.rst b/man/htools.rst index 22b67bb..8b83526 100644 --- a/man/htools.rst +++ b/man/htools.rst @@ -163,6 +163,7 @@ support all options. Some common options are: - group uuid - allocation policy - tags (separated by comma) + - networks (UUID's, separated by comma) The second sections contains node data, with the following columns: diff --git a/src/Ganeti/HTools/Backend/Text.hs b/src/Ganeti/HTools/Backend/Text.hs index 96a5290..54ad41d 100644 --- a/src/Ganeti/HTools/Backend/Text.hs +++ b/src/Ganeti/HTools/Backend/Text.hs @@ -69,9 +69,10 @@ commaSplit = sepSplit ',' -- | Serialize a single group. serializeGroup :: Group.Group -> String serializeGroup grp = - printf "%s|%s|%s|%s" (Group.name grp) (Group.uuid grp) + printf "%s|%s|%s|%s|%s" (Group.name grp) (Group.uuid grp) (allocPolicyToRaw (Group.allocPolicy grp)) (intercalate "," (Group.allTags grp)) + (intercalate "," (Group.networks grp)) -- | Generate group file data from a group list. serializeGroups :: Group.List -> String @@ -182,12 +183,12 @@ serializeCluster (ClusterData gl nl il ctags cpol) = loadGroup :: (Monad m) => [String] -> m (String, Group.Group) -- ^ The result, a tuple of group -- UUID and group object -loadGroup [name, gid, apol, tags] = do +loadGroup [name, gid, apol, tags, nets] = do xapol <- allocPolicyFromRaw apol let xtags = commaSplit tags - -- TODO: parse networks to which this group is connected - return (gid, Group.create name gid xapol [] defIPolicy xtags) - + let xnets = commaSplit nets + return (gid, Group.create name gid xapol xnets defIPolicy xtags) +loadGroup [name, gid, apol, tags] = loadGroup [name, gid, apol, tags, ""] loadGroup s = fail $ "Invalid/incomplete group data: '" ++ show s ++ "'" -- | Load a node from a field list. diff --git a/test/data/htools/clean-nonzero-score.data b/test/data/htools/clean-nonzero-score.data index 28ebdf1..8380fb1 100644 --- a/test/data/htools/clean-nonzero-score.data +++ b/test/data/htools/clean-nonzero-score.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01-001|91552|0|91424|953674|953674|16|N|fake-uuid-01|1 node-01-002|91552|0|91296|953674|953674|16|N|fake-uuid-01|1 diff --git a/test/data/htools/common-suffix.data b/test/data/htools/common-suffix.data index 1e34c94..bce119d 100644 --- a/test/data/htools/common-suffix.data +++ b/test/data/htools/common-suffix.data @@ -1,4 +1,4 @@ -default|fake-uuid-01|preferred| +default|fake-uuid-01|preferred|| node1.example.com|1024|0|1024|95367|95367|4|N|fake-uuid-01|1 node2.example.com|1024|0|896|95367|94343|4|N|fake-uuid-01|1 diff --git a/test/data/htools/empty-cluster.data b/test/data/htools/empty-cluster.data index 9e17bbb..c58b412 100644 --- a/test/data/htools/empty-cluster.data +++ b/test/data/htools/empty-cluster.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| diff --git a/test/data/htools/hbal-excl-tags.data b/test/data/htools/hbal-excl-tags.data index c243aef..6c53395 100644 --- a/test/data/htools/hbal-excl-tags.data +++ b/test/data/htools/hbal-excl-tags.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01|16384|0|14336|409600|153600|16|N|fake-uuid-01|1 node-02|16384|0|13312|409600|153600|16|N|fake-uuid-01|1 diff --git a/test/data/htools/hbal-split-insts.data b/test/data/htools/hbal-split-insts.data index fe3bb22..4d00956 100644 --- a/test/data/htools/hbal-split-insts.data +++ b/test/data/htools/hbal-split-insts.data @@ -1,5 +1,5 @@ -group-01|fake-uuid-01|preferred| -group-02|fake-uuid-02|preferred| +group-01|fake-uuid-01|preferred|| +group-02|fake-uuid-02|preferred|| node-01-001|98304|0|96256|8388608|8355840|16|N|fake-uuid-01|1 node-01-002|98304|0|96256|8388608|8355840|16|N|fake-uuid-01|1 diff --git a/test/data/htools/hspace-tiered-dualspec.data b/test/data/htools/hspace-tiered-dualspec.data index 46e44ce..8cb684c 100644 --- a/test/data/htools/hspace-tiered-dualspec.data +++ b/test/data/htools/hspace-tiered-dualspec.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01-001|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1 node-01-002|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1 diff --git a/test/data/htools/hspace-tiered.data b/test/data/htools/hspace-tiered.data index 61ee4c1..6d0698b 100644 --- a/test/data/htools/hspace-tiered.data +++ b/test/data/htools/hspace-tiered.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01-001|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1 node-01-002|262144|65536|196608|2097152|2097152|8|N|fake-uuid-01|1 diff --git a/test/data/htools/invalid-node.data b/test/data/htools/invalid-node.data index 9655f72..1aa5324 100644 --- a/test/data/htools/invalid-node.data +++ b/test/data/htools/invalid-node.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01-001|1024|0|1024|95367|95367|4|N|fake-uuid-01|1 node-01-002|1024|0|896|95367|94343|4|N|fake-uuid-01|1 diff --git a/test/data/htools/missing-resources.data b/test/data/htools/missing-resources.data index 500576a..15b55c0 100644 --- a/test/data/htools/missing-resources.data +++ b/test/data/htools/missing-resources.data @@ -1,4 +1,4 @@ -default|fake-uuid-01|preferred| +default|fake-uuid-01|preferred|| node1|1024|0|1024|95367|95367|4|N|fake-uuid-01|1 node2|1024|0|0|95367|0|4|N|fake-uuid-01|1 diff --git a/test/data/htools/multiple-master.data b/test/data/htools/multiple-master.data index 5d4fc52..2050835 100644 --- a/test/data/htools/multiple-master.data +++ b/test/data/htools/multiple-master.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01-001|91552|0|91424|953674|953674|16|M|fake-uuid-01|1 node-01-002|91552|0|91296|953674|953674|16|N|fake-uuid-01|1 diff --git a/test/data/htools/n1-failure.data b/test/data/htools/n1-failure.data index 5218750..482b1ed 100644 --- a/test/data/htools/n1-failure.data +++ b/test/data/htools/n1-failure.data @@ -1,5 +1,5 @@ -group-01|fake-uuid-01|preferred| -group-02|fake-uuid-02|unallocable| +group-01|fake-uuid-01|preferred|| +group-02|fake-uuid-02|unallocable|| node-01-001|256|0|0|7629394|7625298|16|N|fake-uuid-01|1 node-01-002|256|0|0|7629394|7625298|16|N|fake-uuid-01|1 diff --git a/test/data/htools/unique-reboot-order.data b/test/data/htools/unique-reboot-order.data index a756a05..7007aee 100644 --- a/test/data/htools/unique-reboot-order.data +++ b/test/data/htools/unique-reboot-order.data @@ -1,4 +1,4 @@ -group-01|fake-uuid-01|preferred| +group-01|fake-uuid-01|preferred|| node-01-001|91552|0|91424|953674|953674|16|M|fake-uuid-01|1 node-01-002|91552|0|91296|953674|953674|16|N|fake-uuid-01|1