From 60ec84ec80e70e36a67fc25d6802bff100702027 Mon Sep 17 00:00:00 2001 From: FredYu Date: Wed, 13 Jan 2021 10:06:03 +0800 Subject: [PATCH] Provide QoS Scheduler CLI command and user guide - What I did Provide CLI to create and delete QoS Scheduler profiles. Syntax for QoS Scheduler * config qos scheduler del * config qos scheduler add [--meter_type=(byte | packet)] --pir= --pbs= - Why I did it We cannot create or remove QoS Scheduler profiles through CLI. - How I verified it We can create and delete QoS Scheduler profiles through CLI command. - Details if related Signed-off-by: Fred Yu fred_yu@edge-core.com --- config/main.py | 37 +++++++++++++++++++++++++ doc/Command-Reference.md | 58 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/config/main.py b/config/main.py index f07d7a7b4b..49b75d932c 100644 --- a/config/main.py +++ b/config/main.py @@ -1830,6 +1830,43 @@ def is_dynamic_buffer_enabled(config_db): device_metadata = config_db.get_entry('DEVICE_METADATA', 'localhost') return 'dynamic' == device_metadata.get('buffer_model') +# +# 'qos scheduler' group ('config qos scheduler ...') +# +@qos.group() +def scheduler(): + """QoS-Scheduler-related configuration tasks""" + pass + +@scheduler.command(name='add') +@click.argument('profile_name', metavar='', required=True) +@click.option('--meter_type', help='Meter type', type=click.Choice(['bytes', 'packets']), default='bytes') +@click.option('--pir', help='Maximum bandwidth rate', type=click.IntRange(1, 50000000000), required=True) +@click.option('--pbs', help='Maximum bandwidth burst', type=click.IntRange(1, 256000000), required=True) +def add(profile_name, meter_type, pir, pbs): + """Add QoS-Scheduler profile.""" + + config_db = ConfigDBConnector() + config_db.connect() + + data = { + 'meter_type': meter_type, + 'pir': pir, + 'pbs': pbs + } + + config_db.set_entry("SCHEDULER", profile_name, data) + +@scheduler.command(name='del') +@click.argument('profile_name', metavar='', required=True) +def delete(profile_name): + """Delete QoS-Scheduler profile.""" + + config_db = ConfigDBConnector() + config_db.connect() + + config_db.set_entry("SCHEDULER", profile_name, None) + # # 'warm_restart' group ('config warm_restart ...') # diff --git a/doc/Command-Reference.md b/doc/Command-Reference.md index 3088b6db61..186fcacd14 100644 --- a/doc/Command-Reference.md +++ b/doc/Command-Reference.md @@ -6107,6 +6107,64 @@ Some of the example QOS configurations that users can modify are given below. When there are no changes in the platform specific configutation files, they internally use the file "/usr/share/sonic/templates/buffers_config.j2" and "/usr/share/sonic/templates/qos_config.j2" to generate the configuration. ``` +**config qos scheduler add** + +This command is used for creating QoS scheduler profile. + +- Usage: + ``` + config qos scheduler add [--meter_type (bytes | packets)] --pir= --pbs= + ``` + +Parameters + +* profile_name: QoS scheduler profile name. + +* meter_type: scheduler meter type. One of: + + * "bytes": metering is done based on bytes. + + * "packets": metering is done based on packets. + + Default: "bytes". + +* pir: shaper maximum bandwidth rate. + + * When meter type is "bytes": + + Unit: Bps(bytes per second). Minimum: "1000" (AS8000 and AS9716-32D: "4000"). Maximum: "50000000000". + + * When meter type is "packets": + + Unit: pps(packets per second). Minimum: "1". Maximum: "50000000000". + +* pbs: shaper maximum bandwidth burst. Unit: bytes if meter type is "bytes", otherwise packets. Minimum: "1". Maximum: "256000000". + +The following example shows how to create a QoS scheduler profile named profile-1. meter_type: bytes. pir: 100000. pbs: 8000. +- Example: + ``` + admin@sonic:~$ sudo config qos scheduler add profile-1 --meter_type=bytes --pbs=100000 --pir=8000 + ``` + +**config qos scheduler del** + +This command is used for removing QoS scheduler profile. + +- Usage: + ``` + config qos scheduler del + ``` + +Parameters + +* profile_name: QoS scheduler profile name. + +The following example shows how to remove a QoS scheduler profile named profile-1. +- Example: + ``` + admin@sonic:~$ sudo config qos scheduler del profile-1 + ``` + Go Back To [Beginning of the document](#) or [Beginning of this section](#qos) ## sFlow