Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

T6452: Add QoS Op Commands #3591

Merged
merged 9 commits into from
Jun 28, 2024
Merged

T6452: Add QoS Op Commands #3591

merged 9 commits into from
Jun 28, 2024

Conversation

l0crian1
Copy link
Contributor

@l0crian1 l0crian1 commented Jun 6, 2024

Change Summary

Added the following Commands

show qos shaping
show qos shaping detail
show qos shaping interface
show qos shaping interface detail
show qos shaping interface class show qos shaping interface class detail show qos cake interface

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes)
  • Migration from an old Vyatta component to vyos-1x, please link to related PR inside obsoleted component
  • Other (please describe):

Related Task(s)

https://vyos.dev/T6452

Related PR(s)

Component(s) name

qos, op-mode

Proposed changes

This PR will add op mode commands for QoS. The following commands will be added:
show qos shaping
show qos shaping detail
show qos shaping interface
show qos shaping interface detail
show qos shaping interface class
show qos shaping interface class detail
show qos cake interface

Shaping commands will offer a table view by default, and an optional detailed view, which is presented in a list view:
Table View:

vyos@vyos:~$ show qos shaping interface eth1 class 10
--------------------------------------------------------------------------------
Interface: eth1
Policy Name: test

Class    Type            BW    Max. BW    Bytes    Pkts.    Drops    Queued
-------  --------  --------  ---------  -------  -------  -------  --------
root     htb       1.000 Gb   1.000 Gb     0  B        0        0         0
10       fq_codel  3.750 Mb   3.750 Mb     0  B        0        0         0
default  fq_codel  1.000 Mb   1.000 Mb     0  B        0        0         0

Detailed View:

vyos@vyos:~$ show qos shaping interface eth1 class 10 detail
-----------------------------------
Interface: eth1
Policy Name: test

 Interface   | eth1
 Policy Name | test
 Direction   | egress
 Class       | root
 Type        | htb
 BW          | 1000000000
 Max. BW     | 1000000000
 Bytes       | 0
 Pkts.       | 0
 Drops       | 0
 Queued      | 0
 Overlimit   | 0
 Requeue     | 0
 Lended      | 0
 Borrowed    | 0
 Giants      | 0

 Interface   | eth1
 Policy Name | test
 Direction   | egress
 Class       | 10
 Type        | fq_codel
 BW          | 3750000
 Max. BW     | 3750000
 Bytes       | 0
 Pkts.       | 0
 Drops       | 0
 Queued      | 0
 Overlimit   | 0
 Requeue     | 0
 Lended      | 0
 Borrowed    | 0
 Giants      | 0

 Interface   | eth1
 Policy Name | test
 Direction   | egress
 Class       | default
 Type        | fq_codel
 BW          | 1000000
 Max. BW     | 1000000
 Bytes       | 0
 Pkts.       | 0
 Drops       | 0
 Queued      | 0
 Overlimit   | 0
 Requeue     | 0
 Lended      | 0
 Borrowed    | 0
 Giants      | 0

How to test

Smoketest result

Checklist:

  • I have read the CONTRIBUTING document
  • I have linked this PR to one or more Phabricator Task(s)
  • I have run the components SMOKETESTS if applicable
  • My commit headlines contain a valid Task id
  • My change requires a change to the documentation
  • I have updated the documentation accordingly

Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
src/op_mode/qos.py Outdated Show resolved Hide resolved
op-mode-definitions/show-qos.xml.in Outdated Show resolved Hide resolved
src/op_mode/qos.py Outdated Show resolved Hide resolved
src/op_mode/qos.py Outdated Show resolved Hide resolved
l0crian1 and others added 3 commits June 12, 2024 10:30
Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
@sever-sever
Copy link
Member

I do not have any qos confiugred

vyos@r4:~$ show qos shaper interface eth1
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/qos.py", line 224, in <module>
    res = vyos.opmode.run(sys.modules[__name__])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 263, in run
    res = func(**args)
          ^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/qos.py", line 79, in show_shaping
    policy_name, class_dict = get_tc_info(interface_dict, interface_name, 'shaper')
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/qos.py", line 38, in get_tc_info
    class_dict = op_mode_config_dict(['qos', 'policy', policy_type, policy_name], key_mangling=('-', '_'),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configquery.py", line 168, in op_mode_config_dict
    rc, out = op_mode_run(command + path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configquery.py", line 155, in op_mode_run
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1834, in _execute_child
    self.pid = _fork_exec(
               ^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType
vyos@r4:~$ 

Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
@l0crian1
Copy link
Contributor Author

I do not have any qos confiugred

@sever-sever
I didn't have any checks against an empty config path. I added them. You'll now see this when trying to do "show qos" when it is not applied to an interface.

vyos@vyos# run show qos shaper
QoS is not applied to any interface!

vyos@vyos# run show qos shaper interface eth1
QoS is not applied to eth1!

Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
@sever-sever
Copy link
Member

vyos@r4# run show conf com | match qos
set qos interface eth1
set qos policy

fails

vyos@r4# run show qos shaper 
Traceback (most recent call last):
  File "/usr/libexec/vyos/op_mode/qos.py", line 230, in <module>
    res = vyos.opmode.run(sys.modules[__name__])
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/opmode.py", line 263, in run
    res = func(**args)
          ^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/qos.py", line 85, in show_shaping
    policy_name, class_dict = get_tc_info(interface_dict, interface_name, 'shaper')
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/libexec/vyos/op_mode/qos.py", line 38, in get_tc_info
    class_dict = op_mode_config_dict(['qos', 'policy', policy_type, policy_name], key_mangling=('-', '_'),
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configquery.py", line 168, in op_mode_config_dict
    rc, out = op_mode_run(command + path)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/vyos/configquery.py", line 155, in op_mode_run
    p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/subprocess.py", line 1024, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.11/subprocess.py", line 1834, in _execute_child
    self.pid = _fork_exec(
               ^^^^^^^^^^^
TypeError: expected str, bytes or os.PathLike object, not NoneType
[edit]
vyos@r4# 

Could you also change show_shaping => show_shaper?

Subcommand required!
usage: qos.py [-h] {show_cake,show_shaping} ...
[edit]
vyos@r4# 

Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
@l0crian1
Copy link
Contributor Author

vyos@r4# run show conf com | match qos
set qos interface eth1
set qos policy

fails
@sever-sever Added checks against empty config elements and renamed the function to show_shaper

src/op_mode/qos.py Outdated Show resolved Hide resolved
Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
@sever-sever sever-sever requested a review from c-po June 26, 2024 07:59
src/op_mode/qos.py Outdated Show resolved Hide resolved
Added the following commands:

show qos shaping
show qos shaping detail
show qos shaping interface <int name>
show qos shaping interface <int name> detail
show qos shaping interface <int name> class <class name>
show qos shaping interface <int name> class <class name> detail
show qos cake interface <int name>
Copy link

👍 VyOS CLI smoketests finished successfully!

@sever-sever sever-sever merged commit 206c07a into vyos:current Jun 28, 2024
11 of 12 checks passed
@HollyGurza
Copy link
Contributor

@c-po @dmbaturin
Need to backport on Sagitta?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

6 participants