From b6afa809538b9f6dd80953362e99a129147bf634 Mon Sep 17 00:00:00 2001 From: Dimitris Aragiorgis Date: Mon, 16 Jun 2014 14:05:16 +0300 Subject: [PATCH] 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: Dimitris Aragiorgis Signed-off-by: Klaus Aehlig Reviewed-by: Klaus Aehlig --- 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 2c6e4643e..aff0b59d5 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 76581e6dc..3596adb81 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 edbb3b523..6651f8834 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 = -- GitLab