From 0105315ef05489bc7568dbcd0f5c38e5474b866a Mon Sep 17 00:00:00 2001 From: Shane Bradley Date: Thu, 18 Jun 2015 12:18:40 -0400 Subject: [networking] nmcli status is obtained from the output The nmcli status would always return 0, nmcli status is now determined by the output of the command instead of the return code. Signed-off-by: Shane Bradley --- sos/plugins/networking.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/sos/plugins/networking.py b/sos/plugins/networking.py index 59f38cef..a6db592f 100644 --- a/sos/plugins/networking.py +++ b/sos/plugins/networking.py @@ -123,7 +123,10 @@ class Networking(Plugin): # NetworkManager >= 0.9.9 (Use long names of objects for nmcli) nmcli_con_details_cmd = "" nmcli_dev_details_cmd = "" - if self.call_ext_prog("nmcli general status")['status'] == 0: + nmcli_status_cmd_v1 = "nmcli --terse --fields RUNNING general status" + nmcli_status_cmd_v0 = "nmcli --terse --fields RUNNING nm status" + if self.call_ext_prog( + nmcli_status_cmd_v1)['output'].lower().startswith("running"): self.add_cmd_output([ "nmcli general status", "nmcli con", @@ -132,7 +135,8 @@ class Networking(Plugin): nmcli_con_details_cmd = "nmcli con show id" nmcli_dev_details_cmd = "nmcli dev show" # NetworkManager < 0.9.9 (Use short name of objects for nmcli) - elif self.call_ext_prog("nmcli nm status")['status'] == 0: + elif self.call_ext_prog( + nmcli_status_cmd_v0)['output'].lower().startswith("running"): self.add_cmd_output([ "nmcli nm status", "nmcli con", @@ -146,13 +150,15 @@ class Networking(Plugin): "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("%s '%s'" % nmcli_con_details_cmd, con) + self.add_cmd_output("%s '%s'" % + (nmcli_con_details_cmd, con)) nmcli_dev_status_result = self.call_ext_prog( "nmcli --terse --fields DEVICE dev") if nmcli_dev_status_result['status'] == 0: for dev in nmcli_dev_status_result['output'].splitlines(): - self.add_cmd_output("%s '%s'" % nmcli_dev_details_cmd, dev) + self.add_cmd_output("%s '%s'" % + (nmcli_dev_details_cmd, dev)) ip_link_result = self.call_ext_prog("ip -o link") if ip_link_result['status'] == 0: -- cgit