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

201807 cel #24

Merged
merged 6 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
Expand Up @@ -221,7 +221,7 @@ def get_fans_name_list(self):
for x in range(1, n_fan + 1):
f_index = int(round(float(x)/2))
pos = 1 if x % 2 else 2
fan_name = 'FAN{}-{}'.format(f_index, pos)
fan_name = 'FAN{}_{}'.format(f_index, pos)
fan_names.append(fan_name)

return fan_names
Expand Down Expand Up @@ -291,7 +291,7 @@ def get_all(self):
fan_dict["HighThd"] = fan_sp_list[2]
fan_dict["PN"] = fan_fru_dict[f_index]["PN"]
fan_dict["SN"] = fan_fru_dict[f_index]["SN"]
fan_name = 'FAN{}-{}'.format(f_index, pos)
fan_name = 'FAN{}_{}'.format(f_index, pos)
all_fan_dict[fan_name] = fan_dict
break

Expand Down
130 changes: 130 additions & 0 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/fwmgrutil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# fwmgrutil.py
#
# Platform-specific firmware management interface for SONiC
#

import subprocess
import requests

try:
from sonic_fwmgr.fwgmr_base import FwMgrUtilBase
except ImportError as e:
raise ImportError("%s - required module not found" % str(e))


class FwMgrUtil(FwMgrUtilBase):

"""Platform-specific FwMgrUtil class"""

def __init__(self):
self.platform_name = "AS1332h"
self.onie_config_file = "/host/machine.conf"
self.bmc_info_url = "http://240.1.1.1:8080/api/sys/bmc"
self.onie_config_file = "/host/machine.conf"
self.cpldb_version_path = "/sys/devices/platform/%s.cpldb/getreg" % self.platform_name
self.fpga_version_path = "/sys/devices/platform/%s.switchboard/FPGA/getreg" % self.platform_name
self.switchboard_cpld1_path = "/sys/devices/platform/%s.switchboard/CPLD1/getreg" % self.platform_name
self.switchboard_cpld2_path = "/sys/devices/platform/%s.switchboard/CPLD2/getreg" % self.platform_name

def __get_register_value(self, path, register):
cmd = "echo {1} > {0}; cat {0}".format(path, register)
p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err is not '':
return 'None'
else:
return raw_data.strip()

def get_bmc_version(self):
"""Get BMC version from SONiC
:returns: version string

"""
bmc_version = "None"

bmc_version_key = "OpenBMC Version"
bmc_info_req = requests.get(self.bmc_info_url)
bmc_info_json = bmc_info_req.json()
bmc_info = bmc_info_json.get('Information')
bmc_version = bmc_info.get(bmc_version_key)

return bmc_version

def get_cpld_version(self):
"""Get CPLD version from SONiC
:returns: dict like {'CPLD_1': version_string, 'CPLD_2': version_string}
"""

CPLD_B = self.__get_register_value(self.cpldb_version_path, '0xA100')
CPLD_C = self.__get_register_value(self.cpldb_version_path, '0xA1E0')
CPLD_1 = self.__get_register_value(self.switchboard_cpld1_path, '0x00')
CPLD_2 = self.__get_register_value(self.switchboard_cpld2_path, '0x00')

CPLD_B = 'None' if CPLD_B is 'None' else "{}.{}".format(int(CPLD_B[2],16),int(CPLD_B[3],16))
CPLD_C = 'None' if CPLD_C is 'None' else "{}.{}".format(int(CPLD_C[2],16),int(CPLD_C[3],16))
CPLD_1 = 'None' if CPLD_1 is 'None' else "{}.{}".format(int(CPLD_1[2],16),int(CPLD_1[3],16))
CPLD_2 = 'None' if CPLD_2 is 'None' else "{}.{}".format(int(CPLD_2[2],16),int(CPLD_2[3],16))

cpld_version_dict = {}
cpld_version_dict.update({'CPLD_B':CPLD_B})
cpld_version_dict.update({'CPLD_C':CPLD_C})
cpld_version_dict.update({'CPLD_1':CPLD_1})
cpld_version_dict.update({'CPLD_2':CPLD_2})

