From cbae374bd1c9980c704b7c952945175e288195c3 Mon Sep 17 00:00:00 2001 From: Solvik Blum Date: Sun, 19 Apr 2020 12:13:38 +0200 Subject: [PATCH] fix ethtool class in case ethtool works but returns nothing --- netbox_agent/ethtool.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/netbox_agent/ethtool.py b/netbox_agent/ethtool.py index a58ef50a..132cd09c 100644 --- a/netbox_agent/ethtool.py +++ b/netbox_agent/ethtool.py @@ -65,11 +65,11 @@ def _parse_ethtool_output(self): def _parse_ethtool_module_output(self): status, output = subprocess.getstatusoutput('ethtool -m {}'.format(self.interface)) - if status != 0: - return {} - r = re.search(r'Identifier.*\((\w+)\)', output) - if r and len(r.groups()) > 0: - return {'form_factor': r.groups()[0]} + if status == 0: + r = re.search(r'Identifier.*\((\w+)\)', output) + if r and len(r.groups()) > 0: + return {'form_factor': r.groups()[0]} + return {} def parse(self): if which('ethtool') is None: