[Nokia ixs7215] Platform API 2.0 improvements (#6787)

- Improve sonic-mgmt platform test suite pass rate
- Improve coverage of platform unit tests
- Provide platform specific reboot logic as per platform porting guide
- Fix bug due to pcie.yaml file being located in the wrong directory
This commit is contained in:
dflynn-Nokia 2021-02-23 12:25:14 -05:00 committed by GitHub
parent f77157f09d
commit cbe7493b8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 308 additions and 168 deletions

View File

@ -0,0 +1,11 @@
#!/bin/bash
function SafePwrCycle() {
sync ; sync
umount -fa > /dev/null 2&>1
# Write CPLD register to initiate cold reboot
sudo i2cset -f -y 0 0x41 0x10 0x00
}
SafePwrCycle

View File

@ -51,7 +51,7 @@ chmod 644 /sys/class/i2c-adapter/i2c-0/0-0053/eeprom
echo eeprom 0x55 > /sys/class/i2c-adapter/i2c-0/new_device echo eeprom 0x55 > /sys/class/i2c-adapter/i2c-0/new_device
echo eeprom 0x56 > /sys/class/i2c-adapter/i2c-0/new_device echo eeprom 0x56 > /sys/class/i2c-adapter/i2c-0/new_device
# Enumerate psu eeprom devices # Enumerate PSU eeprom devices
echo eeprom 0x51 > /sys/class/i2c-adapter/i2c-1/new_device echo eeprom 0x51 > /sys/class/i2c-adapter/i2c-1/new_device
echo eeprom 0x52 > /sys/class/i2c-adapter/i2c-1/new_device echo eeprom 0x52 > /sys/class/i2c-adapter/i2c-1/new_device

View File

@ -1,2 +1,4 @@
__all__ = ["platform", "chassis"]
from sonic_platform import *

View File

@ -159,6 +159,14 @@ class Chassis(ChassisBase):
""" """
return self._eeprom.part_number_str() return self._eeprom.part_number_str()
def get_service_tag(self):
"""
Retrieves the Service Tag of the chassis
Returns:
string: Service Tag of chassis
"""
return self._eeprom.service_tag_str()
def get_status(self): def get_status(self):
""" """
Retrieves the operational status of the chassis Retrieves the operational status of the chassis
@ -367,7 +375,7 @@ class Chassis(ChassisBase):
sonic_logger.log_warning(" Fail to load watchdog {}".format(repr(e))) sonic_logger.log_warning(" Fail to load watchdog {}".format(repr(e)))
return self._watchdog return self._watchdog
def get_position_in_parent(self): def get_position_in_parent(self):
""" """
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position

View File

@ -16,6 +16,7 @@ try:
except ImportError as e: except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
smbus_present = 1
try: try:
import smbus import smbus
except ImportError as e: except ImportError as e:
@ -34,6 +35,7 @@ class Component(ComponentBase):
["System-CPLD", "Used for managing SFPs, LEDs, PSUs and FANs "], ["System-CPLD", "Used for managing SFPs, LEDs, PSUs and FANs "],
["U-Boot", "Performs initialization during booting"], ["U-Boot", "Performs initialization during booting"],
] ]
CPLD_UPDATE_COMMAND = 'cp /usr/sbin/vme /tmp; cp {} /tmp; cd /tmp; ./vme {};'
def __init__(self, component_index): def __init__(self, component_index):
self.index = component_index self.index = component_index
@ -55,12 +57,12 @@ class Component(ComponentBase):
def _get_cpld_version(self, cpld_number): def _get_cpld_version(self, cpld_number):
if smbus_present == 0: if smbus_present == 0:
cmdstatus, cpld_version = cmd.getstatusoutput('i2cget -y 0 0x41 0x2') cmdstatus, cpld_version = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x2')
else: else:
bus = smbus.SMBus(0) bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41 DEVICE_ADDRESS = 0x41
DEVICE_REG = 0x2 DEVICE_REG = 0x2
cpld_version = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG) cpld_version = str(bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG))
return str(int(cpld_version, 16)) return str(int(cpld_version, 16))
@ -93,7 +95,7 @@ class Component(ComponentBase):
return self._get_cpld_version(self.index) return self._get_cpld_version(self.index)
if self.index == 1: if self.index == 1:
cmdstatus, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -1 | cut -c 1-30') cmdstatus, uboot_version = cmd.getstatusoutput('grep --null-data U-Boot /dev/mtd0ro|head -1 | cut -d" " -f2-4')
return uboot_version return uboot_version
def install_firmware(self, image_path): def install_firmware(self, image_path):
@ -114,6 +116,18 @@ class Component(ComponentBase):
print("ERROR: the cpld image {} doesn't exist ".format(image_path)) print("ERROR: the cpld image {} doesn't exist ".format(image_path))
return False return False
cmdline = self.CPLD_UPDATE_COMMAND.format(image_path, image_name)
success_flag = False success_flag = False
try:
subprocess.check_call(cmdline, stderr=subprocess.STDOUT, shell=True)
success_flag = True
except subprocess.CalledProcessError as e:
print("ERROR: Failed to upgrade CPLD: rc={}".format(e.returncode))
if success_flag:
print("INFO: Refresh or power cycle is required to finish CPLD installation")
return success_flag return success_flag

