summaryrefslogtreecommitdiff
path: root/python/vyos/ethtool.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-08-31 21:28:08 +0200
committerChristian Poessinger <christian@poessinger.com>2021-08-31 21:28:08 +0200
commit6f5fb5c503b5df96d0686002355da3633b1fc597 (patch)
tree1d6293a5262f5c25597dde9c9c812839849b88c0 /python/vyos/ethtool.py
parentcc742d48579e4f76e5d3230d87e22f71f76f9301 (diff)
downloadvyos-1x-6f5fb5c503b5df96d0686002355da3633b1fc597.tar.gz
vyos-1x-6f5fb5c503b5df96d0686002355da3633b1fc597.zip
vyos.ethtool: T3163: purify code to read current speed and duplex settings
It makes no sense to have a parser for the ethtool value sin ethtool.py and ethernet.py - one instance ios more then enough!
Diffstat (limited to 'python/vyos/ethtool.py')
-rw-r--r--python/vyos/ethtool.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/python/vyos/ethtool.py b/python/vyos/ethtool.py
index 968e2e2a3..e803e28a1 100644
--- a/python/vyos/ethtool.py
+++ b/python/vyos/ethtool.py
@@ -44,6 +44,7 @@ class Ethtool:
_speed_duplex = { }
_ring_buffers = { }
_driver_name = None
+ _auto_negotiation = None
def __init__(self, ifname):
# Get driver used for interface
@@ -65,7 +66,6 @@ class Ethtool:
reading = True
if 'Supported pause frame use:' in line:
reading = False
- break
if reading:
for block in line.split():
if pattern.search(block):
@@ -75,6 +75,15 @@ class Ethtool:
self._speed_duplex.update({ speed : {}})
if duplex not in self._speed_duplex[speed]:
self._speed_duplex[speed].update({ duplex : ''})
+ if 'Auto-negotiation:' in line:
+ # Split the following string: Auto-negotiation: off
+ # we are only interested in off or on
+ tmp = line.split()[-1]
+ self._auto_negotiation = bool(tmp == 'on')
+
+ if self._auto_negotiation == None:
+ raise ValueError(f'Could not determine auto-negotiation settings '\
+ f'for interface {ifname}!')
# Now populate features dictionaty
out, err = popen(f'ethtool --show-features {ifname}')
@@ -162,3 +171,5 @@ class Ethtool:
return True
return False
+ def get_auto_negotiation(self):
+ return self._auto_negotiation