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

[Nokia ixs7215] Support show system-health #8771

Merged
merged 2 commits into from
Sep 17, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"services_to_ignore": [],
"devices_to_ignore": [
"asic",
"psu"
],
"user_defined_checkers": [],
"polling_interval": 60,
"led_color": {
"fault": "amber",
"normal": "green",
"booting": "blinking green"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
try:
import os
import sys
import subprocess
dflynn-Nokia marked this conversation as resolved.
Show resolved Hide resolved
import glob
from sonic_platform_base.chassis_base import ChassisBase
from sonic_platform.sfp import Sfp
Expand All @@ -27,6 +28,11 @@
except ImportError as e:
smbus_present = 0

if sys.version_info[0] < 3:
import commands as cmd
else:
import subprocess as cmd

MAX_SELECT_DELAY = 3600
COPPER_PORT_START = 1
COPPER_PORT_END = 48
Expand Down Expand Up @@ -278,6 +284,9 @@ def get_thermal_manager(self):
from .thermal_manager import ThermalManager
return ThermalManager

def initizalize_system_led(self):
return True

def set_status_led(self, color):
"""
Sets the state of the system LED
Expand Down Expand Up @@ -306,17 +315,18 @@ def set_status_led(self, color):
return False

# Write sys led
if smbus_present == 0:
sonic_logger.log_warning("PMON LED SET -> smbus present = 0")
if smbus_present == 0: # called from host (e.g. 'show system-health')
cmdstatus, value = cmd.getstatusoutput('sudo i2cset -y 0 0x41 0x7 %d' % value)
if cmdstatus:
sonic_logger.log_warning(" System LED set %s failed" % value)
return False
else:
bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41
DEVICEREG = 0x7
bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, value)
sonic_logger.log_info(" System LED set O.K. ")
return True

return False
return True

def get_status_led(self):
"""
Expand All @@ -327,29 +337,29 @@ def get_status_led(self):
specified.
"""
# Read sys led
if smbus_present == 0:
sonic_logger.log_warning("PMON LED GET -> smbus present = 0")
return False
if smbus_present == 0: # called from host
cmdstatus, value = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x7')
value = int(value, 16)
else:
bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41
DEVICE_REG = 0x7
value = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)

if value == 0x00:
color = 'off'
elif value == 0x01:
color = 'amber'
elif value == 0x02:
color = 'green'
elif value == 0x03:
color = 'amber_blink'
elif value == 0x04:
color = 'green_blink'
else:
return False
if value == 0x00:
color = 'off'
elif value == 0x01:
color = 'amber'
elif value == 0x02:
color = 'green'
elif value == 0x03:
color = 'amber_blink'
elif value == 0x04:
color = 'green_blink'
else:
return None

return color
return color

def get_watchdog(self):
"""
Expand Down