Commit 503574ec authored by Michael Hanselmann's avatar Michael Hanselmann
Browse files

Format network field "group_list" in client



The field is now a list of tuples containing the group name, mode and
link.
Signed-off-by: default avatarMichael Hanselmann <hansmi@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parent f1222089
......@@ -153,10 +153,13 @@ def ListNetworks(opts, args):
"""
desired_fields = ParseFields(opts.output, _LIST_DEF_FIELDS)
fmtoverride = {
"group_list": (",".join, False),
"group_list":
(lambda data: utils.CommaJoin("%s (%s, %s)" % (name, mode, link)
for (name, mode, link) in data),
False),
"inst_list": (",".join, False),
"tags": (",".join, False),
}
}
return GenericList(constants.QR_NETWORK, desired_fields, args, None,
opts.separator, not opts.no_headers,
......
......@@ -16225,9 +16225,10 @@ class _NetworkQuery(_QueryBase):
for net_uuid in group.networks.keys():
if net_uuid in network_to_groups:
netparams = group.networks[net_uuid]
mode = netparams[constants.NIC_MODE]
link = netparams[constants.NIC_LINK]
info = group.name + "(" + mode + ", " + link + ")"
info = (group.name, netparams[constants.NIC_MODE],
netparams[constants.NIC_LINK])
network_to_groups[net_uuid].append(info)
 
if do_instances:
......
......@@ -2556,8 +2556,9 @@ def _BuildNetworkFields():
fields.extend([
(_MakeField("group_cnt", "NodeGroups", QFT_NUMBER, "Number of nodegroups"),
NETQ_GROUP, 0, _GetLength(network_to_groups)),
(_MakeField("group_list", "GroupList", QFT_OTHER, "List of nodegroups"),
NETQ_GROUP, 0, _GetSortedList(network_to_groups)),
(_MakeField("group_list", "GroupList", QFT_OTHER,
"List of nodegroups (group name, NIC mode, NIC link)"),
NETQ_GROUP, 0, lambda ctx, network: network_to_groups(ctx)[network.uuid]),
])
# Add fields for instances
......
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