View File

@ -1,5 +1,5 @@
######################################################################## ########################################################################
# Nokia IXR7220_D1 # Nokia IXS7215
# #
# Module contains platform specific implementation of SONiC Platform # Module contains platform specific implementation of SONiC Platform
# Base API and provides the EEPROMs' information. # Base API and provides the EEPROMs' information.
@ -7,10 +7,9 @@
# The different EEPROMs available are as follows: # The different EEPROMs available are as follows:
# - System EEPROM : Contains Serial number, Service tag, Base MA # - System EEPROM : Contains Serial number, Service tag, Base MA
# address, etc. in ONIE TlvInfo EEPROM format. # address, etc. in ONIE TlvInfo EEPROM format.
# - PSU EEPROM : Contains Serial number, Part number, Service Tag, # - PSU EEPROM : Contains Model name and Part number.
# PSU type, Revision. # - Fan EEPROM : Contains Part number, Serial number, Manufacture Date,
# - Fan EEPROM : Contains Serial number, Part number, Service Tag, # and Service Tag.
# Fan type, Number of Fans in Fantray, Revision.
######################################################################## ########################################################################
@ -23,15 +22,9 @@ except ImportError as e:
# PSU eeprom fields in format required by EepromDecoder # PSU eeprom fields in format required by EepromDecoder
psu_eeprom_format = [ psu_eeprom_format = [
('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7), ('Model', 's', 15), ('burn', 'x', 1),
('Part Number', 's', 10), ('Part Num Revision', 's', 3), ('Part Number', 's', 14), ('burn', 'x', 40),
('Mfg Test', 's', 2), ('Redundant copy', 's', 83), ('PSU Type', 's', 1), ('Serial Number', 's', 11)
('Fab Rev', 's', 2)
]
# Fan eeprom fields in format required by EepromDecoder
fan_eeprom_format = [
('Model', 's', 12), ('Serial Number', 's', 13)
] ]
@ -48,6 +41,7 @@ class Eeprom(TlvInfoDecoder):
if self.is_sys_eeprom: if self.is_sys_eeprom:
self.start_offset = 0 self.start_offset = 0
self.eeprom_path = self.I2C_DIR + "i2c-0/0-0053/eeprom" self.eeprom_path = self.I2C_DIR + "i2c-0/0-0053/eeprom"
# System EEPROM is in ONIE TlvInfo EEPROM format # System EEPROM is in ONIE TlvInfo EEPROM format
super(Eeprom, self).__init__(self.eeprom_path, super(Eeprom, self).__init__(self.eeprom_path,
self.start_offset, '', True) self.start_offset, '', True)
@ -55,18 +49,24 @@ class Eeprom(TlvInfoDecoder):
else: else:
if self.is_psu_eeprom: if self.is_psu_eeprom:
self.index = psu_index self.index = psu_index
self.start_offset = 6 self.start_offset = 18
self.eeprom_path = self.I2C_DIR \ self.eeprom_path = self.I2C_DIR \
+ "i2c-1/1-005{}/eeprom".format(2 - self.index) + "i2c-1/1-005{}/eeprom".format(self.index)
self.format = psu_eeprom_format self.format = psu_eeprom_format
# Decode device eeprom as per specified format
EepromDecoder.__init__(self, self.eeprom_path, self.format,
self.start_offset, '', True)
else: else:
self.index = fan_index self.index = fan_index
self.start_offset = 13 self.start_offset = 0
self.eeprom_path = self.I2C_DIR \ self.eeprom_path = self.I2C_DIR \
+ "i2c-4{0}/4{0}-0050/eeprom".format(self.index - 1) + "i2c-0/0-005{}/eeprom".format(self.index + 4)
self.format = fan_eeprom_format
EepromDecoder.__init__(self, self.eeprom_path, self.format, # Fan EEPROM is in ONIE TlvInfo EEPROM format
self.start_offset, '', True) super(Eeprom, self).__init__(self.eeprom_path,
self.start_offset, '', True)
self._load_device_eeprom() self._load_device_eeprom()
def _load_system_eeprom(self): def _load_system_eeprom(self):
@ -83,24 +83,24 @@ class Eeprom(TlvInfoDecoder):
self.serial_number = 'NA' self.serial_number = 'NA'
self.part_number = 'NA' self.part_number = 'NA'
self.model_str = 'NA' self.model_str = 'NA'
self.serial = 'NA' self.service_tag = 'NA'
self.eeprom_tlv_dict = dict() self.eeprom_tlv_dict = dict()
else: else:
eeprom = self.eeprom_data eeprom = self.eeprom_data
self.eeprom_tlv_dict = dict()
if not self.is_valid_tlvinfo_header(eeprom): if not self.is_valid_tlvinfo_header(eeprom):
self.base_mac = 'NA' self.base_mac = 'NA'
self.serial_number = 'NA' self.serial_number = 'NA'
self.part_number = 'NA' self.part_number = 'NA'
self.model_str = 'NA' self.model_str = 'NA'
self.serial = 'NA' self.service_tag = 'NA'
return return
total_length = (eeprom[9] << 8) | eeprom[10] total_length = (eeprom[9] << 8) | eeprom[10]
tlv_index = self._TLV_INFO_HDR_LEN tlv_index = self._TLV_INFO_HDR_LEN
tlv_end = self._TLV_INFO_HDR_LEN + total_length tlv_end = self._TLV_INFO_HDR_LEN + total_length
# Construct dictionary of eeprom TLV entries
self.eeprom_tlv_dict = dict()
while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end: while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end:
if not self.is_valid_tlv(eeprom[tlv_index:]): if not self.is_valid_tlv(eeprom[tlv_index:]):
break break
@ -108,7 +108,7 @@ class Eeprom(TlvInfoDecoder):
tlv = eeprom[tlv_index:tlv_index + 2 tlv = eeprom[tlv_index:tlv_index + 2
+ eeprom[tlv_index + 1]] + eeprom[tlv_index + 1]]
code = "0x%02X" % (tlv[0]) code = "0x%02X" % (tlv[0])
name, value = self.decoder(None, tlv) name, value = self.decoder(None, tlv)
self.eeprom_tlv_dict[code] = value self.eeprom_tlv_dict[code] = value
@ -118,56 +118,98 @@ class Eeprom(TlvInfoDecoder):
tlv_index += eeprom[tlv_index+1] + 2 tlv_index += eeprom[tlv_index+1] + 2
self.base_mac = self.eeprom_tlv_dict.get( self.base_mac = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_MAC_BASE), 'NA') "0x%X" % (self._TLV_CODE_MAC_BASE), 'NA')
self.serial_number = self.eeprom_tlv_dict.get( self.serial_number = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA') "0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA')
self.part_number = self.eeprom_tlv_dict.get( self.part_number = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA') "0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA')
self.model_str = self.eeprom_tlv_dict.get( self.model_str = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA') "0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA')
self.serial = self.eeprom_tlv_dict.get( self.service_tag = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA') "0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA')
def _load_device_eeprom(self): def _load_device_eeprom(self):
""" """
Reads the Fan/PSU EEPROM and retrieves the serial number and Reads the Fan/PSU EEPROM and interprets as per the specified format
model number of the device.
""" """
try: self.serial_number = 'NA'
# Read Fan/PSU EEPROM as per the specified format. self.part_number = 'NA'
self.eeprom_data = EepromDecoder.read_eeprom(self) self.model_str = 'NA'
except Exception as e: self.service_tag = 'NA'
self.serial_number = 'NA' self.mfg_date = 'NA'
self.part_number = 'NA'
self.model_str = 'NA' # PSU device eeproms use proprietary format
self.serial = 'NA' if self.is_psu_eeprom:
else: try:
# Read Fan/PSU EEPROM as per the specified format.
self.eeprom_data = EepromDecoder.read_eeprom(self)
except Exception as e:
return
# Bail out if PSU eeprom unavailable
if self.eeprom_data[0] == 255:
return
(valid, data) = self._get_eeprom_field("Model") (valid, data) = self._get_eeprom_field("Model")
if valid: if valid:
self.model_str = data self.model_str = data.decode()
else:
self.model_str = 'NA'
(valid, data) = self._get_eeprom_field("Serial Number") (valid, data) = self._get_eeprom_field("Part Number")
if valid: if valid:
self.serial_number = data self.part_number = data.decode()
else:
self.serial_number = 'NA'
if self.is_psu_eeprom: # Early PSU device eeproms were not programmed with serial #
(valid, data) = self._get_eeprom_field("PSU Type") try:
(valid, data) = self._get_eeprom_field("Serial Number")
if valid: if valid:
self.psu_type = data self.serial_number = data.decode()
else: except Exception as e:
self.psu_type = 'NA' return
else:
(valid, data) = self._get_eeprom_field("Fan Type")
if valid:
self.fan_type = data
else:
self.fan_type = 'NA'
def _get_eeprom_field(self, field_name): # Fan device eeproms use ONIE TLV format
else:
try:
# Read Fan EEPROM as per ONIE TlvInfo EEPROM format.
self.eeprom_data = self.read_eeprom()
except Exception as e:
return
eeprom = self.eeprom_data
if not self.is_valid_tlvinfo_header(eeprom):
return
total_length = (eeprom[9] << 8) | eeprom[10]
tlv_index = self._TLV_INFO_HDR_LEN
tlv_end = self._TLV_INFO_HDR_LEN + total_length
# Construct dictionary of eeprom TLV entries
self.eeprom_tlv_dict = dict()
while (tlv_index + 2) < len(eeprom) and tlv_index < tlv_end:
if not self.is_valid_tlv(eeprom[tlv_index:]):
break
tlv = eeprom[tlv_index:tlv_index + 2
+ eeprom[tlv_index + 1]]
code = "0x%02X" % (tlv[0])
name, value = self.decoder(None, tlv)
self.eeprom_tlv_dict[code] = value
if eeprom[tlv_index] == self._TLV_CODE_CRC_32:
break
tlv_index += eeprom[tlv_index+1] + 2
self.serial_number = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA')
self.part_number = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_PART_NUMBER), 'NA')
self.model_str = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA')
self.service_tag = self.eeprom_tlv_dict.get(
"0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA')
def _get_eeprom_field(self, field_name, decode=False):
""" """
For a field name specified in the EEPROM format, returns the For a field name specified in the EEPROM format, returns the
presence of the field and the value for the same. presence of the field and the value for the same.
@ -205,24 +247,23 @@ class Eeprom(TlvInfoDecoder):
else: else:
return int(self.fan_type.encode('hex'), 16) return int(self.fan_type.encode('hex'), 16)
# System EEPROM specific methods
def base_mac_addr(self):
"""
Returns the base MAC address found in the system EEPROM.
"""
return self.base_mac
def modelstr(self): def modelstr(self):
""" """
Returns the Model name. Returns the Model name.
""" """
return self.model_str return self.model_str
def serial_str(self): def base_mac_addr(self):
"""
Returns the base MAC address found in the system EEPROM.
"""
return self.base_mac
def service_tag_str(self):
""" """
Returns the servicetag number. Returns the servicetag number.
""" """
return self.serial return self.service_tag
def system_eeprom_info(self): def system_eeprom_info(self):
""" """

View File

@ -1,5 +1,5 @@
######################################################################## ########################################################################
# Nokia 7215 # Nokia IXS7215
# #
# Module contains an implementation of SONiC Platform Base API and # Module contains an implementation of SONiC Platform Base API and
# provides the Fans' information which are available in the platform # provides the Fans' information which are available in the platform
@ -9,7 +9,9 @@
try: try:
import os import os
import time
from sonic_platform_base.fan_base import FanBase from sonic_platform_base.fan_base import FanBase
from sonic_platform.eeprom import Eeprom
from sonic_py_common import logger from sonic_py_common import logger
except ImportError as e: except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
@ -41,6 +43,9 @@ class Fan(FanBase):
self.get_fan_speed_reg = ADT7473_DIR+"fan{}_input".format(self.index) self.get_fan_speed_reg = ADT7473_DIR+"fan{}_input".format(self.index)
self.max_fan_speed = MAX_IXS7215_FAN_SPEED self.max_fan_speed = MAX_IXS7215_FAN_SPEED
self.supported_led_color = ['off', 'green', 'red'] self.supported_led_color = ['off', 'green', 'red']
# Fan eeprom
self.eeprom = Eeprom(is_fan=True, fan_index=self.index)
else: else:
# this is a PSU Fan # this is a PSU Fan
self.index = fan_index self.index = fan_index
@ -78,6 +83,12 @@ class Fan(FanBase):
except Exception as e: except Exception as e:
rv = 'ERR' rv = 'ERR'
# Ensure that the write operation has succeeded
if (int(self._get_i2c_register(reg_file)) != value ):
time.sleep(3)
if (int(self._get_i2c_register(reg_file)) != value ):
rv = 'ERR'
return rv return rv
def get_name(self): def get_name(self):
@ -123,10 +134,9 @@ class Fan(FanBase):
Retrieves the model number of the Fan Retrieves the model number of the Fan
Returns: Returns:
string: Part number of Fan string: Model number of Fan. Use part number for this.
""" """
return self.eeprom.part_number_str()
return 'NA'
def get_serial(self): def get_serial(self):
""" """
@ -135,8 +145,25 @@ class Fan(FanBase):
Returns: Returns:
string: Serial number of Fan string: Serial number of Fan
""" """
return self.eeprom.serial_number_str()
return 'NA' def get_part_number(self):
"""
Retrieves the part number of the Fan
Returns:
string: Part number of Fan
"""
return self.eeprom.part_number_str()
def get_service_tag(self):
"""
Retrieves the service tag of the Fan
Returns:
string: Service Tag of Fan
"""
return self.eeprom.service_tag_str()
def get_status(self): def get_status(self):
""" """

View File

@ -30,7 +30,7 @@ class NokiaFanDrawer(FanDrawerBase):
""" """
Retrieves the model number of the Fan Drawer Retrieves the model number of the Fan Drawer
Returns: Returns:
string: Part number of Fan Drawer string: Part number of Fan Drawer
""" """
return self._fan_list[0].get_model() return self._fan_list[0].get_model()
@ -49,7 +49,7 @@ class NokiaFanDrawer(FanDrawerBase):
bool: True if Fan is operating properly, False if not bool: True if Fan is operating properly, False if not
""" """
return self._fan_list[0].get_status() return self._fan_list[0].get_status()
def get_direction(self): def get_direction(self):
return 'intake' return 'intake'
@ -74,8 +74,8 @@ class NokiaFanDrawer(FanDrawerBase):
integer: The 1-based relative physical position in parent device integer: The 1-based relative physical position in parent device
""" """
return self._index return self._index
# For Nokia platforms with fan drawer(s) # For Nokia platforms with fan drawer(s)
class RealDrawer(NokiaFanDrawer): class RealDrawer(NokiaFanDrawer):
def __init__(self, index): def __init__(self, index):
@ -84,8 +84,3 @@ class RealDrawer(NokiaFanDrawer):
def get_name(self): def get_name(self):
return self._name return self._name

View File

@ -1,5 +1,5 @@
######################################################################## ########################################################################
# Nokia 7215 # Nokia IXS7215
# #
# Module contains an implementation of SONiC Platform Base API and # Module contains an implementation of SONiC Platform Base API and
# provides the PSUs' information which are available in the platform # provides the PSUs' information which are available in the platform
@ -10,6 +10,7 @@ try:
import sys import sys
from sonic_platform_base.psu_base import PsuBase from sonic_platform_base.psu_base import PsuBase
from sonic_py_common import logger from sonic_py_common import logger
from sonic_platform.eeprom import Eeprom
except ImportError as e: except ImportError as e:
raise ImportError(str(e) + "- required module not found") raise ImportError(str(e) + "- required module not found")
@ -34,6 +35,9 @@ class Psu(PsuBase):
self.index = psu_index + 1 self.index = psu_index + 1
self._fan_list = [] self._fan_list = []
# PSU eeprom
self.eeprom = Eeprom(is_psu=True, psu_index=self.index)
def get_name(self): def get_name(self):
""" """
Retrieves the name of the device Retrieves the name of the device
@ -52,7 +56,7 @@ class Psu(PsuBase):
""" """
if smbus_present == 0: # if called from psuutil outside of pmon if smbus_present == 0: # if called from psuutil outside of pmon
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa')
psustatus = int(psustatus, 16) psustatus = int(psustatus, 16)
else: else:
bus = smbus.SMBus(0) bus = smbus.SMBus(0)
@ -78,8 +82,7 @@ class Psu(PsuBase):
Returns: Returns:
string: Part number of PSU string: Part number of PSU
""" """
return "N/A" return self.eeprom.modelstr()
# return self.eeprom.serial_number_str()
def get_serial(self): def get_serial(self):
@ -89,10 +92,18 @@ class Psu(PsuBase):
Returns: Returns:
string: Serial number of PSU string: Serial number of PSU
""" """
return "N/A" return self.eeprom.serial_number_str()
# return self.eeprom.serial_number_str()
def get_part_number(self):
"""
Retrieves the part number of the PSU
Returns:
string: Part number of PSU
"""
return self.eeprom.part_number_str()
def get_status(self): def get_status(self):
""" """
Retrieves the operational status of the PSU Retrieves the operational status of the PSU
@ -102,7 +113,7 @@ class Psu(PsuBase):
""" """
if smbus_present == 0: if smbus_present == 0:
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa')
psustatus = int(psustatus, 16) psustatus = int(psustatus, 16)
sonic_logger.log_warning("PMON psu-smbus - presence = 0 ") sonic_logger.log_warning("PMON psu-smbus - presence = 0 ")
else: else:
@ -131,7 +142,7 @@ class Psu(PsuBase):
e.g. 12.1 e.g. 12.1
""" """
if smbus_present == 0: if smbus_present == 0:
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa')
psustatus = int(psustatus, 16) psustatus = int(psustatus, 16)
else: else:
bus = smbus.SMBus(0) bus = smbus.SMBus(0)
@ -153,30 +164,6 @@ class Psu(PsuBase):
psu_voltage = 0.0 psu_voltage = 0.0
return psu_voltage return psu_voltage
# def get_current(self):
# """
# Retrieves present electric current supplied by PSU
#
# Returns:
# A float number, electric current in amperes,
# e.g. 15.4
# """
# psu_current = 0.0
#
# return psu_current
#
# def get_power(self):
# """
# Retrieves current energy supplied by PSU
#
# Returns:
# A float number, the power in watts,
# e.g. 302.6
# """
# psu_power = 0.0
#
# return psu_power
def get_position_in_parent(self): def get_position_in_parent(self):
""" """
Retrieves 1-based relative physical position in parent device Retrieves 1-based relative physical position in parent device
@ -191,7 +178,7 @@ class Psu(PsuBase):
Returns: Returns:
bool: True if it is replaceable. bool: True if it is replaceable.
""" """
return True return True
def get_powergood_status(self): def get_powergood_status(self):
""" """
@ -202,7 +189,7 @@ class Psu(PsuBase):
""" """
if smbus_present == 0: if smbus_present == 0:
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') cmdstatus, psustatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0xa')
psustatus = int(psustatus, 16) psustatus = int(psustatus, 16)
else: else:
bus = smbus.SMBus(0) bus = smbus.SMBus(0)
@ -243,6 +230,6 @@ class Psu(PsuBase):
bool: True if status LED state is set successfully, False if bool: True if status LED state is set successfully, False if
not not
""" """
# In ISX7215 , the firmware running in the PSU controls the LED # The firmware running in the PSU controls the LED
# and the PSU LED state cannot be changed from CPU. # and the PSU LED state cannot be changed from CPU.
return False return False

