DellEMC: Z9332f - Component API Fixes (#10187)
This commit is contained in:
parent
c5849c9650
commit
5c7aa50463
@ -90,7 +90,10 @@ class IpmiSensor(object):
|
||||
R_exp = get_twos_complement((factors[6] & 0xF0) >> 4, 4)
|
||||
B_exp = get_twos_complement(factors[6] & 0x0F, 4)
|
||||
|
||||
converted_reading = ((M * raw_value) + (B * 10**B_exp)) * 10**R_exp
|
||||
if R_exp < 0:
|
||||
converted_reading = ((M * raw_value) + (B * 10**B_exp)) / 10**(-R_exp)
|
||||
else:
|
||||
converted_reading = ((M * raw_value) + (B * 10**B_exp)) * 10**R_exp
|
||||
|
||||
return True, converted_reading
|
||||
|
||||
|
@ -45,7 +45,7 @@ function show_help_and_exit()
|
||||
echo " "
|
||||
echo " Available options:"
|
||||
echo " -h, -? : getting this help"
|
||||
echo " -o [fwpkg] : stages the firmware update package"
|
||||
echo " -a [fwpkg] : stages the firmware update package"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
@ -39,7 +39,10 @@ def pci_set_value(resource, val, offset):
|
||||
# Read I2C device
|
||||
|
||||
def i2c_get(bus, i2caddr, ofs):
|
||||
return int(subprocess.check_output(['/usr/sbin/i2cget', '-y', str(bus), str(i2caddr), str(ofs)]), 16)
|
||||
try:
|
||||
return int(subprocess.check_output(['/usr/sbin/i2cget', '-y', str(bus), str(i2caddr), str(ofs)]), 16)
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
return -1
|
||||
|
||||
def io_reg_read(io_resource, offset):
|
||||
fd = os.open(io_resource, os.O_RDONLY)
|
||||
|
@ -23,20 +23,36 @@ except ImportError as e:
|
||||
|
||||
|
||||
def get_bios_version():
|
||||
return subprocess.check_output(
|
||||
['dmidecode', '-s', 'bios-version']).decode('utf-8').strip()
|
||||
try:
|
||||
return subprocess.check_output(['dmidecode', '-s', 'bios-version'],
|
||||
text=True).strip()
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
return 'NA'
|
||||
|
||||
def get_fpga_version():
|
||||
val = hwaccess.pci_get_value('/sys/bus/pci/devices/0000:09:00.0/resource0', 0)
|
||||
return '{}.{}'.format((val >> 16) & 0xffff, val & 0xffff)
|
||||
|
||||
def get_bmc_version():
|
||||
return subprocess.check_output(
|
||||
['cat', '/sys/class/ipmi/ipmi0/device/bmc/firmware_revision']
|
||||
).decode('utf-8').strip()
|
||||
val = 'NA'
|
||||
try:
|
||||
bmc_ver = subprocess.check_output(['ipmitool', 'mc', 'info'],
|
||||
stderr=subprocess.STDOUT, text=True)
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
pass
|
||||
else:
|
||||
version = re.search(r'Firmware Revision\s*:\s(.*)', bmc_ver)
|
||||
if version:
|
||||
val = version.group(1).strip()
|
||||
|
||||
return val
|
||||
|
||||
def get_cpld_version(bus, i2caddr):
|
||||
return '{}'.format(hwaccess.i2c_get(bus, i2caddr, 0))
|
||||
val = hwaccess.i2c_get(bus, i2caddr, 0)
|
||||
if val != -1:
|
||||
return '{:x}.{:x}'.format((val >> 4) & 0xf, val & 0xf)
|
||||
else:
|
||||
return 'NA'
|
||||
|
||||
def get_cpld0_version():
|
||||
return get_cpld_version(5, 0x0d)
|
||||
@ -69,7 +85,7 @@ def get_pciephy_version():
|
||||
except (FileNotFoundError, subprocess.CalledProcessError):
|
||||
pass
|
||||
else:
|
||||
version = re.search(r'PCIe FW loader version:\s(.*)', pcie_ver)
|
||||
version = re.search(r'PCIe FW version:\s(.*)', pcie_ver)
|
||||
if version:
|
||||
val = version.group(1).strip()
|
||||
|
||||
@ -158,6 +174,14 @@ class Component(ComponentBase):
|
||||
|
||||
ver_info = ver_info.get("x86_64-dellemc_z9332f_d1508-r0")
|
||||
if ver_info:
|
||||
components = list(ver_info.keys())
|
||||
for component in components:
|
||||
if "CPLD" in component and ver_info[component].get('version'):
|
||||
val = ver_info.pop(component)
|
||||
ver = int(val['version'], 16)
|
||||
val['version'] = "{:x}.{:x}".format((ver >> 4) & 0xf, ver & 0xf)
|
||||
ver_info[component.replace("-", " ")] = val
|
||||
|
||||
return True, ver_info
|
||||
else:
|
||||
return False, "ERROR: Version info not available"
|
||||
|
Loading…
Reference in New Issue
Block a user