From 236d28aa3097d5a5a859b3485f222e332348cdba Mon Sep 17 00:00:00 2001 From: Shane Bradley Date: Mon, 18 May 2015 11:25:15 -0400 Subject: [PATCH] [networking] nmcli incompatiblity issues There are some incompatible changes in nmcli since the release of NetworkManager >= 0.9.9. In addition, NetworkManager >= 0.9.9 will use the long names of "nmcli" objects. This is documented in the following article: https://wiki.gnome.org/Projects/NetworkManager/nmcli Signed-off-by: Shane Bradley --- sos/plugins/networking.py | 66 +++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 17 deletions(-) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 369d894261..52b2f8386f 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -110,15 +110,59 @@ def setup(self): "ip neigh show", "ip neigh show nud noarp", "ip netns", - "nmcli general status", - "nmcli connection show", - "nmcli connection show active", - "nmcli device status", - "nmcli device show", "biosdevname -d", "tc -s qdisc show", "iptables -vnxL" ]) + + # There are some incompatible changes in nmcli since + # the release of NetworkManager >= 0.9.9. In addition, + # NetworkManager >= 0.9.9 will use the long names of + # "nmcli" objects. + + # NetworkManager >= 0.9.9 (Use long names of objects for nmcli) + nmcli_status_result = self.call_ext_prog("nmcli general status") + if nmcli_status_result['status'] == 0: + self.add_cmd_output([ + "nmcli general status", + "nmcli connection show", + "nmcli connection show --active", + "nmcli device status", + "nmcli device show"]) + nmcli_con_show_result = self.call_ext_prog( + "nmcli --terse --fields NAME con show") + if nmcli_con_show_result['status'] == 0: + for con in nmcli_con_show_result['output'].splitlines(): + self.add_cmd_output("nmcli connection show id '%s'" % con) + + nmcli_dev_status_result = self.call_ext_prog( + "nmcli --terse --fields DEVICE device status") + if nmcli_dev_status_result['status'] == 0: + for dev in nmcli_dev_status_result['output'].splitlines(): + self.add_cmd_output("nmcli device show '%s'" % dev) + + # NetworkManager < 0.9.9 (Use short name of objects for nmcli) + nmcli_status_result = self.call_ext_prog("nmcli nm status") + if nmcli_status_result['status'] == 0: + self.add_cmd_output([ + "nmcli nm status", + "nmcli con", + "nmcli con status", + "nmcli dev status", + "nmcli dev"]) + + nmcli_con_show_result = self.call_ext_prog( + "nmcli --terse --fields NAME con") + if nmcli_con_show_result['status'] == 0: + for con in nmcli_con_show_result['output'].splitlines(): + self.add_cmd_output("nmcli con list id '%s'" % con) + + nmcli_dev_status_result = self.call_ext_prog( + "nmcli --terse --fields DEVICE dev status") + if nmcli_dev_status_result['status'] == 0: + for dev in nmcli_dev_status_result['output'].splitlines(): + self.add_cmd_output("nmcli dev list iface '%s'" % dev) + ip_link_result = self.call_ext_prog("ip -o link") if ip_link_result['status'] == 0: for eth in self.get_eth_interfaces(ip_link_result['output']): @@ -141,18 +185,6 @@ def setup(self): "brctl showmacs "+br_name ]) - nmcli_con_show_result = self.call_ext_prog( - "nmcli --terse --fields NAME con show") - if nmcli_con_show_result['status'] == 0: - for con in nmcli_con_show_result['output'].splitlines(): - self.add_cmd_output("nmcli con show conf '%s'" % con) - - nmcli_dev_status_result = self.call_ext_prog( - "nmcli --terse --fields DEVICE dev status") - if nmcli_dev_status_result['status'] == 0: - for dev in nmcli_dev_status_result['output'].splitlines(): - self.add_cmd_output("nmcli device show "+dev) - if self.get_option("traceroute"): self.add_cmd_output("/bin/traceroute -n %s" % self.trace_host)