return cpld_version_dict

def get_bios_version(self):
"""Get BIOS version from SONiC
:returns: version string

"""
bios_version = 'None'

p = subprocess.Popen(
["sudo", "dmidecode", "-s", "bios-version"], stdout=subprocess.PIPE)
raw_data = str(p.communicate()[0])
raw_data_list = raw_data.split("\n")
bios_version = raw_data_list[0] if len(
raw_data_list) == 1 else raw_data_list[-2]

return bios_version

def get_onie_version(self):
"""Get ONiE version from SONiC
:returns: version string

"""
onie_verison = 'None'

onie_version_keys = "onie_version"
onie_config_file = open(self.onie_config_file, "r")
for line in onie_config_file.readlines():
if onie_version_keys in line:
onie_version_raw = line.split('=')
onie_verison = onie_version_raw[1].strip()
break
return onie_verison

def get_pcie_version(self):
"""Get PCiE version from SONiC
:returns: version string
"""
cmd = "sudo bcmcmd 'pciephy fw version'"
p = subprocess.Popen(cmd,shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
raw_data, err = p.communicate()
if err is not '':
return 'None'
else:
lines = raw_data.split('\n')
version = lines[0].split(':')[1].strip()
return str(version)

def get_fpga_version(self):
"""Get FPGA version from SONiC
:returns: version string

"""
version = self.__get_register_value(self.fpga_version_path, '0x00')
if version is not 'None':
version = "{}.{}".format(int(version[2:][:4],16), int(version[2:][4:],16))
return str(version)
69 changes: 59 additions & 10 deletions device/alibaba/x86_64-alibaba_as13-32h-cl-r0/plugins/sensorutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

__author__ = 'Wirut G.<wgetbumr@celestica.com>'
__license__ = "GPL"
__version__ = "0.1.1"
__version__ = "0.2.0"
__status__ = "Development"

import requests
Expand Down Expand Up @@ -33,8 +33,53 @@ def input_type_selector(self, unit):
"W": "power"
}.get(unit, unit)

def input_name_selector(self, sensor_name, input_name):

self.sensor_name = {
"syscpld-i2c-0-0d": "TEMPERATURE",
"dps1100-i2c-24-58": "PSU1",
"dps1100-i2c-25-59": "PSU2",
"fancpld-i2c-8-0d": "FAN"
}.get(sensor_name, sensor_name)

if 'dps1100' in sensor_name:
input_name = {
"fan1": self.sensor_name + "_FAN",
"iin": self.sensor_name + "_CURR_I",
"iout1": self.sensor_name + "_CURR_O",
"pin": self.sensor_name + "_POWER_I",
"pout1": self.sensor_name + "_POWER_O",
"temp1": self.sensor_name + "_TEMP1",
"temp2": self.sensor_name + "_TEMP2",
"vin": self.sensor_name + "_VOL_I",
"vout1": self.sensor_name + "_VOL_O"
}.get(input_name, input_name)

elif 'tmp75' in sensor_name:
input_name = {
"tmp75-i2c-7-4d": "FTB_INLET_RIGHT",
"tmp75-i2c-7-4c": "FTB_INLET_LEFT",
"tmp75-i2c-7-4b": "FTB_SWITCH_OUTLET",
"tmp75-i2c-7-4a": "BTF_SWITCH_OUTLET",
"tmp75-i2c-39-48": "BTF_INLET_RIGHT",
"tmp75-i2c-39-49": "BTF_INLET_LEFT"
}.get(sensor_name, input_name)
self.sensor_name = "TEMPERATURE"

elif 'fancpld' in sensor_name:
raw_fan_input = input_name.split()
input_name = raw_fan_input[0] + \
raw_fan_input[1] + "_" + raw_fan_input[2]

