-
Notifications
You must be signed in to change notification settings - Fork 48
JIRA-ONSBUSWI-3489:[Modify] Add a flag to control the tolerance when thermal policy changes the speed #662
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ | |||||||||||||||||||||||||||||
| from sonic_py_common.general import getstatusoutput_noshell | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| HOST_CHK_CMD = ["docker"] | ||||||||||||||||||||||||||||||
| MACHINE_CONF_FILE = "/host/machine.conf" | ||||||||||||||||||||||||||||||
| EMPTY_STRING = "" | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
@@ -107,6 +108,16 @@ def ipmi_set_ss_thres(self, id, threshold_key, value): | |||||||||||||||||||||||||||||
| status = False | ||||||||||||||||||||||||||||||
| return status, result | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| def get_platform(self): | ||||||||||||||||||||||||||||||
| platform = None | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| with open(MACHINE_CONF_FILE, 'r') as file: | ||||||||||||||||||||||||||||||
| for line in file: | ||||||||||||||||||||||||||||||
| if 'onie_platform=' in line: | ||||||||||||||||||||||||||||||
| platform = line.strip().split('=')[1] | ||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||
|
Comment on lines
+114
to
+118
|
||||||||||||||||||||||||||||||
| with open(MACHINE_CONF_FILE, 'r') as file: | |
| for line in file: | |
| if 'onie_platform=' in line: | |
| platform = line.strip().split('=')[1] | |
| break | |
| try: | |
| with open(MACHINE_CONF_FILE, 'r') as file: | |
| for line in file: | |
| if 'onie_platform=' in line: | |
| platform = line.strip().split('=')[1] | |
| break | |
| except (OSError, IOError): | |
| # If the machine configuration file cannot be read, return None | |
| platform = None |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |||||||||||||||||||||||||||||||
| from sonic_py_common.general import getstatusoutput_noshell | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| HOST_CHK_CMD = ["docker"] | ||||||||||||||||||||||||||||||||
| MACHINE_CONF_FILE = "/host/machine.conf" | ||||||||||||||||||||||||||||||||
| EMPTY_STRING = "" | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
|
|
@@ -50,3 +51,13 @@ def write_txt_file(self, file_path, value): | |||||||||||||||||||||||||||||||
| return False | ||||||||||||||||||||||||||||||||
| return True | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| def get_platform(self): | ||||||||||||||||||||||||||||||||
| platform = None | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| with open(MACHINE_CONF_FILE, 'r') as file: | ||||||||||||||||||||||||||||||||
| for line in file: | ||||||||||||||||||||||||||||||||
| if 'onie_platform=' in line: | ||||||||||||||||||||||||||||||||
| platform = line.strip().split('=')[1] | ||||||||||||||||||||||||||||||||
| break | ||||||||||||||||||||||||||||||||
|
Comment on lines
+57
to
+61
|
||||||||||||||||||||||||||||||||
| with open(MACHINE_CONF_FILE, 'r') as file: | |
| for line in file: | |
| if 'onie_platform=' in line: | |
| platform = line.strip().split('=')[1] | |
| break | |
| try: | |
| with open(MACHINE_CONF_FILE, 'r') as file: | |
| for line in file: | |
| if 'onie_platform=' in line: | |
| platform = line.strip().split('=')[1] | |
| break | |
| except (IOError, OSError): | |
| # If the machine configuration file cannot be opened or read, | |
| # return None to avoid raising an unhandled exception. | |
| return 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.
The get_platform method does not handle the case where the MACHINE_CONF_FILE cannot be opened or does not exist. This will cause an unhandled exception when the file is missing or inaccessible, potentially crashing the fan monitoring service.