[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:
parent
f77157f09d
commit
cbe7493b8e
11
device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot
Normal file
11
device/nokia/armhf-nokia_ixs7215_52x-r0/platform_reboot
Normal 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
|
@ -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 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 0x52 > /sys/class/i2c-adapter/i2c-1/new_device
|
||||
|
||||
|
@ -1,2 +1,4 @@
|
||||
__all__ = ["platform", "chassis"]
|
||||
from sonic_platform import *
|
||||
|
||||
|
||||
|
@ -159,6 +159,14 @@ class Chassis(ChassisBase):
|
||||
"""
|
||||
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):
|
||||
"""
|
||||
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)))
|
||||
|
||||
return self._watchdog
|
||||
|
||||
|
||||
def get_position_in_parent(self):
|
||||
"""
|
||||
Retrieves 1-based relative physical position in parent device. If the agent cannot determine the parent-relative position
|
||||
|
@ -16,6 +16,7 @@ try:
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
smbus_present = 1
|
||||
try:
|
||||
import smbus
|
||||
except ImportError as e:
|
||||
@ -34,6 +35,7 @@ class Component(ComponentBase):
|
||||
["System-CPLD", "Used for managing SFPs, LEDs, PSUs and FANs "],
|
||||
["U-Boot", "Performs initialization during booting"],
|
||||
]
|
||||
CPLD_UPDATE_COMMAND = 'cp /usr/sbin/vme /tmp; cp {} /tmp; cd /tmp; ./vme {};'
|
||||
|
||||
def __init__(self, component_index):
|
||||
self.index = component_index
|
||||
@ -55,12 +57,12 @@ class Component(ComponentBase):
|
||||
def _get_cpld_version(self, cpld_number):
|
||||
|
||||
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:
|
||||
bus = smbus.SMBus(0)
|
||||
DEVICE_ADDRESS = 0x41
|
||||
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))
|
||||
|
||||
@ -93,7 +95,7 @@ class Component(ComponentBase):
|
||||
return self._get_cpld_version(self.index)
|
||||
|
||||
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
|
||||
|
||||
def install_firmware(self, image_path):
|
||||
@ -114,6 +116,18 @@ class Component(ComponentBase):
|
||||
print("ERROR: the cpld image {} doesn't exist ".format(image_path))
|
||||
return False
|
||||
|
||||
cmdline = self.CPLD_UPDATE_COMMAND.format(image_path, image_name)
|
||||
|
||||
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
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
########################################################################
|
||||
# Nokia IXR7220_D1
|
||||
# Nokia IXS7215
|
||||
#
|
||||
# Module contains platform specific implementation of SONiC Platform
|
||||
# Base API and provides the EEPROMs' information.
|
||||
@ -7,10 +7,9 @@
|
||||
# The different EEPROMs available are as follows:
|
||||
# - System EEPROM : Contains Serial number, Service tag, Base MA
|
||||
# address, etc. in ONIE TlvInfo EEPROM format.
|
||||
# - PSU EEPROM : Contains Serial number, Part number, Service Tag,
|
||||
# PSU type, Revision.
|
||||
# - Fan EEPROM : Contains Serial number, Part number, Service Tag,
|
||||
# Fan type, Number of Fans in Fantray, Revision.
|
||||
# - PSU EEPROM : Contains Model name and Part number.
|
||||
# - Fan EEPROM : Contains Part number, Serial number, Manufacture Date,
|
||||
# and Service Tag.
|
||||
########################################################################
|
||||
|
||||
|
||||
@ -23,15 +22,9 @@ except ImportError as e:
|
||||
|
||||
# PSU eeprom fields in format required by EepromDecoder
|
||||
psu_eeprom_format = [
|
||||
('PPID', 's', 20), ('DPN Rev', 's', 3), ('Service Tag', 's', 7),
|
||||
('Part Number', 's', 10), ('Part Num Revision', 's', 3),
|
||||
('Mfg Test', 's', 2), ('Redundant copy', 's', 83), ('PSU Type', 's', 1),
|
||||
('Fab Rev', 's', 2)
|
||||
]
|
||||
|
||||
# Fan eeprom fields in format required by EepromDecoder
|
||||
fan_eeprom_format = [
|
||||
('Model', 's', 12), ('Serial Number', 's', 13)
|
||||
('Model', 's', 15), ('burn', 'x', 1),
|
||||
('Part Number', 's', 14), ('burn', 'x', 40),
|
||||
('Serial Number', 's', 11)
|
||||
]
|
||||
|
||||
|
||||
@ -48,6 +41,7 @@ class Eeprom(TlvInfoDecoder):
|
||||
if self.is_sys_eeprom:
|
||||
self.start_offset = 0
|
||||
self.eeprom_path = self.I2C_DIR + "i2c-0/0-0053/eeprom"
|
||||
|
||||
# System EEPROM is in ONIE TlvInfo EEPROM format
|
||||
super(Eeprom, self).__init__(self.eeprom_path,
|
||||
self.start_offset, '', True)
|
||||
@ -55,18 +49,24 @@ class Eeprom(TlvInfoDecoder):
|
||||
else:
|
||||
if self.is_psu_eeprom:
|
||||
self.index = psu_index
|
||||
self.start_offset = 6
|
||||
self.start_offset = 18
|
||||
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
|
||||
|
||||
# Decode device eeprom as per specified format
|
||||
EepromDecoder.__init__(self, self.eeprom_path, self.format,
|
||||
self.start_offset, '', True)
|
||||
else:
|
||||
self.index = fan_index
|
||||
self.start_offset = 13
|
||||
self.start_offset = 0
|
||||
self.eeprom_path = self.I2C_DIR \
|
||||
+ "i2c-4{0}/4{0}-0050/eeprom".format(self.index - 1)
|
||||
self.format = fan_eeprom_format
|
||||
EepromDecoder.__init__(self, self.eeprom_path, self.format,
|
||||
self.start_offset, '', True)
|
||||
+ "i2c-0/0-005{}/eeprom".format(self.index + 4)
|
||||
|
||||
# Fan EEPROM is in ONIE TlvInfo EEPROM format
|
||||
super(Eeprom, self).__init__(self.eeprom_path,
|
||||
self.start_offset, '', True)
|
||||
|
||||
self._load_device_eeprom()
|
||||
|
||||
def _load_system_eeprom(self):
|
||||
@ -83,24 +83,24 @@ class Eeprom(TlvInfoDecoder):
|
||||
self.serial_number = 'NA'
|
||||
self.part_number = 'NA'
|
||||
self.model_str = 'NA'
|
||||
self.serial = 'NA'
|
||||
self.service_tag = 'NA'
|
||||
self.eeprom_tlv_dict = dict()
|
||||
else:
|
||||
eeprom = self.eeprom_data
|
||||
self.eeprom_tlv_dict = dict()
|
||||
|
||||
if not self.is_valid_tlvinfo_header(eeprom):
|
||||
self.base_mac = 'NA'
|
||||
self.serial_number = 'NA'
|
||||
self.part_number = 'NA'
|
||||
self.model_str = 'NA'
|
||||
self.serial = 'NA'
|
||||
self.service_tag = 'NA'
|
||||
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
|
||||
@ -108,7 +108,7 @@ class Eeprom(TlvInfoDecoder):
|
||||
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
|
||||
@ -118,56 +118,98 @@ class Eeprom(TlvInfoDecoder):
|
||||
tlv_index += eeprom[tlv_index+1] + 2
|
||||
|
||||
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(
|
||||
"0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA')
|
||||
"0x%X" % (self._TLV_CODE_SERIAL_NUMBER), 'NA')
|
||||
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(
|
||||
"0x%X" % (self._TLV_CODE_PRODUCT_NAME), 'NA')
|
||||
self.serial = self.eeprom_tlv_dict.get(
|
||||
"0x%X" % (self._TLV_CODE_SERVICE_TAG), 'NA')
|
||||
"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 _load_device_eeprom(self):
|
||||
"""
|
||||
Reads the Fan/PSU EEPROM and retrieves the serial number and
|
||||
model number of the device.
|
||||
Reads the Fan/PSU EEPROM and interprets as per the specified format
|
||||
"""
|
||||
try:
|
||||
# Read Fan/PSU EEPROM as per the specified format.
|
||||
self.eeprom_data = EepromDecoder.read_eeprom(self)
|
||||
except Exception as e:
|
||||
self.serial_number = 'NA'
|
||||
self.part_number = 'NA'
|
||||
self.model_str = 'NA'
|
||||
self.serial = 'NA'
|
||||
else:
|
||||
self.serial_number = 'NA'
|
||||
self.part_number = 'NA'
|
||||
self.model_str = 'NA'
|
||||
self.service_tag = 'NA'
|
||||
self.mfg_date = 'NA'
|
||||
|
||||
# PSU device eeproms use proprietary format
|
||||
if self.is_psu_eeprom:
|
||||
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")
|
||||
if valid:
|
||||
self.model_str = data
|
||||
else:
|
||||
self.model_str = 'NA'
|
||||
self.model_str = data.decode()
|
||||
|
||||
(valid, data) = self._get_eeprom_field("Serial Number")
|
||||
(valid, data) = self._get_eeprom_field("Part Number")
|
||||
if valid:
|
||||
self.serial_number = data
|
||||
else:
|
||||
self.serial_number = 'NA'
|
||||
self.part_number = data.decode()
|
||||
|
||||
if self.is_psu_eeprom:
|
||||
(valid, data) = self._get_eeprom_field("PSU Type")
|
||||
# Early PSU device eeproms were not programmed with serial #
|
||||
try:
|
||||
(valid, data) = self._get_eeprom_field("Serial Number")
|
||||
if valid:
|
||||
self.psu_type = data
|
||||
else:
|
||||
self.psu_type = 'NA'
|
||||
else:
|
||||
(valid, data) = self._get_eeprom_field("Fan Type")
|
||||
if valid:
|
||||
self.fan_type = data
|
||||
else:
|
||||
self.fan_type = 'NA'
|
||||
self.serial_number = data.decode()
|
||||
except Exception as e:
|
||||
return
|
||||
|
||||
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
|
||||
presence of the field and the value for the same.
|
||||
@ -205,24 +247,23 @@ class Eeprom(TlvInfoDecoder):
|
||||
else:
|
||||
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):
|
||||
"""
|
||||
Returns the Model name.
|
||||
"""
|
||||
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.
|
||||
"""
|
||||
return self.serial
|
||||
return self.service_tag
|
||||
|
||||
def system_eeprom_info(self):
|
||||
"""
|
||||
|
@ -1,5 +1,5 @@
|
||||
########################################################################
|
||||
# Nokia 7215
|
||||
# Nokia IXS7215
|
||||
#
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
# provides the Fans' information which are available in the platform
|
||||
@ -9,7 +9,9 @@
|
||||
|
||||
try:
|
||||
import os
|
||||
import time
|
||||
from sonic_platform_base.fan_base import FanBase
|
||||
from sonic_platform.eeprom import Eeprom
|
||||
from sonic_py_common import logger
|
||||
except ImportError as e:
|
||||
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.max_fan_speed = MAX_IXS7215_FAN_SPEED
|
||||
self.supported_led_color = ['off', 'green', 'red']
|
||||
|
||||
# Fan eeprom
|
||||
self.eeprom = Eeprom(is_fan=True, fan_index=self.index)
|
||||
else:
|
||||
# this is a PSU Fan
|
||||
self.index = fan_index
|
||||
@ -78,6 +83,12 @@ class Fan(FanBase):
|
||||
except Exception as e:
|
||||
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
|
||||
|
||||
def get_name(self):
|
||||
@ -123,10 +134,9 @@ class Fan(FanBase):
|
||||
Retrieves the model number of the Fan
|
||||
|
||||
Returns:
|
||||
string: Part number of Fan
|
||||
string: Model number of Fan. Use part number for this.
|
||||
"""
|
||||
|
||||
return 'NA'
|
||||
return self.eeprom.part_number_str()
|
||||
|
||||
def get_serial(self):
|
||||
"""
|
||||
@ -135,8 +145,25 @@ class Fan(FanBase):
|
||||
Returns:
|
||||
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):
|
||||
"""
|
||||
|
@ -30,7 +30,7 @@ class NokiaFanDrawer(FanDrawerBase):
|
||||
"""
|
||||
Retrieves the model number of the Fan Drawer
|
||||
Returns:
|
||||
string: Part number of Fan Drawer
|
||||
string: Part number of Fan Drawer
|
||||
"""
|
||||
return self._fan_list[0].get_model()
|
||||
|
||||
@ -49,7 +49,7 @@ class NokiaFanDrawer(FanDrawerBase):
|
||||
bool: True if Fan is operating properly, False if not
|
||||
"""
|
||||
return self._fan_list[0].get_status()
|
||||
|
||||
|
||||
def get_direction(self):
|
||||
return 'intake'
|
||||
|
||||
@ -74,8 +74,8 @@ class NokiaFanDrawer(FanDrawerBase):
|
||||
integer: The 1-based relative physical position in parent device
|
||||
"""
|
||||
return self._index
|
||||
|
||||
|
||||
|
||||
|
||||
# For Nokia platforms with fan drawer(s)
|
||||
class RealDrawer(NokiaFanDrawer):
|
||||
def __init__(self, index):
|
||||
@ -84,8 +84,3 @@ class RealDrawer(NokiaFanDrawer):
|
||||
|
||||
def get_name(self):
|
||||
return self._name
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
########################################################################
|
||||
# Nokia 7215
|
||||
# Nokia IXS7215
|
||||
#
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
# provides the PSUs' information which are available in the platform
|
||||
@ -10,6 +10,7 @@ try:
|
||||
import sys
|
||||
from sonic_platform_base.psu_base import PsuBase
|
||||
from sonic_py_common import logger
|
||||
from sonic_platform.eeprom import Eeprom
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
@ -34,6 +35,9 @@ class Psu(PsuBase):
|
||||
self.index = psu_index + 1
|
||||
self._fan_list = []
|
||||
|
||||
# PSU eeprom
|
||||
self.eeprom = Eeprom(is_psu=True, psu_index=self.index)
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the device
|
||||
@ -52,7 +56,7 @@ class Psu(PsuBase):
|
||||
"""
|
||||
|
||||
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)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
@ -78,8 +82,7 @@ class Psu(PsuBase):
|
||||
Returns:
|
||||
string: Part number of PSU
|
||||
"""
|
||||
return "N/A"
|
||||
# return self.eeprom.serial_number_str()
|
||||
return self.eeprom.modelstr()
|
||||
|
||||
|
||||
def get_serial(self):
|
||||
@ -89,10 +92,18 @@ class Psu(PsuBase):
|
||||
Returns:
|
||||
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):
|
||||
"""
|
||||
Retrieves the operational status of the PSU
|
||||
@ -102,7 +113,7 @@ class Psu(PsuBase):
|
||||
"""
|
||||
|
||||
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)
|
||||
sonic_logger.log_warning("PMON psu-smbus - presence = 0 ")
|
||||
else:
|
||||
@ -131,7 +142,7 @@ class Psu(PsuBase):
|
||||
e.g. 12.1
|
||||
"""
|
||||
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)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
@ -153,30 +164,6 @@ class Psu(PsuBase):
|
||||
psu_voltage = 0.0
|
||||
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):
|
||||
"""
|
||||
Retrieves 1-based relative physical position in parent device
|
||||
@ -191,7 +178,7 @@ class Psu(PsuBase):
|
||||
Returns:
|
||||
bool: True if it is replaceable.
|
||||
"""
|
||||
return True
|
||||
return True
|
||||
|
||||
def get_powergood_status(self):
|
||||
"""
|
||||
@ -202,7 +189,7 @@ class Psu(PsuBase):
|
||||
"""
|
||||
|
||||
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)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
@ -243,6 +230,6 @@ class Psu(PsuBase):
|
||||
bool: True if status LED state is set successfully, False if
|
||||
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.
|
||||
return False
|
||||
|
@ -366,7 +366,7 @@ class Sfp(SfpBase):
|
||||
transceiver_info_dict['nominal_bit_rate'] = str(
|
||||
sfp_interface_bulk_data['data']['NominalSignallingRate(UnitsOf100Mbd)']['value'])
|
||||
transceiver_info_dict['application_advertisement'] = 'N/A'
|
||||
|
||||
|
||||
return transceiver_info_dict
|
||||
|
||||
def get_transceiver_bulk_status(self):
|
||||
@ -571,7 +571,7 @@ class Sfp(SfpBase):
|
||||
rx_los_list.append(rx_los_data & 0x02 != 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
return rx_los_list
|
||||
|
||||
def get_tx_fault(self):
|
||||
@ -617,7 +617,7 @@ class Sfp(SfpBase):
|
||||
tx_disable_list.append(tx_disable_data & 0xC0 != 0)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
return tx_disable_list
|
||||
|
||||
def get_tx_disable_channel(self):
|
||||
@ -668,7 +668,7 @@ class Sfp(SfpBase):
|
||||
"""
|
||||
if self.sfp_type == COPPER_TYPE:
|
||||
return None
|
||||
|
||||
|
||||
transceiver_bulk_status = self.get_transceiver_bulk_status()
|
||||
return transceiver_bulk_status.get("temperature", "N/A")
|
||||
|
||||
@ -680,7 +680,7 @@ class Sfp(SfpBase):
|
||||
"""
|
||||
if self.sfp_type == COPPER_TYPE:
|
||||
return None
|
||||
|
||||
|
||||
transceiver_bulk_status = self.get_transceiver_bulk_status()
|
||||
return transceiver_bulk_status.get("voltage", "N/A")
|
||||
|
||||
@ -688,11 +688,11 @@ class Sfp(SfpBase):
|
||||
"""
|
||||
Retrieves the TX bias current of this SFP
|
||||
Returns:
|
||||
|
||||
|
||||
"""
|
||||
if self.sfp_type == COPPER_TYPE:
|
||||
return None
|
||||
|
||||
|
||||
tx_bias_list = []
|
||||
transceiver_bulk_status = self.get_transceiver_bulk_status()
|
||||
tx_bias_list.append(transceiver_bulk_status.get("tx1bias", "N/A"))
|
||||
@ -884,7 +884,7 @@ class Sfp(SfpBase):
|
||||
return False
|
||||
|
||||
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)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
@ -938,7 +938,7 @@ class Sfp(SfpBase):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def get_position_in_parent(self):
|
||||
"""
|
||||
Retrieves 1-based relative physical position in parent device
|
||||
|
@ -51,7 +51,7 @@ class sfp_event:
|
||||
def _get_transceiver_status(self):
|
||||
if smbus_present == 0:
|
||||
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)
|
||||
else:
|
||||
bus = smbus.SMBus(0)
|
||||
|
@ -41,6 +41,10 @@ def main():
|
||||
|
||||
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 all_thermals: {}\n".format(chassis.get_all_thermals()))
|
||||
|
@ -10,6 +10,11 @@ def main():
|
||||
|
||||
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
|
||||
|
||||
|
||||
|
@ -12,11 +12,11 @@ def main():
|
||||
|
||||
eeprom = chassis.get_eeprom()
|
||||
|
||||
print " Model: {}, Serial: {}".format(eeprom.modelstr(),
|
||||
eeprom.serial_str())
|
||||
print " Part#: {}, Serial#: {}".format(eeprom.part_number_str(),
|
||||
eeprom.serial_number_str())
|
||||
print " Base MAC: {}".format(eeprom.base_mac_addr())
|
||||
print(" Model: {}, Service Tag: {}".format(eeprom.modelstr(),
|
||||
eeprom.service_tag_str()))
|
||||
print(" Part#: {}, Serial#: {}".format(eeprom.part_number_str(),
|
||||
eeprom.serial_number_str()))
|
||||
print(" Base MAC: {}".format(eeprom.base_mac_addr()))
|
||||
|
||||
return
|
||||
|
||||
|
@ -11,15 +11,20 @@ def main():
|
||||
chassis = Chassis()
|
||||
|
||||
for fan in chassis.get_all_fans():
|
||||
print(" Name:", fan.get_name())
|
||||
print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(),
|
||||
fan.get_status(),
|
||||
fan.get_status_led()))
|
||||
print(" Model: {}, Serial: {}".format(fan.get_model(),
|
||||
fan.get_serial()))
|
||||
print(" Direction: {}, Speed: {}RPM, Target Speed: {}%\n".format(fan.get_direction(),
|
||||
str(fan.get_speed()),
|
||||
str(fan.get_target_speed())))
|
||||
if not fan.get_presence():
|
||||
print(" Name: {} not present".format(fan.get_name()))
|
||||
else:
|
||||
print(" Name:", fan.get_name())
|
||||
print(" Presence: {}, Status: {}, LED: {}".format(fan.get_presence(),
|
||||
fan.get_status(),
|
||||
fan.get_status_led()))
|
||||
print(" Model: {}, Serial#: {}".format(fan.get_model(),
|
||||
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
|
||||
|
||||
|
||||
|
@ -11,13 +11,28 @@ def main():
|
||||
chassis = Chassis()
|
||||
|
||||
for psu in chassis.get_all_psus():
|
||||
print(" Name:", psu.get_name())
|
||||
print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(),
|
||||
psu.get_status(),
|
||||
psu.get_status_led()))
|
||||
print(" Model: {}, Serial: {}".format(psu.get_model(),
|
||||
psu.get_serial()))
|
||||
print(" Voltage: {}, Current: NO, Power: NO \n".format(psu.get_voltage()))
|
||||
if not psu.get_presence():
|
||||
print(" Name: {} not present".format(psu.get_name()))
|
||||
else:
|
||||
print(" Name:", psu.get_name())
|
||||
print(" Presence: {}, Status: {}, LED: {}".format(psu.get_presence(),
|
||||
psu.get_status(),
|
||||
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
|
||||
|
||||
|
||||
|
@ -7,15 +7,16 @@ except ImportError as e:
|
||||
|
||||
|
||||
def main():
|
||||
print("---------------------")
|
||||
print("Chassis SFP Unit Test")
|
||||
print("---------------------")
|
||||
|
||||
chassis = Chassis()
|
||||
|
||||
PORT_START = 1
|
||||
PORT_END = 52
|
||||
|
||||
chassis = Chassis()
|
||||
|
||||
for physical_port in range(PORT_START, PORT_END+1):
|
||||
|
||||
|
||||
print(" ")
|
||||
print(" SFP transceiver tests PORT = ", physical_port)
|
||||
name = chassis.get_sfp(physical_port).get_name()
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
from sonic_platform.chassis import Chassis
|
||||
|
||||
|
||||
def main():
|
||||
print("-------------------------")
|
||||
print("Chassis Thermal Unit Test")
|
||||
@ -11,13 +10,39 @@ def main():
|
||||
chassis = Chassis()
|
||||
|
||||
for thermal in chassis.get_all_thermals():
|
||||
print(" Name:", thermal.get_name())
|
||||
print(" Presence: {}, Status: {}".format(thermal.get_presence(),
|
||||
thermal.get_status()))
|
||||
print(" Model: {}, Serial: {}".format(thermal.get_model(),
|
||||
thermal.get_serial()))
|
||||
print(" Temperature: {}C, High Threshold: {}C\n".format(thermal.get_temperature(),
|
||||
thermal.get_high_threshold()))
|
||||
if not thermal.get_presence():
|
||||
print(" Name: {} not present".format(thermal.get_name()))
|
||||
else:
|
||||
print(" Name:", thermal.get_name())
|
||||
print(" Presence: {}, Status: {}".format(thermal.get_presence(),
|
||||
thermal.get_status()))
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user