-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[syseepromd] Support both new platform API and old platform plugins #36
[syseepromd] Support both new platform API and old platform plugins #36
Conversation
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.
After thinking about this more, I think we can make this change even smaller. Because no matter which API gets loaded (the new API or the old plugin), the resulting object is handled the same way. Do you see any reason why we can't do the following:
- Remove
eeprom_util
,load_eeprom_util()
,load_platform_api()
and all_wrapper_*()
functions completely. - Replace lines 136-140 with something like the following:
# First, try to load the new platform API
try:
import sonic_platform
self.chassis = sonic_platform.platform.Platform().get_chassis()
self.eeprom = self.chassis.get_eeprom()
except Exception as e:
logger.log_warning("Failed to load platform-specific eeprom from sonic_platform package due to {}".format(repr(e)))
finally:
# If we didn't successfully load the class from the sonic_platform package, try loading the old plugin
if not self.eeprom:
try:
self.eeprom = self.load_platform_util(PLATFORM_SPECIFIC_MODULE_NAME, PLATFORM_SPECIFIC_CLASS_NAME)
except Exception as e:
logger.log_error("Failed to load platform-specific eeprom implementation: %s" % (str(e)), True)
if not self.eeprom:
sys.exit(ERR_EEPROMUTIL_LOAD)
Then all the functions can simply reference self.eeprom
. Will this work or am I missing something?
Hi Joe,
Can it be well handled if another exception thrown from the finally block? I’m not sure whether it’s a good style. Other thing seems good to me.
BTW, psud can also be updated in this way.
But for xcvrd, it is a little complicated, because the sfputil has to be remained even new platform api supported. I’ve mentioned that in another PR #38
|
The finally block is a bit of a messy approach, I agree. Instead, you should be able to simply check for None:
Great to know psud should be able to use the same approach. I assumed xcvrd would require a different solution. |
Eepromd works in this way.
But I don’t think we should remove the _wrapper_* functions if we want to have a per-API level compat.
PSU doesn’t work in this way, since the it requires both chassis and psu object, unlike eeprom which requires eeprom object only.
The root cause is that,
1. there can be more than one PSUs in a switch so we have both APIs to access PSU information on a global scope, like get_num_psus which is provided by chassis, and APIs to access each PSU, like get_psu_presence provided by psu class.
2. there is only one eeprom in a switch and it doesn’t require any “global” scope APIs.
|
Understood. So do you want to make any changes to this PR after all? |
Sure. I'm testing the syseepromd. |
Hi Joe, syseepromd has been updated. Please review. Thank you. |
[sonic-platform-common] [sonic_sfp] Interpret sff 'int' element =0 as valid value (sonic-net/sonic-platform-common#51) add more error code to get_transceiver_change_event ((sonic-net/sonic-platform-common#50) [sonic_platform_base] support new-platform-api-based daemons ((sonic-net/sonic-platform-common#48) sync change to sonic_platform_base/sonic_sfp and create symbol link ((sonic-net/sonic-platform-common#49) Add parser support for Tx_RxLos,TxFault, PowerControl, ResetStatus in sff8436.py ((sonic-net/sonic-platform-common#45) readd type_abbrv_name in sonic_sfp/sff8436.py ((sonic-net/sonic-platform-common#44) [psu_base] get_status_led() returns current state of the status LED ((sonic-net/sonic-platform-common#39) Fix abbrv name for OSFP ((sonic-net/sonic-platform-common#36) [sff8436] support "Control Bytes" and "Options" ((sonic-net/sonic-platform-common#38) sonic_sfp: avoid possible key error in get_physical_to_logical() ((sonic-net/sonic-platform-common#37) [sonic-platform-daemons] [xcvrd] Enhance xcvrd to handle new system level event/error (sonic-net/sonic-platform-daemons#39) [xcvrd] Support both new platform API and old platform plugins (sonic-net/sonic-platform-daemons#38) [psud] Support both new platform API and old platform plugins (sonic-net/sonic-platform-daemons#37) [syseepromd] Support both new platform API and old platform plugins (sonic-net/sonic-platform-daemons#36) Add missing import statemet (sonic-net/sonic-platform-daemons#32) sonic_xcvrd: Support for DOM Threshold values for EEPROM dump (sonic-net/sonic-platform-daemons#29)
…ic-net#3333) [sonic-platform-common] [sonic_sfp] Interpret sff 'int' element =0 as valid value (sonic-net/sonic-platform-common#51) add more error code to get_transceiver_change_event ((sonic-net/sonic-platform-common#50) [sonic_platform_base] support new-platform-api-based daemons ((sonic-net/sonic-platform-common#48) sync change to sonic_platform_base/sonic_sfp and create symbol link ((sonic-net/sonic-platform-common#49) Add parser support for Tx_RxLos,TxFault, PowerControl, ResetStatus in sff8436.py ((sonic-net/sonic-platform-common#45) readd type_abbrv_name in sonic_sfp/sff8436.py ((sonic-net/sonic-platform-common#44) [psu_base] get_status_led() returns current state of the status LED ((sonic-net/sonic-platform-common#39) Fix abbrv name for OSFP ((sonic-net/sonic-platform-common#36) [sff8436] support "Control Bytes" and "Options" ((sonic-net/sonic-platform-common#38) sonic_sfp: avoid possible key error in get_physical_to_logical() ((sonic-net/sonic-platform-common#37) [sonic-platform-daemons] [xcvrd] Enhance xcvrd to handle new system level event/error (sonic-net/sonic-platform-daemons#39) [xcvrd] Support both new platform API and old platform plugins (sonic-net/sonic-platform-daemons#38) [psud] Support both new platform API and old platform plugins (sonic-net/sonic-platform-daemons#37) [syseepromd] Support both new platform API and old platform plugins (sonic-net/sonic-platform-daemons#36) Add missing import statemet (sonic-net/sonic-platform-daemons#32) sonic_xcvrd: Support for DOM Threshold values for EEPROM dump (sonic-net/sonic-platform-daemons#29)
There was a problem with the abbreviated type name fetching if the xcvr was OSFP. This commit fixes the issue.
Support new platform api with plugin mode compatible.
In this PR, new platform api is supported in following steps:
now only two APIs are called in syseepromd, update_eeprom_db and read_eeprom.
it depends on the sonic-platform-common #48 add get_eeprom to Chassis for syseepromd to access