Skip to content

Commit 9b90ee7

Browse files
justindthomasyanjundeng
authored andcommitted
eliminate dmidecode because it requires root privileges (sonic-net#17509)
Why I did it As described in sonic-net#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 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:
1 parent 884f3cd commit 9b90ee7

File tree

1 file changed

+1
-1
lines changed
  • platform/broadcom/sonic-platform-modules-dell/n3248te/sonic_platform

1 file changed

+1
-1
lines changed

platform/broadcom/sonic-platform-modules-dell/n3248te/sonic_platform/component.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
except ImportError as e:
1717
raise ImportError(str(e) + "- required module not found")
1818
def get_bios_version():
19-
return subprocess.check_output(['dmidecode', '-s', 'system-version']).strip().decode()
19+
return subprocess.check_output(['cat', '/sys/class/dmi/id/bios_version']).strip().decode()
2020

2121
def get_cpld_version(cpld):
2222
mjr_ver_path = '/sys/devices/platform/dell-n3248te-cpld.0/' + cpld + '_mjr_ver'

0 commit comments

Comments
 (0)