Skip to content

Conversation

@auspham
Copy link
Contributor

@auspham auspham commented Nov 26, 2025

Description of PR

Summary: Add Cli to support L1 connect from pipeline/elastictest
Fixes # (issue) 36011538

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • New Test case
    • Skipped for non-supported platforms
  • Test case improvement

Back port request

  • 202205
  • 202305
  • 202311
  • 202405
  • 202411
  • 202505

Approach

What is the motivation for this PR?

usage: sonic_l1_cli.py [-h] {connect,read} ...

Sonic-mgmt utility command-line to connect ports and read ports from SONiC L1 device.

positional arguments:
  {connect,read}
    connect       Connect to device.
    read          Read from device.

optional arguments:
  -h, --help      show this help message and exit

Usecases:

1. Connect port
../.azure-pipelines/sonic_l1_cli.py connect --device l1_device --port "1,41" -i inventory

This will do the following connection:
    Connect single port
        1A -> 41B
        41A -> 1B

2. Connect port in a combined port group
../.azure-pipelines/sonic_l1_cli.py connect --device l1_device --port "1|2|3|4,41|42|43|44" -i inventory

This will do the following connection:
    Connect port group:
        1A -> 41B
        41A -> 1B
        ...
        4A -> 44B
        44A -> 4B

3. Connect multiple port
../.azure-pipelines/sonic_l1_cli.py connect --device l1_device --port "1,41" --port "2,42" -i inventory

This will do the following connection:
    Connect single port
        1A -> 41B
        41A -> 1B

        2A -> 42B
        42A -> 2B

4. Read the port connection
../.azure-pipelines/sonic_l1_cli.py read --output output_file --device l1_device -i inventory

This will write to output_file
{
    "port_list": [
        "1,43",
        "2,46",
        "17,45",
        "19,47",
        "20,48",
        "21,49",
        "22,50",
        "23,51",
        "24,52"
    ]
}

If you dont want to output to any file, simply omit --output

How did you do it?

How did you verify/test it?

Physical device

Any platform specific information?

Supported testbed topology if it's a new test case?

Documentation

@auspham auspham marked this pull request as ready for review November 26, 2025 12:12
@auspham auspham requested a review from wangxin as a code owner November 26, 2025 12:12
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@auspham auspham force-pushed the austinpham/36011538-l1-connect branch from de2b258 to 85674ca Compare November 26, 2025 22:45
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@auspham auspham force-pushed the austinpham/36011538-l1-connect branch from 85674ca to 87444f7 Compare December 1, 2025 05:16
@mssonicbld
Copy link
Collaborator

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

elif args.command == "read":
l1_device.read(args.output)
else:
raise ValueError(f"Command '{args.command}' is not a valid command")
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this script is a CLI, it would be better to use sys.exit(<non_zero_value>) when something is wrong.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants