-
Couldn't load subscription status.
- Fork 192
[psud] Refactor PSU object retrieval to improve exception handling #659
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
cf713d9
6063a6e
188652c
455572d
048fc91
bf4dede
cf7161e
5bdf678
2fcc059
9a11b05
3995d5f
98bee9b
a7e21b5
8a52b30
508d208
0a37102
23efbcf
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 |
|---|---|---|
|
|
@@ -99,19 +99,40 @@ def _wrapper_get_num_psus(): | |
| return platform_psuutil.get_num_psus() | ||
|
|
||
|
|
||
| def _wrapper_get_psu(psu_index): | ||
| """ | ||
| Get PSU object from platform chassis | ||
| :param psu_index: PSU index (1-based) | ||
| :return: PSU object if available, None otherwise | ||
| """ | ||
| if platform_chassis is not None: | ||
| try: | ||
| return platform_chassis.get_psu(psu_index - 1) | ||
| except NotImplementedError: # TODO: Is NotImplementedError sufficient? | ||
|
||
| pass # TODO: When caught, what should we do here? | ||
| # TODO: If platform_chassis is None, should we return None or add logging and return None? | ||
| return None | ||
|
|
||
|
|
||
| def _wrapper_get_psu_presence(psu_index): | ||
| if platform_chassis is not None: | ||
| psu = _wrapper_get_psu(psu_index) | ||
| if not psu: | ||
|
||
| return False # TODO: What should we do when PSU object is not available? | ||
| try: | ||
| return platform_chassis.get_psu(psu_index - 1).get_presence() | ||
| return psu.get_presence() | ||
| except NotImplementedError: | ||
| pass | ||
| return platform_psuutil.get_psu_presence(psu_index) | ||
|
|
||
|
|
||
| def _wrapper_get_psu_status(psu_index): | ||
| if platform_chassis is not None: | ||
| psu = _wrapper_get_psu(psu_index) | ||
| if not psu: | ||
| return False # TODO: What should we do when PSU object is not available? | ||
| try: | ||
| return platform_chassis.get_psu(psu_index - 1).get_powergood_status() | ||
| return psu.get_powergood_status() | ||
| except NotImplementedError: | ||
| pass | ||
| return platform_psuutil.get_psu_status(psu_index) | ||
|
|
@@ -123,8 +144,11 @@ def _wrapper_get_psu_status(psu_index): | |
|
|
||
| def get_psu_key(psu_index): | ||
| if platform_chassis is not None: | ||
| psu = _wrapper_get_psu(psu_index) | ||
| if not psu: | ||
| return "" # TODO: What should we do when PSU object is not available? | ||
| try: | ||
| return platform_chassis.get_psu(psu_index - 1).get_name() | ||
| return psu.get_name() | ||
| except NotImplementedError: | ||
| pass | ||
| except IndexError: | ||
|
|
||
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 docstring is missing the logger parameter description. Add ':param logger: Logger instance for error/warning messages' to document the logger parameter.
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.
@LinJin23 Pls fix this.
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.
done