sonic-buildimage
sonic-buildimage copied to clipboard
eliminate dmidecode in component.py because it requires root privileges
Why I did it
As described in https://github.com/sonic-net/sonic-buildimage/issues/16878, every show command on the N3248TE-ON results in an error about dmidecode not being found. This is because that command is called in the get_bios_version function of component.py, which is used in a lot of places (many which should not require privileged access).
The error message prior to this change:
jdt@sonic:~$ show system-health
failed to import plugin show.plugins.cisco-8000: [Errno 2] No such file or directory: 'dmidecode'
Usage: show system-health [OPTIONS] COMMAND [ARGS]...
Show system-health information
Work item tracking
- Microsoft ADO (number only):
How I did it
On this platform, at least, the BIOS version can be obtained from /sys/class/dmi/id/bios_versionwithout requiring root privileges. I adjusted component.py to use that instead of dmidecode.
How to verify it
With that change in place, you can see that commands no longer complain about dmidecode:
jdt@sonic:~$ show system-health
Usage: show system-health [OPTIONS] COMMAND [ARGS]...
Show system-health information
Options:
-?, -h, --help Show this message and exit.
Commands:
detail Show system-health detail information
monitor-list Show system-health monitored services and devices name...
summary Show system-health summary information
sysready-status Show system-health system ready status
- [ ] 201811
- [ ] 201911
- [ ] 202006
- [ ] 202012
- [ ] 202106
- [ ] 202111
- [ ] 202205
- [ ] 202211
- [ ] 202305
Tested branch (Please provide the tested image version)
master
Description for the changelog
Removed call to dmidecode for every component command on the N3248TE-ON platform.
@jeff-yin flagging this one too for review by someone at Dell.
@justindthomas please assign @arunlk-dell and @vpsubramaniam as reviewers too, thanks!
Is there a meeting I need to attend or something to get things like this merged? This seems like a pretty trivial change, but has a significantly positive usability impact (i.e., operations that shouldn't require privileges no longer error out).
I have 4 PRs that have been sitting for months with some reviews, but apparently not enough. How do I move these forward?
@jeff-yin
@zhangyanzhao @lguohan -- these changes have been approved by Dell staff. Can someone merge?
@yxieca can you please help to check this PR to see if we can merge it? Thanks.
@yxieca can you please help to check this PR to see if we can merge it? Thanks.
I think it is okay, @prgeor can you take a quick look?
/Semgrep