summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriyEshenko <snooppy@mail.ua>2019-08-10 19:45:14 +0000
committerJohn Estabrook <jestabro@vyos.io>2020-07-12 09:46:58 -0500
commiteb6bfbd75bf61828af886b3c9a06384e49b451ae (patch)
tree8b21d8fc133340fe49b68c623d13e637524ecd3d
parent136cef97bbd2c0360e5f554bb469cb1311cda0db (diff)
downloadvyos-1x-eb6bfbd75bf61828af886b3c9a06384e49b451ae.tar.gz
vyos-1x-eb6bfbd75bf61828af886b3c9a06384e49b451ae.zip
snmp: T1575: Adding additional check for lspci
(cherry-picked from commits dc936192e87f114df6ab6a4df44967ce0f2b8390 c291d18377eb6eea6693050c338b0392e1297e74)
-rwxr-xr-xsrc/op_mode/snmp_ifmib.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/op_mode/snmp_ifmib.py b/src/op_mode/snmp_ifmib.py
index 9d56a950b..3a0e0d4b2 100755
--- a/src/op_mode/snmp_ifmib.py
+++ b/src/op_mode/snmp_ifmib.py
@@ -77,10 +77,16 @@ def show_ifdescr(i):
proc = subprocess.Popen(['/usr/bin/lspci', '-mm', '-d', device], stdout=subprocess.PIPE)
(out, err) = proc.communicate()
+ vendor = ""
+ device = ""
+
# convert output to string
string = out.decode("utf-8").split('"')
- vendor = string[3]
- device = string[5]
+ if len(string) > 3:
+ vendor = string[3]
+
+ if len(string) > 5:
+ device = string[5]
ret = 'ifDescr = {0} {1}'.format(vendor, device)
return ret.replace('\n', '')