Skip to content

Make SSH session generator support generating session files for all devices, like fanout switches.#12974

Merged
wangxin merged 2 commits intosonic-net:masterfrom
r12f:user/r12f/ssh-gen
May 31, 2024
Merged

Make SSH session generator support generating session files for all devices, like fanout switches.#12974
wangxin merged 2 commits intosonic-net:masterfrom
r12f:user/r12f/ssh-gen

Conversation

@r12f
Copy link
Collaborator

@r12f r12f commented May 24, 2024

Description of PR

Summary:
Currently, the SSH repo generator will only generate the session files for DUT and PTF in testbeds, but not all the other devices, such as fanout switches and servers.

This change is to add this support in it.

Type of change

  • Bug fix
  • Testbed and Framework(new/improvement)
  • Test case(new/improvement)

Back port request

  • 201911
  • 202012
  • 202205
  • 202305
  • 202311

Approach

What is the motivation for this PR?

Currently, the SSH repo generator will only generate the session files for DUT and PTF in testbeds, but not all the other devices, such as fanout switches and servers.

How did you do it?

This change updates the ssh_session_gen.py to parse the device inventory csv files, so we can generate all sessions for it.

How did you verify/test it?

Run it locally, and it outputs the session files as below. Besides the testbeds, now we also outputs the devices folder:

image

Any platform specific information?

No.

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

N/A.

Documentation

No changes on how to use it. N/A.

@mssonicbld
Copy link
Collaborator

The pre-commit check detected issues in the files touched by this pull request.
The pre-commit check is a mandatory check, please fix detected issues.

Detailed pre-commit check results:
trim trailing whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing ansible/devutil/device_inventory.py
Fixing ansible/ssh_session_gen.py

fix end of files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing ansible/devutil/device_inventory.py

check yaml...........................................(no files to check)Skipped
check for added large files..............................................Passed
check python ast.........................................................Passed
flake8...................................................................Failed
- hook id: flake8
...
[truncated extra lines, please run pre-commit locally to view full check results]

To run the pre-commit checks locally, you can follow below steps:

  1. Ensure that default python is python3. In sonic-mgmt docker container, default python is python2. You can run
    the check by activating the python3 virtual environment in sonic-mgmt docker container or outside of sonic-mgmt
    docker container.
  2. Ensure that the pre-commit package is installed:
sudo pip install pre-commit
  1. Go to repository root folder
  2. Install the pre-commit hooks:
pre-commit install
  1. Use pre-commit to check staged file:
pre-commit
  1. Alternatively, you can check committed files using:
pre-commit run --from-ref <commit_id> --to-ref <commit_id>

@r12f r12f force-pushed the user/r12f/ssh-gen branch from 4965d10 to 67c7da6 Compare May 24, 2024 04:09
@wangxin wangxin merged commit 37579a9 into sonic-net:master May 31, 2024
mrkcmo pushed a commit to Azarack/sonic-mgmt that referenced this pull request Jul 17, 2024
…evices, like fanout switches. (sonic-net#12974)

What is the motivation for this PR?
Currently, the SSH repo generator will only generate the session files for DUT and PTF in testbeds, but not all the other devices, such as fanout switches and servers.

How did you do it?
This change updates the ssh_session_gen.py to parse the device inventory csv files, so we can generate all sessions for it.

How did you verify/test it?
Run it locally, and it outputs the session files as below. Besides the testbeds, now we also outputs the devices folder:
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