elif 'ir35' in sensor_name or 'ir38' in sensor_name:
sensor_name_raw = sensor_name.split("-")
sensor_name = sensor_name_raw[0]
self.sensor_name = sensor_name.upper()

return input_name.replace(" ", "_").upper()

def get_num_sensors(self):
"""
"""
Get the number of sensors
:return: int num_sensors
"""
Expand All @@ -53,7 +98,7 @@ def get_num_sensors(self):
return num_sensors

def get_sensor_input_num(self, index):
"""
"""
Get the number of the input items of the specified sensor
:return: int input_num
"""
Expand All @@ -73,7 +118,7 @@ def get_sensor_input_num(self, index):
return input_num

def get_sensor_name(self, index):
"""
"""
Get the device name of the specified sensor.
for example "coretemp-isa-0000"
:return: str sensor_name
Expand All @@ -95,7 +140,7 @@ def get_sensor_name(self, index):

def get_sensor_input_name(self, sensor_index, input_index):
"""
Get the input item name of the specified input item of the
Get the input item name of the specified input item of the
specified sensor index, for example "Physical id 0"
:return: str sensor_input_name
"""
Expand All @@ -120,7 +165,7 @@ def get_sensor_input_name(self, sensor_index, input_index):

def get_sensor_input_type(self, sensor_index, input_index):
"""
Get the item type of the specified input item of the specified sensor index,
Get the item type of the specified input item of the specified sensor index,
The return value should among "valtage","temperature"
:return: str sensor_input_type
"""
Expand Down Expand Up @@ -175,7 +220,7 @@ def get_sensor_input_value(self, sensor_index, input_index):

def get_sensor_input_low_threshold(self, sensor_index, input_index):
"""
Get the low threshold of the value,
Get the low threshold of the value,
the status of this item is not ok if the current value<low_threshold
:return: float sensor_input_low_threshold
"""
Expand Down Expand Up @@ -211,7 +256,7 @@ def get_sensor_input_low_threshold(self, sensor_index, input_index):

def get_sensor_input_high_threshold(self, sensor_index, input_index):
"""
Get the high threshold of the value,
Get the high threshold of the value,
the status of this item is not ok if the current value > high_threshold
:return: float sensor_input_high_threshold
"""
Expand Down Expand Up @@ -253,7 +298,6 @@ def get_all(self):
# Request sensor's information.
self.sensor_info_list = self.request_data()
for sensor_data in self.sensor_info_list:
sensor_name = sensor_data.get('name')
sensor_info = sensor_data.copy()

# Remove none unuse key.
Expand Down Expand Up @@ -283,8 +327,13 @@ def get_all(self):
1000 if str(thres_unit[0]).lower() == 'k' else h_thres
sensor_i_dict["LowThd"] = l_thres * \
1000 if str(thres_unit[0]).lower() == 'k' else l_thres

k = self.input_name_selector(sensor_data.get('name'), k)
sensor_dict[k] = sensor_i_dict

all_sensor_dict[sensor_name] = sensor_dict
if all_sensor_dict.get(self.sensor_name) is None:
all_sensor_dict[self.sensor_name] = dict()

all_sensor_dict[self.sensor_name].update(sensor_dict)

return all_sensor_dict
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def get_fans_name_list(self):
for x in range(1, n_fan + 1):
f_index = int(round(float(x)/2))
pos = 1 if x % 2 else 2
fan_name = 'FAN{}-{}'.format(f_index, pos)
fan_name = 'FAN{}_{}'.format(f_index, pos)
fan_names.append(fan_name)

return fan_names
Expand Down Expand Up @@ -291,7 +291,7 @@ def get_all(self):
fan_dict["HighThd"] = fan_sp_list[2]
fan_dict["PN"] = fan_fru_dict[f_index]["PN"]
fan_dict["SN"] = fan_fru_dict[f_index]["SN"]
fan_name = 'FAN{}-{}'.format(f_index, pos)
fan_name = 'FAN{}_{}'.format(f_index, pos)
all_fan_dict[fan_name] = fan_dict
break

Expand Down
Loading