View File

@ -366,7 +366,7 @@ class Sfp(SfpBase):
transceiver_info_dict['nominal_bit_rate'] = str( transceiver_info_dict['nominal_bit_rate'] = str(
sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value']) sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value'])
transceiver_info_dict['application_advertisement'] = 'N/A' transceiver_info_dict['application_advertisement'] = 'N/A'
return transceiver_info_dict return transceiver_info_dict
def get_transceiver_bulk_status(self): def get_transceiver_bulk_status(self):
@ -571,7 +571,7 @@ class Sfp(SfpBase):
rx_los_list.append(rx_los_data & 0x02 != 0) rx_los_list.append(rx_los_data & 0x02 != 0)
else: else:
return None return None
return rx_los_list return rx_los_list
def get_tx_fault(self): def get_tx_fault(self):
@ -617,7 +617,7 @@ class Sfp(SfpBase):
tx_disable_list.append(tx_disable_data & 0xC0 != 0) tx_disable_list.append(tx_disable_data & 0xC0 != 0)
else: else:
return None return None
return tx_disable_list return tx_disable_list
def get_tx_disable_channel(self): def get_tx_disable_channel(self):
@ -668,7 +668,7 @@ class Sfp(SfpBase):
""" """
if self.sfp_type == COPPER_TYPE: if self.sfp_type == COPPER_TYPE:
return None return None
transceiver_bulk_status = self.get_transceiver_bulk_status() transceiver_bulk_status = self.get_transceiver_bulk_status()
return transceiver_bulk_status.get("temperature", "N/A") return transceiver_bulk_status.get("temperature", "N/A")
@ -680,7 +680,7 @@ class Sfp(SfpBase):
""" """
if self.sfp_type == COPPER_TYPE: if self.sfp_type == COPPER_TYPE:
return None return None
transceiver_bulk_status = self.get_transceiver_bulk_status() transceiver_bulk_status = self.get_transceiver_bulk_status()
return transceiver_bulk_status.get("voltage", "N/A") return transceiver_bulk_status.get("voltage", "N/A")
@ -688,11 +688,11 @@ class Sfp(SfpBase):
""" """
Retrieves the TX bias current of this SFP Retrieves the TX bias current of this SFP
Returns: Returns:
""" """
if self.sfp_type == COPPER_TYPE: if self.sfp_type == COPPER_TYPE:
return None return None
tx_bias_list = [] tx_bias_list = []
transceiver_bulk_status = self.get_transceiver_bulk_status() transceiver_bulk_status = self.get_transceiver_bulk_status()
tx_bias_list.append(transceiver_bulk_status.get("tx1bias", "N/A")) tx_bias_list.append(transceiver_bulk_status.get("tx1bias", "N/A"))
@ -884,7 +884,7 @@ class Sfp(SfpBase):
return False return False
if smbus_present == 0: # if called from sfputil outside of pmon if smbus_present == 0: # if called from sfputil outside of pmon
cmdstatus, sfpstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x3') cmdstatus, sfpstatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x3')
sfpstatus = int(sfpstatus, 16) sfpstatus = int(sfpstatus, 16)
else: else:
bus = smbus.SMBus(0) bus = smbus.SMBus(0)
@ -938,7 +938,7 @@ class Sfp(SfpBase):
return True return True
else: else:
return False return False
def get_position_in_parent(self): def get_position_in_parent(self):
""" """
Retrieves 1-based relative physical position in parent device Retrieves 1-based relative physical position in parent device

