Skip to content

Commit

Permalink
[Nokia ixs7215] Support show system-health
Browse files Browse the repository at this point in the history
  • Loading branch information
dflynn-Nokia committed Sep 15, 2021
1 parent 1863e1f commit fc92e6b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 21 deletions.
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
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

0 comments on commit fc92e6b

Please sign in to comment.