[Nokia ixs7215] Support show system-health (#8771)
* [Nokia ixs7215] Support show system-health * [Nokia ixs7215] Fix LGTM alert
This commit is contained in:
parent
f6ec932b3c
commit
1a2e852483
@ -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"
|
||||||
|
}
|
||||||
|
}
|
@ -27,6 +27,11 @@ try:
|
|||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
smbus_present = 0
|
smbus_present = 0
|
||||||
|
|
||||||
|
if sys.version_info[0] < 3:
|
||||||
|
import commands as cmd
|
||||||
|
else:
|
||||||
|
import subprocess as cmd
|
||||||
|
|
||||||
MAX_SELECT_DELAY = 3600
|
MAX_SELECT_DELAY = 3600
|
||||||
COPPER_PORT_START = 1
|
COPPER_PORT_START = 1
|
||||||
COPPER_PORT_END = 48
|
COPPER_PORT_END = 48
|
||||||
@ -278,6 +283,9 @@ class Chassis(ChassisBase):
|
|||||||
from .thermal_manager import ThermalManager
|
from .thermal_manager import ThermalManager
|
||||||
return ThermalManager
|
return ThermalManager
|
||||||
|
|
||||||
|
def initizalize_system_led(self):
|
||||||
|
return True
|
||||||
|
|
||||||
def set_status_led(self, color):
|
def set_status_led(self, color):
|
||||||
"""
|
"""
|
||||||
Sets the state of the system LED
|
Sets the state of the system LED
|
||||||
@ -306,17 +314,18 @@ class Chassis(ChassisBase):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Write sys led
|
# Write sys led
|
||||||
if smbus_present == 0:
|
if smbus_present == 0: # called from host (e.g. 'show system-health')
|
||||||
sonic_logger.log_warning("PMON LED SET -> smbus present = 0")
|
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:
|
else:
|
||||||
bus = smbus.SMBus(0)
|
bus = smbus.SMBus(0)
|
||||||
DEVICE_ADDRESS = 0x41
|
DEVICE_ADDRESS = 0x41
|
||||||
DEVICEREG = 0x7
|
DEVICEREG = 0x7
|
||||||
bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, value)
|
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):
|
def get_status_led(self):
|
||||||
"""
|
"""
|
||||||
@ -327,29 +336,29 @@ class Chassis(ChassisBase):
|
|||||||
specified.
|
specified.
|
||||||
"""
|
"""
|
||||||
# Read sys led
|
# Read sys led
|
||||||
if smbus_present == 0:
|
if smbus_present == 0: # called from host
|
||||||
sonic_logger.log_warning("PMON LED GET -> smbus present = 0")
|
cmdstatus, value = cmd.getstatusoutput('sudo i2cget -y 0 0x41 0x7')
|
||||||
return False
|
value = int(value, 16)
|
||||||
else:
|
else:
|
||||||
bus = smbus.SMBus(0)
|
bus = smbus.SMBus(0)
|
||||||
DEVICE_ADDRESS = 0x41
|
DEVICE_ADDRESS = 0x41
|
||||||
DEVICE_REG = 0x7
|
DEVICE_REG = 0x7
|
||||||
value = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)
|
value = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)
|
||||||
|
|
||||||
if value == 0x00:
|
if value == 0x00:
|
||||||
color = 'off'
|
color = 'off'
|
||||||
elif value == 0x01:
|
elif value == 0x01:
|
||||||
color = 'amber'
|
color = 'amber'
|
||||||
elif value == 0x02:
|
elif value == 0x02:
|
||||||
color = 'green'
|
color = 'green'
|
||||||
elif value == 0x03:
|
elif value == 0x03:
|
||||||
color = 'amber_blink'
|
color = 'amber_blink'
|
||||||
elif value == 0x04:
|
elif value == 0x04:
|
||||||
color = 'green_blink'
|
color = 'green_blink'
|
||||||
else:
|
else:
|
||||||
return False
|
return None
|
||||||
|
|
||||||
return color
|
return color
|
||||||
|
|
||||||
def get_watchdog(self):
|
def get_watchdog(self):
|
||||||
"""
|
"""
|
||||||
|
Reference in New Issue
Block a user