View File

@ -51,7 +51,7 @@ class sfp_event:
def _get_transceiver_status(self): def _get_transceiver_status(self):
if smbus_present == 0: if smbus_present == 0:
sonic_logger.log_info(" PMON - smbus ERROR - DEBUG sfp_event ") sonic_logger.log_info(" PMON - smbus ERROR - DEBUG sfp_event ")
cmdstatus, sfpstatus = cmd.getstatusoutput('i2cget -y 0 0x41 0x3') cmdstatus, sfpstatus = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x3')
sfpstatus = int(sfpstatus, 16) sfpstatus = int(sfpstatus, 16)
else: else:
bus = smbus.SMBus(0) bus = smbus.SMBus(0)

View File

@ -41,6 +41,10 @@ def main():
print(" Chassis all_fans: {}\n".format(chassis.get_all_fans())) print(" Chassis all_fans: {}\n".format(chassis.get_all_fans()))
print(" Chassis num_psus: {}".format(chassis.get_num_psus()))
print(" Chassis all_psus: {}\n".format(chassis.get_all_psus()))
print(" Chassis num_thermals: {}".format(chassis.get_num_thermals())) print(" Chassis num_thermals: {}".format(chassis.get_num_thermals()))
print(" Chassis all_thermals: {}\n".format(chassis.get_all_thermals())) print(" Chassis all_thermals: {}\n".format(chassis.get_all_thermals()))

