Skip to content

Pr json support queue watermark and persistent-watermark #3875

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

vikumarks
Copy link

What I did

Added json output supoort for

admin@sonic:~$ show queue watermark unicast --help
Usage: show queue watermark unicast [OPTIONS]

  Show user WM for unicast queues

Options:
  -j, --json      Display1 output in JSON format  [default: False]
  -?, -h, --help  Show this message and exit.
admin@sonic:~$ show queue watermark multicast --help
Usage: show queue watermark multicast [OPTIONS]

  Show user WM for multicast queues

Options:
  -j, --json      Display1 output in JSON format  [default: False]
  -?, -h, --help  Show this message and exit.

How I did it

How to verify it

admin@sonic:~$ show queue watermark multicast
Egress shared pool occupancy per multicast queue:
       Port    MC10    MC11    MC12    MC13    MC14    MC15    MC16    MC17    MC18    MC19
-----------  ------  ------  ------  ------  ------  ------  ------  ------  ------  ------
  Ethernet0       0       0       0       0       0       0       0       0       0       0
  Ethernet4       0       0       0       0       0       0       0       0       0       0
  Ethernet8       0       0       0       0       0       0       0       0       0       0
 Ethernet12       0       0       0       0       0       0       0       0       0       0
 Ethernet16       0       0       0       0       0       0       0       0       0       0
 Ethernet20       0       0       0       0       0       0       0       0       0       0
 Ethernet24       0       0       0       0       0       0       0       0       0       0
 Ethernet28       0       0       0       0       0       0       0       0       0       0
 Ethernet32       0       0       0       0       0       0       0       0       0       0
 Ethernet36       0       0       0       0       0       0       0       0       0       0
 Ethernet40       0       0       0       0       0       0       0       0       0       0
 Ethernet44       0       0       0       0       0       0       0       0       0       0
 Ethernet48       0       0       0       0       0       0       0       0       0       0
 Ethernet52       0       0       0       0       0       0       0       0       0       0
 Ethernet56       0       0       0       0       0       0       0       0       0       0
 Ethernet60       0       0       0       0       0       0       0       0       0       0
 Ethernet64       0       0       0       0       0       0       0       0       0       0
 Ethernet68       0       0       0       0       0       0       0       0       0       0
 Ethernet72    1536       0       0       0       0       0       0       0       0       0
 Ethernet76     256       0       0       0       0       0       0       0       0       0
 Ethernet80       0       0       0       0       0       0       0       0       0       0
 Ethernet84       0       0       0       0       0       0       0       0       0       0
 Ethernet88       0       0       0       0       0       0       0       0       0       0
 Ethernet92       0       0       0       0       0       0       0       0       0       0
 Ethernet96       0       0       0       0       0       0       0       0       0       0
Ethernet100       0       0       0       0       0       0       0       0       0       0
Ethernet104       0       0       0       0       0       0       0       0       0       0
Ethernet108       0       0       0       0       0       0       0       0       0       0
Ethernet112       0       0       0       0       0       0       0       0       0       0
Ethernet116       0       0       0       0       0       0       0       0       0       0
Ethernet120       0       0       0       0       0       0       0       0       0       0
Ethernet124       0       0       0       0       0       0       0       0       0       0

admin@sonic:~$ show queue watermark multicast --json
Egress shared pool occupancy per multicast queue:
[
    {
        "Port": "Ethernet0",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet4",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet8",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet12",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet16",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet20",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet24",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet28",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet32",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet36",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet40",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet44",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet48",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet52",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet56",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet60",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet64",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet68",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet72",
        "MC10": "1536",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet76",
        "MC10": "256",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet80",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet84",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet88",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet92",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet96",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet100",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet104",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet108",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet112",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet116",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet120",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    },
    {
        "Port": "Ethernet124",
        "MC10": "0",
        "MC11": "0",
        "MC12": "0",
        "MC13": "0",
        "MC14": "0",
        "MC15": "0",
        "MC16": "0",
        "MC17": "0",
        "MC18": "0",
        "MC19": "0"
    }
]
admin@sonic:~$

Previous command output (if the output of a command-line utility has changed)

New command output (if the output of a command-line utility has changed)

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@r12f r12f requested a review from vvolam May 8, 2025 20:53
@vvolam vvolam requested a review from Copilot May 8, 2025 21:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds JSON output support for queue watermark and persistent-watermark commands, allowing users to view the output in JSON format via a new command-line flag.

  • Added a new click option (--json/-j) in the unicast, multicast, and all queues commands.
  • Updated the watermarkstat script and related methods to support JSON output.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
show/main.py Added a JSON flag to queue watermark CLI subcommands
scripts/watermarkstat Modified command execution and output formatting to support JSON output

show/main.py Outdated
@@ -826,11 +826,14 @@ def watermark():
show_default=True,
help='Namespace name or all',
callback=multi_asic_util.multi_asic_namespace_validation_callback)
def wm_q_uni(namespace):
@click.option('--json','-j','json_output', is_flag=True, default=False, show_default=True, help="Display JSON output")
Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a consistent help message for the JSON flag across all commands. For example, aligning with other modules by using 'Display JSON output' uniformly.

Copilot uses AI. Check for mistakes.

@@ -324,8 +330,9 @@ class Watermarkstat(object):
@click.option('-p', '--persistent', is_flag=True, help='Do the operations on the persistent watermark')
@click.option('-t', '--type', 'wm_type', type=click.Choice(['pg_headroom', 'pg_shared', 'q_shared_uni', 'q_shared_multi', 'buffer_pool', 'headroom_pool', 'q_shared_all']), help='The type of watermark', required=True)
@click.option('-n', '--namespace', type=click.Choice(multi_asic.get_namespace_list()), help='Namespace name or skip for all', default=None)
@click.option('--json','-j','json_output', is_flag=True, default=False, show_default=True, help="Display output in JSON format")
Copy link
Preview

Copilot AI May 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider using a consistent help message for the JSON flag across all commands. For example, align this with the 'Display JSON output' help text used elsewhere.

Suggested change
@click.option('--json','-j','json_output', is_flag=True, default=False, show_default=True, help="Display output in JSON format")
@click.option('--json','-j','json_output', is_flag=True, default=False, show_default=True, help="Display JSON output")

Copilot uses AI. Check for mistakes.

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@mssonicbld
Copy link
Collaborator

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

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

Successfully merging this pull request may close these issues.

3 participants