Let query mechanism (both python and haskell) be aware of the
vlan info included in a network's netparams.

Signed-off-by: Dimitris Aragiorgis <[email protected]>
---
 lib/client/gnt_network.py   |   10 ++++++----
 lib/cmdlib/network.py       |    3 ++-
 src/Ganeti/Query/Network.hs |   15 +++++++++++----
 3 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/lib/client/gnt_network.py b/lib/client/gnt_network.py
index 2c6e464..aff0b59 100644
--- a/lib/client/gnt_network.py
+++ b/lib/client/gnt_network.py
@@ -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")
 
diff --git a/lib/cmdlib/network.py b/lib/cmdlib/network.py
index 76581e6..3596adb 100644
--- a/lib/cmdlib/network.py
+++ b/lib/cmdlib/network.py
@@ -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)
 
diff --git a/src/Ganeti/Query/Network.hs b/src/Ganeti/Query/Network.hs
index edbb3b5..6651f88 100644
--- a/src/Ganeti/Query/Network.hs
+++ b/src/Ganeti/Query/Network.hs
@@ -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 =
-- 
1.7.10.4

Reply via email to