View File

@ -10,6 +10,11 @@ def main():
chassis = Chassis() chassis = Chassis()
for component in chassis.get_all_components():
print(" Name: {}".format(component.get_name()))
print(" Description: {}".format(component.get_description()))
print(" FW version: {}\n".format(component.get_firmware_version()))
return return

View File

@ -12,11 +12,11 @@ def main():
eeprom = chassis.get_eeprom() eeprom = chassis.get_eeprom()
print " Model: {}, Serial: {}".format(eeprom.modelstr(), print(" Model: {}, Service Tag: {}".format(eeprom.modelstr(),
eeprom.serial_str()) eeprom.service_tag_str()))
print " Part#: {}, Serial#: {}".format(eeprom.part_number_str(), print(" Part#: {}, Serial#: {}".format(eeprom.part_number_str(),
eeprom.serial_number_str()) eeprom.serial_number_str()))
print " Base MAC: {}".format(eeprom.base_mac_addr()) print(" Base MAC: {}".format(eeprom.base_mac_addr()))
return return

View File

@ -11,15 +11,20 @@ def main():
chassis = Chassis() chassis = Chassis()
for fan in chassis.get_all_fans(): for fan in chassis.get_all_fans():
print(" Name:", fan.get_name()) if not fan.get_presence():
print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(), print(" Name: {} not present".format(fan.get_name()))
fan.get_status(), else:
fan.get_status_led())) print(" Name:", fan.get_name())
print(" Model: {}, Serial: {}".format(fan.get_model(), print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(),
fan.get_serial())) fan.get_status(),
print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(), fan.get_status_led()))
str(fan.get_speed()), print(" Model: {}, Serial#: {}".format(fan.get_model(),
str(fan.get_target_speed()))) fan.get_serial()))
print(" Part#: {}, Service Tag: {}".format(fan.get_part_number(),
fan.get_service_tag()))
print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(),
str(fan.get_speed()),
str(fan.get_target_speed())))
return return

