summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-09-13 16:36:08 +0200
committerChristian Poessinger <christian@poessinger.com>2019-09-20 21:28:53 +0200
commit66884984c7b4b5b445322828541a942fa9e705c1 (patch)
tree9864c639b5ae80310a8946ae993b6471ed1f14f7 /python/vyos
parentf107a252020d225b4e7429cc5c3a61af6cb2e1d9 (diff)
downloadvyos-1x-66884984c7b4b5b445322828541a942fa9e705c1.tar.gz
vyos-1x-66884984c7b4b5b445322828541a942fa9e705c1.zip
Python/ifconfig: T1557: ethernet: add method for changing speed and duplex
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py
index ab8799e54..507df0d71 100644
--- a/python/vyos/ifconfig.py
+++ b/python/vyos/ifconfig.py
@@ -1095,6 +1095,28 @@ class EthernetIf(VLANIf):
except CalledProcessError:
pass
+ def set_speed_duplex(self, speed, duplex):
+ """
+ Set link speed in Mbit/s and duplex.
+
+ @speed can be any link speed in MBit/s, e.g. 10, 100, 1000 auto
+ @duplex can be half, full, auto
+ """
+
+ if speed not in ['auto', '10', '100', '1000', '2500', '5000', '10000', '25000', '40000', '50000', '100000', '400000']:
+ raise ValueError("Value out of range (speed)")
+
+ if duplex not in ['auto', 'full', 'half']:
+ raise ValueError("Value out of range (duplex)")
+
+ cmd = 'ethtool -s {}'.format(self._ifname)
+ if speed == 'auto' or duplex == 'auto':
+ cmd += ' autoneg on'
+ else:
+ cmd += ' speed {} duplex {} autoneg off'.format(speed, duplex)
+
+ return self._cmd(cmd)
+
class BondIf(VLANIf):
"""