-
Notifications
You must be signed in to change notification settings - Fork 688
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
kdump-Remote-SSH-Configurations #3400
base: master
Are you sure you want to change the base?
kdump-Remote-SSH-Configurations #3400
Conversation
with self.assertRaises(SystemExit) as sys_exit: | ||
sonic_kdump_config.read_ssh_string() | ||
self.assertEqual(sys_exit.exception.code, 1) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No test cases no negative scenarios i.e invalid ssh_key/ssh_path?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handling of valid and invalid SSH keys and paths is already implemented in the utility code. It covers the necessary scenarios, including validation for incorrect SSH keys or paths
mock_read_ssh_string.return_value = 'user@ip_address' # Simulate reading existing SSH string | ||
|
||
# Call the function to test | ||
sonic_kdump_config.write_ssh_string('user@ip_address') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
user@ip_address ? can we test with actual valid values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handling of valid and invalid SSH keys and paths is already implemented in the utility code. It covers the necessary scenarios, including validation for incorrect SSH keys or paths
"""Tests the function `read_ssh_path(...)` in script `sonic-kdump-config`.""" | ||
|
||
# Test successful case with valid SSH path | ||
mock_run_cmd.return_value = (0, ['/path/to/keys'], None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/path/to/keys ? can we test with actual valid values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The handling of valid and invalid SSH keys and paths is already implemented in the utility code. It covers the necessary scenarios, including validation for incorrect SSH keys or paths
Hi @qiluo-msft , please review to merge this PR |
Hi @qiluo-msft / @lguohan PR has been reviewed by the reviewer with all checks passed, please help merge this. |
@qiluo-msft help merge this PR, pending for long |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@qiluo-msft this PR has been approved by reviewers and can you please help to check if you are ok to merge? Thanks. |
@qiluo-msft this PR has been approved by reviewers and can you please help to merge? Thanks. |
@qiluo-msft this PR has been approved by reviewers and can you please help to merge? Thanks. |
|
||
def write_ssh_string(ssh_string): | ||
ssh_string = ssh_string.replace('/', '\/') # Escape any slashes in the SSH string | ||
cmd = "/bin/sed -i -e 's/#*SSH=.*/SSH=\"%s\"/' %s" % (ssh_string, kdump_cfg) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is command inject risk. @maipbui to review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maipbui Hi, Can you please look into this and help us? Thanks
What I did
Added remote kdump functionality using SSH in SONiC.
How I did it
I added two new commands and two options to configure the kdump remote ssh feature.
How to verify it
Upon kernel crash, kdump will transfer the crash report files to the ssh server.