View File

@ -11,13 +11,28 @@ def main():
chassis = Chassis() chassis = Chassis()
for psu in chassis.get_all_psus(): for psu in chassis.get_all_psus():
print(" Name:", psu.get_name()) if not psu.get_presence():
print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(), print(" Name: {} not present".format(psu.get_name()))
psu.get_status(), else:
psu.get_status_led())) print(" Name:", psu.get_name())
print(" Model: {}, Serial: {}".format(psu.get_model(), print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(),
psu.get_serial())) psu.get_status(),
print(" Voltage: {}, Current: NO, Power: NO \n".format(psu.get_voltage())) psu.get_status_led()))
print(" Model: {}, Serial#: {}, Part#: {}".format(psu.get_model(),
psu.get_serial(),
psu.get_part_number()))
try:
current = psu.get_current()
except NotImplementedError:
current = "NA"
try:
power = psu.get_power()
except NotImplementedError:
power = "NA"
print(" Voltage: {}, Current: {}, Power: {}\n".format(psu.get_voltage(),
current,
power))
return return

View File

@ -7,15 +7,16 @@ except ImportError as e:
def main(): def main():
print("---------------------")
print("Chassis SFP Unit Test")
print("---------------------")
chassis = Chassis()
PORT_START = 1 PORT_START = 1
PORT_END = 52 PORT_END = 52
chassis = Chassis()
for physical_port in range(PORT_START, PORT_END+1): for physical_port in range(PORT_START, PORT_END+1):
print(" ") print(" ")
print(" SFP transceiver tests PORT = ", physical_port) print(" SFP transceiver tests PORT = ", physical_port)
name = chassis.get_sfp(physical_port).get_name() name = chassis.get_sfp(physical_port).get_name()

