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

Making PDDF 2.0 base classes python3 compliant #6924

Merged
merged 2 commits into from
Mar 1, 2021

Conversation

FuzailBrcm
Copy link
Contributor

@FuzailBrcm FuzailBrcm commented Mar 1, 2021

Why I did it

We need to make the PDDF 2.0 base API implementation python3 compliant

How I did it

  • Made python2 to python3 changes
  • Removed ord() func as python3 return int instead of str
  • Had to change chr(..) to bytes([..]) function while using ctypes class methods

How to verify it

Verified it with a sample AS9716 (TH3) platform which is being using PDDF as in PR (#6902).
Without these changes we were not able to load the PAI 2.0 and getting the following errors.

>>> from sonic_platform.platform import Platform
>>> ch = Platform().get_chassis()
>>> ch.get_sfp(16).get_transceiver_info()
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
Error: Unable to open eeprom_path: ord() expected string of length 1, but int found
{'type': 'Unknown', 'hardware_rev': 'Non-hexadecimal digit found', 'serial': 'Non-hexadecimal digit found', 'manufacturer': 'Non-hexadecimal digit found', 'model': 'Non-hexadecimal digit found', 'connector': 'Unknown', 'encoding': 'Unknown', 'ext_identifier': 'Unknown', 'ext_rateselect_compliance': 'Unknown', 'cable_type': 'Length Cable Assembly(m)', 'cable_length': '0', 'nominal_bit_rate': '0', 'specification_compliance': '{}', 'vendor_date': '20No-n--he xa', 'vendor_oui': '0x00-0x00-0x00', 'application_advertisement': 'N/A', 'type_abbrv_name': 'Unknown'}
>>>

After the fix,

>>> ch.get_sfp(16).get_transceiver_info()
{'type': 'QSFP+ or later', 'hardware_rev': 'A', 'serial': 'ES8077F', 'manufacturer': 'FINISAR CORP', 'model': 'FTL410QE2C', 'connector': 'MPOx12', 'encoding': '64B66B', 'ext_identifier': 'Power Class 1(1.5W max), CLEI present', 'ext_rateselect_compliance': 'QSFP+ Rate Select Version 1', 'cable_type': 'Length Cable Assembly(m)', 'cable_length': '0', 'nominal_bit_rate': '103', 'specification_compliance': "{'10/40G Ethernet Compliance Code': '40GBASE-SR4', 'Fibre Channel link length/Transmitter Technology': 'Short distance (S)', 'Fibre Channel transmission media': 'Shielded Twisted Pair (TP)'}", 'vendor_date': '2014-09-02 ', 'vendor_oui': '00-90-65', 'application_advertisement': 'N/A', 'type_abbrv_name': 'QSFP+'}
>>>
>>>
root@sonic:/home/admin# decode-syseeprom
TlvInfo Header:
   Id String:    TlvInfo
   Version:      1
   Total Length: 169
TLV Name             Code Len Value
-------------------- ---- --- -----
Manufacture Date     0x25  19 04/29/2019 16:38:12
Label Revision       0x27   4 R0BA
Platform Name        0x28  27 x86_64-accton_as9716_32D-r0
ONIE Version         0x29  13 2018.08.00.03
Manufacturer         0x2B   6 Accton
Manufacture Country  0x2C   2 TW
Diag Version         0x2E   8 0.2.0.14
Base MAC Address     0x24   6 80:A2:35:5A:12:50
Serial Number        0x23  14 971632D1913010
Part Number          0x22  13 FP5ZZ8632006A
Product Name         0x21  15 9716-32D-O-AC-F
MAC Addresses        0x2A   2 256
Vendor Name          0x2D   8 Edgecore
CRC-32               0xFE   4 0x4E80417A
(checksum valid)
root@sonic:/home/admin#
root@sonic:/home/admin# pddf_psuutil mfrinfo
PSU1 is Not OK

PSU2 is OK
Manufacture Id: 3Y POWER
Model: YESM1300AM
Serial Number: S0A000X601825000090
Fan Direction: Intake

root@sonic:/home/admin# pddf_psuutil seninfo
PSU1 is Not OK

PSU2 is OK
Output Voltage: 12041.0 mv
Output Current: 19906.0 ma
Output Power: 238000.0 mw
Fan1 Speed: 13600 rpm

root@sonic:/home/admin# pddf_fanutil getspeed
FAN           SPEED (RPM)
----------  -------------
Fantray1_1           5800
Fantray1_2           6000
Fantray2_1           5800
Fantray2_2           5900
Fantray3_1           5700
Fantray3_2           5800
Fantray4_1           5700
Fantray4_2           5800
Fantray5_1           5900
Fantray5_2           5900
Fantray6_1           5800
Fantray6_2           5900
root@sonic:/home/admin# pddf_thermalutil gettemp
Temp Sensor    Label           Value
-------------  --------------  -------------------------------
Temp_1         lm75-i2c-49-48  temp1	 +27.0 C (high = +80.0 C)
Temp_2         lm75-i2c-49-49  temp1	 +29.5 C (high = +80.0 C)
Temp_3         lm75-i2c-49-4a  temp1	 +27.5 C (high = +80.0 C)
Temp_4         lm75-i2c-49-4b  temp1	 +26.5 C (high = +80.0 C)
Temp_5         lm75-i2c-49-4c  temp1	 +30.5 C (high = +80.0 C)
Temp_6         lm75-i2c-49-4e  temp1	 +27.0 C (high = +80.0 C)
Temp_7         lm75-i2c-49-4f  temp1	 +30.5 C (high = +80.0 C)
root@sonic:/home/admin#
root@sonic:/home/admin#

Which release branch to backport (provide reason below if selected)

  • 201811
  • 201911
  • 202006
  • 202012

Description for the changelog

Related to the PR (#6902)

A picture of a cute animal (not mandatory but encouraged)

@FuzailBrcm FuzailBrcm requested a review from lguohan as a code owner March 1, 2021 07:57
@ben-gale
Copy link
Collaborator

ben-gale commented Mar 1, 2021

@lguohan and review team - please look at this at the earliest - we are working with Accton on a platform contribution that has a dependency upon this PR - thanks.

@jleveque jleveque merged commit 20f0f06 into sonic-net:master Mar 1, 2021
@ben-gale
Copy link
Collaborator

ben-gale commented Mar 1, 2021

Thanks Joe!

carl-nokia pushed a commit to carl-nokia/sonic-buildimage that referenced this pull request Aug 7, 2021
- Made python2 to python3 changes
- Removed ord() func as python3 return int instead of str
- Had to change chr(..) to bytes([..]) function while using ctypes class methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants