From ae8935ce62e55ad047b51bebef8a1d9124ed1826 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 4 Jan 2023 17:54:24 +0100 Subject: qos: T4284: add bandwidth percentage value --- python/vyos/qos/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/vyos/qos/base.py b/python/vyos/qos/base.py index d039bbb0f..96f189b1a 100644 --- a/python/vyos/qos/base.py +++ b/python/vyos/qos/base.py @@ -116,11 +116,14 @@ class QoSBase: 'tbit' : 1000000000000, } - if rate == 'auto': + if rate == 'auto' or rate.endswith('%'): speed = read_file(f'/sys/class/net/{self._interface}/speed') if not speed.isnumeric(): Warning('Interface speed cannot be determined (assuming 10 Mbit/s)') speed = 10 + if rate.endswith('%'): + percent = rate.rstrip('%') + speed = int(speed) * int(percent) // 100 return int(speed) *1000000 # convert to MBit/s rate_numeric = int(''.join([n for n in rate if n.isdigit()])) -- cgit v1.2.3