View File

@ -2,7 +2,6 @@
from sonic_platform.chassis import Chassis from sonic_platform.chassis import Chassis
def main(): def main():
print("-------------------------") print("-------------------------")
print("Chassis Thermal Unit Test") print("Chassis Thermal Unit Test")
@ -11,13 +10,39 @@ def main():
chassis = Chassis() chassis = Chassis()
for thermal in chassis.get_all_thermals(): for thermal in chassis.get_all_thermals():
print(" Name:", thermal.get_name()) if not thermal.get_presence():
print(" Presence: {}, Status: {}".format(thermal.get_presence(), print(" Name: {} not present".format(thermal.get_name()))
thermal.get_status())) else:
print(" Model: {}, Serial: {}".format(thermal.get_model(), print(" Name:", thermal.get_name())
thermal.get_serial())) print(" Presence: {}, Status: {}".format(thermal.get_presence(),
print(" Temperature: {}C, High Threshold: {}C\n".format(thermal.get_temperature(), thermal.get_status()))
thermal.get_high_threshold())) print(" Model: {}, Serial#: {}".format(thermal.get_model(),
thermal.get_serial()))
print(" Temperature(C): {}".format(thermal.get_temperature()))
try:
low_thresh = thermal.get_low_threshold()
except NotImplementedError:
low_thresh = "NA"
try:
high_thresh = thermal.get_high_threshold()
except NotImplementedError:
high_thresh = "NA"
print(" Low Threshold(C): {}, High Threshold(C): {}".format(low_thresh,
high_thresh))
try:
crit_low_thresh = thermal.get_low_critical_threshold()
except NotImplementedError:
crit_low_thresh = "NA"
try:
crit_high_thresh = thermal.get_high_critical_threshold()
except NotImplementedError:
crit_high_thresh = "NA"
print(" Crit Low Threshold(C): {}, Crit High Threshold(C): {}\n".format(crit_low_thresh,
crit_high_thresh))
return return