Commit b6afa809 authored by Dimitris Aragiorgis's avatar Dimitris Aragiorgis Committed by Klaus Aehlig

Fix query mechanism wrt networks and vlans

Let query mechanism (both python and haskell) be aware of the
vlan info included in a network's netparams.
Signed-off-by: default avatarDimitris Aragiorgis <dimara@grnet.gr>
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarKlaus Aehlig <aehlig@google.com>
parent 7f08b221
......@@ -160,8 +160,9 @@ def ListNetworks(opts, args):
desired_fields = ParseFields(opts.output, _LIST_DEF_FIELDS)
fmtoverride = {
"group_list":
(lambda data: utils.CommaJoin("%s (%s, %s)" % (name, mode, link)
for (name, mode, link) in data),
(lambda data:
utils.CommaJoin("%s (%s, %s, %s)" % (name, mode, link, vlan)
for (name, mode, link, vlan) in data),
False),
"inst_list": (",".join, False),
"tags": (",".join, False),
......@@ -240,8 +241,9 @@ def ShowNetworkConfig(_, args):
if group_list:
ToStdout(" connected to node groups:")
for group, nic_mode, nic_link in group_list:
ToStdout(" %s (%s on %s)", group, nic_mode, nic_link)
for group, nic_mode, nic_link, nic_vlan in group_list:
ToStdout(" %s (mode:%s link:%s vlan:%s)",
group, nic_mode, nic_link, nic_vlan)
else:
ToStdout(" not connected to any node group")
......
......@@ -455,7 +455,8 @@ class NetworkQuery(QueryBase):
netparams = group.networks.get(net_uuid, None)
if netparams:
info = (group.name, netparams[constants.NIC_MODE],
netparams[constants.NIC_LINK])
netparams[constants.NIC_LINK],
netparams[constants.NIC_VLAN])
network_to_groups[net_uuid].append(info)
......
......@@ -106,7 +106,8 @@ fieldsMap =
-- | Given a network's UUID, this function lists all connections from
-- the network to nodegroups including the respective mode and links.
getGroupConnections :: ConfigData -> String -> [(String, String, String)]
getGroupConnections ::
ConfigData -> String -> [(String, String, String, String)]
getGroupConnections cfg network_uuid =
mapMaybe (getGroupConnection network_uuid)
((Map.elems . fromContainer . configNodegroups) cfg)
......@@ -115,13 +116,14 @@ getGroupConnections cfg network_uuid =
-- a tuple of the group's name, the mode and the link by which the
-- network is connected to the group. Returns 'Nothing' if the network
-- is not connected to the group.
getGroupConnection :: String -> NodeGroup -> Maybe (String, String, String)
getGroupConnection ::
String -> NodeGroup -> Maybe (String, String, String, String)
getGroupConnection network_uuid group =
let networks = fromContainer . groupNetworks $ group
in case Map.lookup network_uuid networks of
Nothing -> Nothing
Just net ->
Just (groupName group, getNicMode net, getNicLink net)
Just (groupName group, getNicMode net, getNicLink net, getNicVlan net)
-- | Retrieves the network's mode and formats it human-readable,
-- also in case it is not available.
......@@ -129,11 +131,16 @@ getNicMode :: PartialNicParams -> String
getNicMode nic_params =
maybe "-" nICModeToRaw $ nicpModeP nic_params
-- | Retrieves the network's link and formats it human-readable, also in
-- | Retrieves the network's vlan and formats it human-readable, also in
-- case it it not available.
getNicLink :: PartialNicParams -> String
getNicLink nic_params = fromMaybe "-" (nicpLinkP nic_params)
-- | Retrieves the network's link and formats it human-readable, also in
-- case it it not available.
getNicVlan :: PartialNicParams -> String
getNicVlan nic_params = fromMaybe "-" (nicpVlanP nic_params)
-- | Retrieves the network's instances' names.
getInstances :: ConfigData -> String -> [String]
getInstances cfg network_uuid =
......
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