Commit a0be8f1a authored by Thomas Thrainer's avatar Thomas Thrainer
Browse files

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: default avatarThomas Thrainer <thomasth@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent c8b199db
......@@ -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:
......
......@@ -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.
......
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
......
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
......
group-01|fake-uuid-01|preferred|
group-01|fake-uuid-01|preferred||
......
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
......
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
......
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
......
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
......
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
......
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
......
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
......
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
......
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment