[as7326-56x] Add to support PDDF (#7176)
Support PDDF on the as7326-56x platfrom Signed-off-by: Jostar Yang <jostar_yang@accton.com.tw>
This commit is contained in:
parent
e858d6e346
commit
ee728aab7b
@ -0,0 +1,67 @@
|
||||
{
|
||||
|
||||
"XCVR":
|
||||
{
|
||||
"xcvr_present":
|
||||
{
|
||||
"i2c":
|
||||
{
|
||||
"valmap-SFP": {"1":true, "0":false },
|
||||
"valmap-SFP28": {"1":true, "0":false },
|
||||
"valmap-QSFP28": {"1":true, "0":false}
|
||||
}
|
||||
}
|
||||
},
|
||||
"PSU":
|
||||
{
|
||||
"psu_present":
|
||||
{
|
||||
"i2c":
|
||||
{
|
||||
"valmap": { "1":true, "0":false }
|
||||
}
|
||||
},
|
||||
|
||||
"psu_power_good":
|
||||
{
|
||||
"i2c":
|
||||
{
|
||||
"valmap": { "1": true, "0":false }
|
||||
}
|
||||
},
|
||||
|
||||
"psu_fan_dir":
|
||||
{
|
||||
"i2c":
|
||||
{
|
||||
"valmap": { "F2B":"EXHAUST", "B2F":"INTAKE" }
|
||||
}
|
||||
},
|
||||
|
||||
"PSU_FAN_MAX_SPEED":"18000"
|
||||
},
|
||||
|
||||
"FAN":
|
||||
{
|
||||
"direction":
|
||||
{
|
||||
"i2c":
|
||||
{
|
||||
"valmap": {"1":"INTAKE", "0":"EXHAUST"}
|
||||
}
|
||||
},
|
||||
|
||||
"present":
|
||||
{
|
||||
"i2c":
|
||||
{
|
||||
"valmap": {"1":true, "0":false}
|
||||
}
|
||||
},
|
||||
|
||||
"duty_cycle_to_pwm": "lambda dc: ((dc*100)/625 -1)",
|
||||
|
||||
"pwm_to_duty_cycle": "lambda pwm: (((pwm+1)*625+75)/100)"
|
||||
}
|
||||
|
||||
}
|
2916
device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json
Normal file
2916
device/accton/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,16 @@
|
||||
[Unit]
|
||||
Description=Accton AS7326-56X Platform Monitoring service
|
||||
Before=pmon.service
|
||||
After=pddf-platform-init.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/accton_as7326_pddf_monitor.py
|
||||
KillSignal=SIGKILL
|
||||
SuccessExitStatus=SIGKILL
|
||||
|
||||
# Resource Limitations
|
||||
LimitCORE=infinity
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=Accton AS7326-56X Platform MAC handle service
|
||||
Before=opennsl-modules.service
|
||||
Before=opennsl-modules.service pddf-platform-init.service
|
||||
After=local-fs.target
|
||||
|
||||
[Service]
|
||||
|
@ -0,0 +1 @@
|
||||
../../../../pddf/i2c/service/pddf-platform-init.service
|
@ -0,0 +1,3 @@
|
||||
# All the derived classes for PDDF
|
||||
__all__ = ["platform", "chassis", "sfp", "psu", "thermal"]
|
||||
from . import platform
|
@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# PDDF
|
||||
# Module contains an implementation of SONiC Chassis API
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_platform_pddf_base.pddf_chassis import PddfChassis
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Chassis(PddfChassis):
|
||||
"""
|
||||
PDDF Platform-specific Chassis class
|
||||
"""
|
||||
|
||||
def __init__(self, pddf_data=None, pddf_plugin_data=None):
|
||||
PddfChassis.__init__(self, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
sfp_change_event_data = {'valid': 0, 'last': 0, 'present': 0}
|
||||
def get_change_event(self, timeout=2000):
|
||||
now = time.time()
|
||||
port_dict = {}
|
||||
change_dict = {}
|
||||
change_dict['sfp'] = port_dict
|
||||
|
||||
if timeout < 1000:
|
||||
timeout = 1000
|
||||
timeout = timeout / float(1000) # Convert to secs
|
||||
|
||||
if now < (self.sfp_change_event_data['last'] + timeout) and self.sfp_change_event_data['valid']:
|
||||
return True, change_dict
|
||||
|
||||
bitmap = 0
|
||||
for i in range(58):
|
||||
modpres = self.get_sfp(i).get_presence()
|
||||
if modpres:
|
||||
bitmap = bitmap | (1 << i)
|
||||
|
||||
changed_ports = self.sfp_change_event_data['present'] ^ bitmap
|
||||
if changed_ports:
|
||||
for i in range(58):
|
||||
if (changed_ports & (1 << i)):
|
||||
if (bitmap & (1 << i)) == 0:
|
||||
port_dict[i+1] = '0'
|
||||
else:
|
||||
port_dict[i+1] = '1'
|
||||
|
||||
|
||||
# Update teh cache dict
|
||||
self.sfp_change_event_data['present'] = bitmap
|
||||
self.sfp_change_event_data['last'] = now
|
||||
self.sfp_change_event_data['valid'] = 1
|
||||
return True, change_dict
|
||||
else:
|
||||
return True, change_dict
|
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
from sonic_platform_pddf_base.pddf_eeprom import PddfEeprom
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Eeprom(PddfEeprom):
|
||||
|
||||
def __init__(self, pddf_data=None, pddf_plugin_data=None):
|
||||
PddfEeprom.__init__(self, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
try:
|
||||
from sonic_platform_pddf_base.pddf_fan import PddfFan
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Fan(PddfFan):
|
||||
"""PDDF Platform-Specific Fan class"""
|
||||
|
||||
def __init__(self, tray_idx, fan_idx=0, pddf_data=None, pddf_plugin_data=None, is_psu_fan=False, psu_index=0):
|
||||
# idx is 0-based
|
||||
PddfFan.__init__(self, tray_idx, fan_idx, pddf_data, pddf_plugin_data, is_psu_fan, psu_index)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
# Since AS4630 psu_fan airflow direction cant be read from sysfs, it is fixed as 'F2B' or 'intake'
|
||||
|
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# PDDF
|
||||
# Module contains an implementation of SONiC Platform Base API and
|
||||
# provides the platform information
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
|
||||
try:
|
||||
from sonic_platform_pddf_base.pddf_platform import PddfPlatform
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Platform(PddfPlatform):
|
||||
"""
|
||||
PDDF Platform-Specific Platform Class
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
PddfPlatform.__init__(self)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
|
||||
|
||||
try:
|
||||
from sonic_platform_pddf_base.pddf_psu import PddfPsu
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Psu(PddfPsu):
|
||||
"""PDDF Platform-Specific PSU class"""
|
||||
|
||||
PLATFORM_PSU_CAPACITY = 1200
|
||||
|
||||
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
|
||||
PddfPsu.__init__(self, index, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
def get_maximum_supplied_power(self):
|
||||
"""
|
||||
Retrieves the maximum supplied power by PSU (or PSU capacity)
|
||||
Returns:
|
||||
A float number, the maximum power output in Watts.
|
||||
e.g. 1200.1
|
||||
"""
|
||||
return float(self.PLATFORM_PSU_CAPACITY)
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
Gets the type of the PSU
|
||||
Returns:
|
||||
A string, the type of PSU (AC/DC)
|
||||
"""
|
||||
return "DC"
|
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
from sonic_platform_pddf_base.pddf_sfp import PddfSfp
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
|
||||
class Sfp(PddfSfp):
|
||||
"""
|
||||
PDDF Platform-Specific Sfp class
|
||||
"""
|
||||
|
||||
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
|
||||
PddfSfp.__init__(self, index, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
|
||||
try:
|
||||
from sonic_platform_pddf_base.pddf_thermal import PddfThermal
|
||||
except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
|
||||
|
||||
class Thermal(PddfThermal):
|
||||
"""PDDF Platform-Specific Thermal class"""
|
||||
|
||||
def __init__(self, index, pddf_data=None, pddf_plugin_data=None):
|
||||
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data)
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
@ -0,0 +1,25 @@
|
||||
from setuptools import setup
|
||||
|
||||
setup(
|
||||
name='sonic-platform',
|
||||
version='1.0',
|
||||
description='SONiC platform API implementation on Accton Platforms',
|
||||
license='Apache 2.0',
|
||||
author='SONiC Team',
|
||||
author_email='linuxnetdev@microsoft.com',
|
||||
url='https://github.com/Azure/sonic-buildimage',
|
||||
packages=['sonic_platform'],
|
||||
classifiers=[
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Environment :: Plugins',
|
||||
'Intended Audience :: Developers',
|
||||
'Intended Audience :: Information Technology',
|
||||
'Intended Audience :: System Administrators',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Natural Language :: English',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python :: 3.7',
|
||||
'Topic :: Utilities',
|
||||
],
|
||||
keywords='sonic SONiC platform PLATFORM',
|
||||
)
|
@ -0,0 +1,309 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# ------------------------------------------------------------------
|
||||
# HISTORY:
|
||||
# mm/dd/yyyy (A.D.)
|
||||
# 3/23/2018: Roy Lee modify for as7326_56x
|
||||
# 6/26/2018: Jostar implement by new thermal policy from HW RD
|
||||
# 09/18/2020: Jostar Yang, change to call PDDF API .
|
||||
# ------------------------------------------------------------------
|
||||
|
||||
try:
|
||||
import os
|
||||
import sys
|
||||
import getopt
|
||||
import logging
|
||||
import logging.config
|
||||
import logging.handlers
|
||||
import time
|
||||
from sonic_platform import platform
|
||||
except ImportError as e:
|
||||
raise ImportError('%s - required module not found' % str(e))
|
||||
|
||||
# Deafults
|
||||
VERSION = '1.0'
|
||||
FUNCTION_NAME = 'accton_as7326_56x_monitor'
|
||||
|
||||
platform_chassis = None
|
||||
|
||||
# Default FAN speed: 37.5%(0x05)
|
||||
# Ori is that detect: (U45_BCM56873 + Thermal sensor_LM75_CPU:0x4B) /2
|
||||
# New Detect: (sensor_LM75_49 + Thermal sensor_LM75_CPU_4B) /2
|
||||
# Thermal policy: Both F2B and B2F
|
||||
# 1. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 =< 39C , Keep 37.5%(0x05) Fan speed
|
||||
# 2. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 39C , Change Fan speed from 37.5%(0x05) to % 75%(0x0B)
|
||||
# 3. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 45C , Change Fan speed from 75%(0x0B) to 100%(0x0F)
|
||||
# 4. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 61C , Send alarm message
|
||||
# 5. (sensor_LM75_49 + Thermal sensor_LM75_CPU) /2 > 66C , Shutdown system
|
||||
# 6. One Fan fail , Change Fan speed to 100%(0x0F)
|
||||
|
||||
# fan-dev 0-11 speed 0x05 Setup fan speed 37.50%
|
||||
# fan-dev 0-11 speed 0xB Setup fan speed 75%
|
||||
# fan-dev 0-11 speed 0xF Setup fan speed 100.00%
|
||||
|
||||
fan_policy_state = 1
|
||||
fan_fail = 0
|
||||
alarm_state = 0 # 0->default or clear, 1-->alarm detect
|
||||
test_temp = 0
|
||||
test_temp_list = [0, 0]
|
||||
temp_test_data = 0
|
||||
test_temp_revert = 0
|
||||
|
||||
# Make a class we can use to capture stdout and sterr in the log
|
||||
|
||||
|
||||
class device_monitor(object):
|
||||
# static temp var
|
||||
temp = 0
|
||||
new_pwm = 0
|
||||
pwm = 0
|
||||
ori_pwm = 0
|
||||
default_pwm = 0x4
|
||||
|
||||
def __init__(self, log_file, log_level):
|
||||
"""Needs a logger and a logger level."""
|
||||
# set up logging to file
|
||||
logging.basicConfig(
|
||||
filename=log_file,
|
||||
filemode='w',
|
||||
level=log_level,
|
||||
format='[%(asctime)s] {%(pathname)s:%(lineno)d} %(levelname)s - %(message)s',
|
||||
datefmt='%H:%M:%S'
|
||||
)
|
||||
# set up logging to console
|
||||
if log_level == logging.DEBUG:
|
||||
console = logging.StreamHandler()
|
||||
console.setLevel(log_level)
|
||||
formatter = logging.Formatter('%(name)-12s: %(levelname)-8s %(message)s')
|
||||
console.setFormatter(formatter)
|
||||
logging.getLogger('').addHandler(console)
|
||||
|
||||
sys_handler = logging.handlers.SysLogHandler(address='/dev/log')
|
||||
sys_handler.setLevel(logging.WARNING)
|
||||
logging.getLogger('').addHandler(sys_handler)
|
||||
|
||||
def get_state_from_fan_policy(self, temp, policy):
|
||||
state = 0
|
||||
logging.debug('temp=%d', temp)
|
||||
for i in range(0, len(policy)):
|
||||
#logging.debug('policy[%d][0]=%d, policy[%d][1]=%d', i,policy[i][0],i, policy[i][1])
|
||||
if temp > policy[i][0]:
|
||||
if temp <= policy[i][1]:
|
||||
state = policy[i][2]
|
||||
logging.debug('temp=%d >= policy[%d][0]=%d, temp=%d < policy[%d][1]=%d',
|
||||
temp, i, policy[i][0], temp, i, policy[i][1])
|
||||
logging.debug('fan_state=%d', state)
|
||||
if state == 0:
|
||||
state = policy[0][2] # below fan_min, set to default pwm
|
||||
logging.debug('set default state')
|
||||
return state
|
||||
|
||||
def manage_fans(self):
|
||||
LEVEL_FAN_DEF = 1
|
||||
LEVEL_FAN_MID = 2
|
||||
LEVEL_FAN_MAX = 3
|
||||
LEVEL_TEMP_HIGH = 4
|
||||
LEVEL_TEMP_CRITICAL = 5
|
||||
|
||||
FAN_NUM = 2
|
||||
FAN_TRAY_NUM = 6
|
||||
|
||||
fan_policy_state_pwm_tlb = {
|
||||
LEVEL_FAN_DEF: [38, 0x4],
|
||||
LEVEL_FAN_MID: [75, 0xB],
|
||||
LEVEL_FAN_MAX: [100, 0xE],
|
||||
LEVEL_TEMP_HIGH: [100, 0xE],
|
||||
LEVEL_TEMP_CRITICAL: [100, 0xE],
|
||||
}
|
||||
global platform_chassis
|
||||
global fan_policy_state
|
||||
global fan_fail
|
||||
global test_temp
|
||||
global test_temp_list
|
||||
global temp_test_data
|
||||
global test_temp_revert
|
||||
global alarm_state
|
||||
fan_policy = {
|
||||
0: [0, 39000, LEVEL_FAN_DEF], # F2B_policy, B2F_plicy, PWM, reg_val
|
||||
1: [39000, 45000, LEVEL_FAN_MID],
|
||||
2: [45000, 61000, LEVEL_FAN_MAX],
|
||||
3: [61000, 66000, LEVEL_TEMP_HIGH],
|
||||
4: [66000, 200000, LEVEL_TEMP_CRITICAL],
|
||||
}
|
||||
|
||||
ori_perc = platform_chassis.get_fan(0).get_speed()
|
||||
#logging.debug('test_temp=%d', test_temp)
|
||||
if test_temp == 0:
|
||||
temp2 = platform_chassis.get_thermal(1).get_temperature()*1000
|
||||
temp4 = platform_chassis.get_thermal(3).get_temperature()*1000
|
||||
else:
|
||||
temp2 = test_temp_list[0]
|
||||
temp4 = test_temp_list[1]
|
||||
# fan_fail=0 # When test no-fan DUT. Need to use this.
|
||||
if test_temp_revert == 0:
|
||||
temp_test_data = temp_test_data+2000
|
||||
else:
|
||||
temp_test_data = temp_test_data-2000
|
||||
|
||||
if temp2 == 0:
|
||||
temp_get = 50000 # if one detect sensor is fail or zero, assign temp=50000, let fan to 75%
|
||||
logging.debug('lm75_49 detect fail, so set temp_get=50000, let fan to 75%')
|
||||
elif temp4 == 0:
|
||||
temp_get = 50000 # if one detect sensor is fail or zero, assign temp=50000, let fan to 75%
|
||||
logging.debug('lm75_4b detect fail, so set temp_get=50000, let fan to 75%')
|
||||
else:
|
||||
temp_get = (temp2 + temp4)/2 # Use (sensor_LM75_49 + Thermal sensor_LM75_CPU_4B) /2
|
||||
logging.debug('Begeinning ,fan_policy_state=%d', fan_policy_state)
|
||||
if test_temp == 1:
|
||||
temp_get = temp_get+temp_test_data
|
||||
|
||||
ori_state = fan_policy_state
|
||||
fan_policy_state = self.get_state_from_fan_policy(temp_get, fan_policy)
|
||||
#logging.debug("temp2=" + str(temp2))
|
||||
#logging.debug("temp4=" + str(temp4))
|
||||
#logging.debug("temp_get=" + str(temp_get))
|
||||
logging.debug('temp2=lm75_49=%d,temp4=lm_4b=%d, temp_get=%d, ori_state=%d', temp2, temp4, temp_get, ori_state)
|
||||
if fan_policy_state > ori_state:
|
||||
logging.debug('ori_state=%d, fan_policy_state=%d', ori_state, fan_policy_state)
|
||||
new_perc = fan_policy_state_pwm_tlb[fan_policy_state][0]
|
||||
|
||||
if fan_fail == 0:
|
||||
if new_perc != ori_perc:
|
||||
# fan.set_fan_duty_cycle(new_perc)
|
||||
platform_chassis.get_fan(0).set_speed(new_perc)
|
||||
logging.info('Set fan speed from %d to %d', ori_perc, new_perc)
|
||||
|
||||
# for i in range (fan.FAN_NUM_1_IDX, fan.FAN_NUM_ON_MAIN_BROAD+1):
|
||||
for i in range(FAN_TRAY_NUM * FAN_NUM):
|
||||
if not platform_chassis.get_fan(i).get_status() or not platform_chassis.get_fan(i).get_speed_rpm():
|
||||
new_perc = 100
|
||||
logging.debug('fan_%d fail, set new_perc to 100', i+1)
|
||||
# if test_temp==0:# When test no-fan DUT. Need to use this.
|
||||
fan_fail = 1
|
||||
if ori_state < LEVEL_FAN_MAX:
|
||||
fan_policy_state = new_state = LEVEL_FAN_MAX
|
||||
logging.debug('fan_policy_state=%d', fan_policy_state)
|
||||
logging.warning('fan_policy_state is LEVEL_FAN_MAX')
|
||||
platform_chassis.get_fan(0).set_speed(new_perc)
|
||||
break
|
||||
else:
|
||||
fan_fail = 0
|
||||
|
||||
if fan_fail == 0:
|
||||
new_state = fan_policy_state
|
||||
else:
|
||||
if fan_policy_state > ori_state:
|
||||
new_state = fan_policy_state
|
||||
else:
|
||||
fan_policy_state = new_state = LEVEL_FAN_MAX
|
||||
|
||||
if ori_state == LEVEL_FAN_DEF:
|
||||
if new_state == LEVEL_TEMP_HIGH:
|
||||
if alarm_state == 0:
|
||||
logging.warning('Alarm for temperature high is detected')
|
||||
alarm_state = 1
|
||||
if new_state == LEVEL_TEMP_CRITICAL:
|
||||
logging.critical('Alarm for temperature critical is detected, reboot DUT')
|
||||
time.sleep(2)
|
||||
os.system('reboot')
|
||||
if ori_state == LEVEL_FAN_MID:
|
||||
if new_state == LEVEL_TEMP_HIGH:
|
||||
if alarm_state == 0:
|
||||
logging.warning('Alarm for temperature high is detected')
|
||||
alarm_state = 1
|
||||
if new_state == LEVEL_TEMP_CRITICAL:
|
||||
logging.critical('Alarm for temperature critical is detected')
|
||||
time.sleep(2)
|
||||
os.system('reboot')
|
||||
if ori_state == LEVEL_FAN_MAX:
|
||||
if new_state == LEVEL_TEMP_HIGH:
|
||||
if alarm_state == 0:
|
||||
logging.warning('Alarm for temperature high is detected')
|
||||
alarm_state = 1
|
||||
if new_state == LEVEL_TEMP_CRITICAL:
|
||||
logging.critical('Alarm for temperature critical is detected')
|
||||
time.sleep(2)
|
||||
os.system('reboot')
|
||||
if alarm_state == 1:
|
||||
if temp_get < (fan_policy[3][0] - 5000): # below 65 C, clear alarm
|
||||
logging.warning('Alarm for temperature high is cleared')
|
||||
alarm_state = 0
|
||||
if ori_state == LEVEL_TEMP_HIGH:
|
||||
if new_state == LEVEL_TEMP_CRITICAL:
|
||||
logging.critical('Alarm for temperature critical is detected')
|
||||
time.sleep(2)
|
||||
os.system('reboot')
|
||||
if new_state <= LEVEL_FAN_MID:
|
||||
logging.warning('Alarm for temperature high is cleared')
|
||||
alarm_state = 0
|
||||
if new_state <= LEVEL_FAN_MAX:
|
||||
if temp_get < (fan_policy[3][0] - 5000): # below 65 C, clear alarm
|
||||
logging.warning('Alarm for temperature high is cleared')
|
||||
alarm_state = 0
|
||||
if ori_state == LEVEL_TEMP_CRITICAL:
|
||||
if new_state <= LEVEL_FAN_MAX:
|
||||
logging.warning('Alarm for temperature critical is cleared')
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def main(argv):
|
||||
log_file = '%s.log' % FUNCTION_NAME
|
||||
log_level = logging.INFO
|
||||
global test_temp
|
||||
if len(sys.argv) != 1:
|
||||
try:
|
||||
opts, args = getopt.getopt(argv, 'hdlt:', ['lfile='])
|
||||
except getopt.GetoptError:
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
for opt, arg in opts:
|
||||
if opt == '-h':
|
||||
print('Usage: %s [-d] [-l <log_file>]' % sys.argv[0])
|
||||
return 0
|
||||
elif opt in ('-d', '--debug'):
|
||||
log_level = logging.DEBUG
|
||||
elif opt in ('-l', '--lfile'):
|
||||
log_file = arg
|
||||
|
||||
if sys.argv[1] == '-t':
|
||||
if len(sys.argv) != 4:
|
||||
print("temp test, need input four temp")
|
||||
return 0
|
||||
|
||||
i = 0
|
||||
for x in range(2, 4):
|
||||
test_temp_list[i] = int(sys.argv[x])*1000
|
||||
i = i+1
|
||||
test_temp = 1
|
||||
log_level = logging.DEBUG
|
||||
print(test_temp_list)
|
||||
|
||||
global platform_chassis
|
||||
platform_chassis = platform.Platform().get_chassis()
|
||||
|
||||
platform_chassis.get_fan(0).set_speed(38)
|
||||
|
||||
print("set default fan speed to 37.5%")
|
||||
monitor = device_monitor(log_file, log_level)
|
||||
|
||||
while True:
|
||||
monitor.manage_fans()
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main(sys.argv[1:])
|
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env python
|
||||
# Script to stop and start the respective platforms default services.
|
||||
# This will be used while switching the pddf->non-pddf mode and vice versa
|
||||
|
||||
import commands
|
||||
|
||||
def check_pddf_support():
|
||||
return True
|
||||
|
||||
def stop_platform_svc():
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7326-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Stop as7326-platform-fan.service failed %d"%status
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7326-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Stop as7326-platform-psu.service failed %d"%status
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl stop as7326-platform-monitor.service")
|
||||
if status:
|
||||
print "Stop as7326-platform-init.service failed %d"%status
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl disable as7326-platform-monitor.service")
|
||||
if status:
|
||||
print "Disable as7326-platform-monitor.service failed %d"%status
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7326_util.py clean")
|
||||
if status:
|
||||
print "accton_as7326_util.py clean command failed %d"%status
|
||||
return False
|
||||
|
||||
# HACK , stop the pddf-platform-init service if it is active
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service along with other platform serives failed %d"%status
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_svc():
|
||||
status, output = commands.getstatusoutput("/usr/local/bin/accton_as7326_util.py install")
|
||||
if status:
|
||||
print "accton_as7326_util.py install command failed %d"%status
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl enable as7326-platform-monitor.service")
|
||||
if status:
|
||||
print "Enable as7326-platform-monitor.service failed %d"%status
|
||||
return False
|
||||
status, output = commands.getstatusoutput("systemctl start as7326-platform-monitor-fan.service")
|
||||
if status:
|
||||
print "Start as7326-platform-monitor-fan.service failed %d"%status
|
||||
return False
|
||||
|
||||
status, output = commands.getstatusoutput("systemctl start as7326-platform-monitor-psu.service")
|
||||
if status:
|
||||
print "Start as7326-platform-monitor-psu.service failed %d"%status
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def start_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl start pddf-platform-init.service")
|
||||
if status:
|
||||
print "Start pddf-platform-init.service failed %d"%status
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def stop_platform_pddf():
|
||||
status, output = commands.getstatusoutput("systemctl stop pddf-platform-init.service")
|
||||
if status:
|
||||
print "Stop pddf-platform-init.service failed %d"%status
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def main():
|
||||
print"stop_platform_svc"
|
||||
stop_platform_svc()
|
||||
#print"start_platform_svc"
|
||||
#start_platform_svc()
|
||||
#print"start_platform_pddf"
|
||||
#start_platform_pddf()
|
||||
print"stop_platform_pddf"
|
||||
stop_platform_pddf()
|
||||
#pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -0,0 +1 @@
|
||||
as7326-56x/sonic_platform-1.0-py3-none-any.whl usr/share/sonic/device/x86_64-accton_as7326_56x-r0/pddf
|
@ -0,0 +1,29 @@
|
||||
# Special arrangement to make PDDF mode default
|
||||
# Disable monitor, monitor-fan, monitor-psu (not enabling them would imply they will be disabled by default)
|
||||
# Enable pddf-platform-monitor
|
||||
|
||||
# Steps to check syseeprom i2c address
|
||||
modprobe i2c-i801
|
||||
modprobe i2c-dev
|
||||
use_57_eeprom=true
|
||||
(i2cget -y -f 0 0x56 0x0) > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
use_57_eeprom=false
|
||||
fi
|
||||
|
||||
if $use_57_eeprom ; then
|
||||
echo "The board has system EEPROM at I2C address 0x57"
|
||||
# syseeprom is at the i2c address 0x57. Change the PDDF JSON file
|
||||
sed -i 's@"topo_info": {"parent_bus": "0x0", "dev_addr": "0x56", "dev_type": "24c04"},@\
|
||||
"topo_info": {"parent_bus": "0x0", "dev_addr": "0x57", "dev_type": "24c02"},@g' \
|
||||
/usr/share/sonic/device/x86_64-accton_as7326_56x-r0/pddf/pddf-device.json
|
||||
sync
|
||||
fi
|
||||
|
||||
depmod -a
|
||||
systemctl enable as7326-platform-handle_mac.service
|
||||
systemctl start as7326-platform-handle_mac.service
|
||||
systemctl enable pddf-platform-init.service
|
||||
systemctl start pddf-platform-init.service
|
||||
systemctl enable as7326-56x-pddf-platform-monitor.service
|
||||
systemctl start as7326-56x-pddf-platform-monitor.service
|
Loading…
Reference in New Issue
Block a user