diff options
author | Christian Poessinger <christian@poessinger.com> | 2023-01-04 17:54:24 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2023-01-04 17:55:48 +0100 |
commit | ae8935ce62e55ad047b51bebef8a1d9124ed1826 (patch) | |
tree | 2c8b698630431c4790673d1e8ded2e45bea0f9c7 /python | |
parent | f5af95be4f66380d213771b975c63361e27616ef (diff) | |
download | vyos-1x-ae8935ce62e55ad047b51bebef8a1d9124ed1826.tar.gz vyos-1x-ae8935ce62e55ad047b51bebef8a1d9124ed1826.zip |
qos: T4284: add bandwidth percentage value
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/qos/base.py | 5 |
1 files changed, 4 insertions, 1 deletions
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()])) |