Fix Semgrep check
This commit is contained in:
parent
f3637e4a32
commit
045a8df6f0
@ -3,19 +3,19 @@
|
||||
"name": "7726-32X",
|
||||
"components": [
|
||||
{
|
||||
"name": "CPLD1"
|
||||
"name": "MB CPLD1"
|
||||
},
|
||||
{
|
||||
"name": "CPLD2"
|
||||
"name": "MB CPLD2"
|
||||
},
|
||||
{
|
||||
"name": "CPLD3"
|
||||
"name": "MB CPLD3"
|
||||
},
|
||||
{
|
||||
"name": "CPLD4"
|
||||
"name": "FAN CPLD"
|
||||
},
|
||||
{
|
||||
"name": "CPLD5"
|
||||
"name": "CPU CPLD"
|
||||
},
|
||||
{
|
||||
"name": "BIOS"
|
||||
@ -156,26 +156,26 @@
|
||||
],
|
||||
"thermals": [
|
||||
{
|
||||
"name": "PSU-2 temp sensor 2"
|
||||
"name": "PSU-2 temp sensor 1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"thermals": [
|
||||
{
|
||||
"name": "Temp sensor 1"
|
||||
"name": "CB_temp(0x4B)"
|
||||
},
|
||||
{
|
||||
"name": "Temp sensor 2"
|
||||
"name": "FB_temp(0x4C)"
|
||||
},
|
||||
{
|
||||
"name": "Temp sensor 3"
|
||||
"name": "MB_FrontMAC_temp(0x49)"
|
||||
},
|
||||
{
|
||||
"name": "Temp sensor 4"
|
||||
"name": "MB_LeftCenter_temp(0x4A)"
|
||||
},
|
||||
{
|
||||
"name": "Temp sensor 5"
|
||||
"name": "MB_RearMAC_temp(0x48)"
|
||||
},
|
||||
{
|
||||
"name": "CPU Temp"
|
||||
|
@ -12,19 +12,20 @@ except ImportError as e:
|
||||
raise ImportError(str(e) + "- required module not found")
|
||||
|
||||
CPLD_ADDR_MAPPING = {
|
||||
"CPLD1": ['11', '0x60'],
|
||||
"CPLD2": ['12', '0x62'],
|
||||
"CPLD3": ['13', '0x64'],
|
||||
"CPLD4": ['54', '0x66']
|
||||
"MB CPLD1": ['11', '0x60'],
|
||||
"MB CPLD2": ['12', '0x62'],
|
||||
"MB CPLD3": ['13', '0x64'],
|
||||
"FAN CPLD": ['54', '0x66'],
|
||||
"CPU CPLD": ['0', '0x65'],
|
||||
}
|
||||
SYSFS_PATH = "/sys/bus/i2c/devices/"
|
||||
BIOS_VERSION_PATH = "/sys/class/dmi/id/bios_version"
|
||||
COMPONENT_LIST= [
|
||||
("CPLD1", "CPLD 1"),
|
||||
("CPLD2", "CPLD 2"),
|
||||
("CPLD3", "CPLD 3"),
|
||||
("CPLD4", "CPLD 4"),
|
||||
("CPLD5", "CPLD 5"),
|
||||
("MB CPLD1", "Mainboard CPLD 1"),
|
||||
("MB CPLD2", "Mainboard CPLD 2"),
|
||||
("MB CPLD3", "Mainboard CPLD 3"),
|
||||
("FAN CPLD", "Fan board CPLD"),
|
||||
("CPU CPLD", "CPU CPLD"),
|
||||
("BIOS", "Basic Input/Output System")
|
||||
|
||||
]
|
||||
@ -38,22 +39,6 @@ class Component(ComponentBase):
|
||||
self.index = component_index
|
||||
self.name = self.get_name()
|
||||
|
||||
def __run_command(self, command):
|
||||
# Run bash command and print output to stdout
|
||||
try:
|
||||
process = subprocess.Popen(
|
||||
shlex.split(command), stdout=subprocess.PIPE)
|
||||
while True:
|
||||
output = process.stdout.readline()
|
||||
if output == '' and process.poll() is not None:
|
||||
break
|
||||
rc = process.poll()
|
||||
if rc != 0:
|
||||
return False
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
def __get_bios_version(self):
|
||||
# Retrieves the BIOS firmware version
|
||||
try:
|
||||
@ -75,21 +60,6 @@ class Component(ComponentBase):
|
||||
|
||||
return cpld_version
|
||||
|
||||
|
||||
def __get_cpld_cpu_version(self):
|
||||
try:
|
||||
cpu_version = dict()
|
||||
cmd = "i2cget -f -y 0 0x65 0x01"
|
||||
status, output1 = subprocess.getstatusoutput(cmd)
|
||||
if status == 0 :
|
||||
cpu_version = "{}".format(output1[2:])
|
||||
else :
|
||||
cpu_version = 'None'
|
||||
except Exception as e:
|
||||
cpu_version = 'None'
|
||||
|
||||
return cpu_version
|
||||
|
||||
def get_name(self):
|
||||
"""
|
||||
Retrieves the name of the component
|
||||
@ -116,8 +86,6 @@ class Component(ComponentBase):
|
||||
|
||||
if self.name == "BIOS":
|
||||
fw_version = self.__get_bios_version()
|
||||
elif "CPLD5" in self.name:
|
||||
fw_version = self.__get_cpld_cpu_version()
|
||||
elif "CPLD" in self.name:
|
||||
cpld_version = self.__get_cpld_version()
|
||||
fw_version = cpld_version.get(self.name)
|
||||
|
@ -4,7 +4,7 @@ import subprocess
|
||||
from mmap import *
|
||||
from sonic_py_common import device_info
|
||||
|
||||
HOST_CHK_CMD = "docker > /dev/null 2>&1"
|
||||
HOST_CHK_CMD = ["docker"]
|
||||
EMPTY_STRING = ""
|
||||
|
||||
|
||||
@ -14,7 +14,11 @@ class APIHelper():
|
||||
(self.platform, self.hwsku) = device_info.get_platform_and_hwsku()
|
||||
|
||||
def is_host(self):
|
||||
return os.system(HOST_CHK_CMD) == 0
|
||||
try:
|
||||
status, output = getstatusoutput_noshell(HOST_CHK_CMD)
|
||||
return status == 0
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
def pci_get_value(self, resource, offset):
|
||||
status = True
|
||||
@ -29,26 +33,6 @@ class APIHelper():
|
||||
status = False
|
||||
return status, result
|
||||
|
||||
def run_command(self, cmd):
|
||||
status = True
|
||||
result = ""
|
||||
try:
|
||||
p = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
raw_data, err = p.communicate()
|
||||
if err == '':
|
||||
result = raw_data.strip()
|
||||
except Exception:
|
||||
status = False
|
||||
return status, result
|
||||
|
||||
def run_interactive_command(self, cmd):
|
||||
try:
|
||||
os.system(cmd)
|
||||
except Exception:
|
||||
return False
|
||||
return True
|
||||
|
||||
def read_txt_file(self, file_path):
|
||||
try:
|
||||
with open(file_path, 'r', errors='replace') as fd:
|
||||
@ -65,53 +49,3 @@ class APIHelper():
|
||||
except IOError:
|
||||
return False
|
||||
return True
|
||||
|
||||
def ipmi_raw(self, netfn, cmd):
|
||||
status = True
|
||||
result = ""
|
||||
try:
|
||||
cmd = "ipmitool raw {} {}".format(str(netfn), str(cmd))
|
||||
p = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
raw_data, err = p.communicate()
|
||||
if err == '':
|
||||
result = raw_data.strip()
|
||||
else:
|
||||
status = False
|
||||
except Exception:
|
||||
status = False
|
||||
return status, result
|
||||
|
||||
def ipmi_fru_id(self, id, key=None):
|
||||
status = True
|
||||
result = ""
|
||||
try:
|
||||
cmd = "ipmitool fru print {}".format(str(
|
||||
id)) if not key else "ipmitool fru print {0} | grep '{1}' ".format(str(id), str(key))
|
||||
|
||||
p = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
raw_data, err = p.communicate()
|
||||
if err == '':
|
||||
result = raw_data.strip()
|
||||
else:
|
||||
status = False
|
||||
except Exception:
|
||||
status = False
|
||||
return status, result
|
||||
|
||||
def ipmi_set_ss_thres(self, id, threshold_key, value):
|
||||
status = True
|
||||
result = ""
|
||||
try:
|
||||
cmd = "ipmitool sensor thresh '{}' {} {}".format(str(id), str(threshold_key), str(value))
|
||||
p = subprocess.Popen(
|
||||
cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
raw_data, err = p.communicate()
|
||||
if err == '':
|
||||
result = raw_data.strip()
|
||||
else:
|
||||
status = False
|
||||
except Exception:
|
||||
status = False
|
||||
return status, result
|
||||
|
@ -14,11 +14,20 @@ class Thermal(PddfThermal):
|
||||
def __init__(self, index, pddf_data=None, pddf_plugin_data=None, is_psu_thermal=False, psu_index=0):
|
||||
PddfThermal.__init__(self, index, pddf_data, pddf_plugin_data, is_psu_thermal, psu_index)
|
||||
|
||||
self.pddf_obj = pddf_data
|
||||
self.thermal_obj_name = "TEMP{}".format(self.thermal_index)
|
||||
self.thermal_obj = self.pddf_obj.data[self.thermal_obj_name]
|
||||
|
||||
# Provide the functions/variables below for which implementation is to be overwritten
|
||||
def get_name(self):
|
||||
if self.is_psu_thermal:
|
||||
return "PSU-{0} temp sensor 1".format(self.thermals_psu_index)
|
||||
else:
|
||||
if 'dev_attr' in self.thermal_obj.keys():
|
||||
if 'display_name' in self.thermal_obj['dev_attr']:
|
||||
return str(self.thermal_obj['dev_attr']['display_name'])
|
||||
|
||||
# In case of errors
|
||||
return "Temp sensor {0}".format(self.thermal_index)
|
||||
|
||||
def get_status(self):
|
||||
|
Reference in New Issue
Block a user