Skip to content
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

[xcvrd] Add enum dependence back; Install 'enum34' conditionally based on Python version #107

Merged
merged 3 commits into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 8 additions & 15 deletions sonic-xcvrd/scripts/xcvrd
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ try:
import threading
import time

from enum import Enum
from sonic_py_common import daemon_base, device_info, logger
from sonic_py_common import multi_asic
from swsscommon import swsscommon
Expand Down Expand Up @@ -45,21 +46,13 @@ XCVRD_MAIN_THREAD_SLEEP_SECS = 60
SFP_STATUS_REMOVED = '0'
SFP_STATUS_INSERTED = '1'

# SFP error codes, stored as strings. Can add more as needed.
SFP_STATUS_ERR_I2C_STUCK = '2'
SFP_STATUS_ERR_BAD_EEPROM = '3'
SFP_STATUS_ERR_UNSUPPORTED_CABLE = '4'
SFP_STATUS_ERR_HIGH_TEMP = '5'
SFP_STATUS_ERR_BAD_CABLE = '6'

# Store the error codes in a set for convenience
errors_block_eeprom_reading = {
SFP_STATUS_ERR_I2C_STUCK,
SFP_STATUS_ERR_BAD_EEPROM,
SFP_STATUS_ERR_UNSUPPORTED_CABLE,
SFP_STATUS_ERR_HIGH_TEMP,
SFP_STATUS_ERR_BAD_CABLE
}
# SFP error code enum, new elements can be added to the enum if new errors need to be supported.
SFP_STATUS_ERR_ENUM = Enum('SFP_STATUS_ERR_ENUM', ['SFP_STATUS_ERR_I2C_STUCK', 'SFP_STATUS_ERR_BAD_EEPROM',
'SFP_STATUS_ERR_UNSUPPORTED_CABLE', 'SFP_STATUS_ERR_HIGH_TEMP',
'SFP_STATUS_ERR_BAD_CABLE'], start=2)

# Convert the error code to string and store them in a set for convenience
errors_block_eeprom_reading = set(str(error_code.value) for error_code in SFP_STATUS_ERR_ENUM)

EVENT_ON_ALL_SFP = '-1'
# events definition
Expand Down
1 change: 1 addition & 0 deletions sonic-xcvrd/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
],
install_requires = [
# NOTE: This package also requires swsscommon, but it is not currently installed as a wheel
'enum34; python_version < "3.4"',
'sonic-py-common',
],
setup_requires = [
Expand Down