79 lines
2.8 KiB
Python
79 lines
2.8 KiB
Python
import os
|
|
import utils
|
|
import json
|
|
|
|
project_root = utils.get_project_root()
|
|
cache_dir = os.path.join(project_root, "tmp")
|
|
log_dir = os.path.join(cache_dir, "onekeylog")
|
|
|
|
component_dir = os.path.join(log_dir, "component")
|
|
component_file = os.path.join(component_dir, "component.log")
|
|
baseinfo_file = os.path.join(cache_dir, "baseinfo.txt")
|
|
|
|
def get_fw_version_info():
|
|
fw_version_line = 3
|
|
if not os.path.exists(component_file):
|
|
print("no component.log found")
|
|
return
|
|
|
|
fw_version_info = utils.read_specific_line(component_file, fw_version_line)
|
|
json_fw_info = json.loads(fw_version_info)
|
|
|
|
version_str = "\nDPU Firmware Version Info:\n"
|
|
version_str += f"BMC Version : {json_fw_info[0]['dev_version']}\n"
|
|
version_str += f"Bios Version : {json_fw_info[2]['dev_version']}\n"
|
|
version_str += f"ME Version : {json_fw_info[3]['dev_version']}\n"
|
|
version_str += f"Soc_CPLD Version : {json_fw_info[4]['dev_version']}\n"
|
|
version_str += f"Fpga_CPLD Version : {json_fw_info[5]['dev_version']}\n"
|
|
version_str += f"FPGA Version : {json_fw_info[6]['dev_version']}\n"
|
|
|
|
print(version_str)
|
|
utils.append_to_file(baseinfo_file, version_str)
|
|
|
|
def get_fru_info():
|
|
fru_line = 19
|
|
if not os.path.exists(component_file):
|
|
print("no component.log found")
|
|
return
|
|
fru_info = utils.read_specific_line(component_file, fru_line)
|
|
json_fru_info = json.loads(fru_info)
|
|
|
|
fru_str = "\nDPU FRU Infomation:\n"
|
|
fru_str += f"Board Product Name : {json_fru_info[0]['board']['product_name']}\n"
|
|
fru_str += f"Board SN : {json_fru_info[0]['board']['serial_number']}\n"
|
|
fru_str += f"Board PartNumber : {json_fru_info[0]['board']['part_number']}\n"
|
|
fru_str += f"Server Product Name : {json_fru_info[0]['product']['product_name']}\n"
|
|
fru_str += f"Server Product Ver : {json_fru_info[0]['product']['product_version']}\n"
|
|
fru_str += f"Server Product SN : {json_fru_info[0]['product']['serial_number']}\n"
|
|
fru_str += f"Server Custom Field : {json_fru_info[0]['product']['custom_fields-1']}\n"
|
|
|
|
print(fru_str)
|
|
utils.append_to_file(baseinfo_file, fru_str)
|
|
|
|
# def get_hardware_info():
|
|
# hw_cpu_info_line = 5
|
|
# if not os.path.exists(component_file):
|
|
# print("no component.log found")
|
|
# return
|
|
# cpu_info = read_specific_line(component_file, hw_cpu_info_line)
|
|
# json_cpu_info = json.loads(cpu_info)
|
|
|
|
# hw_info_str = "\nDPU Hardware Infomation:\n"
|
|
|
|
|
|
def program_main():
|
|
get_fw_version_info()
|
|
get_fru_info()
|
|
# get_hardware_info()
|
|
|
|
return True
|
|
|
|
def get_all_infostring():
|
|
return utils.read_file_to_string(baseinfo_file)
|
|
|
|
if __name__ == "__main__":
|
|
get_fw_version_info()
|
|
|
|
|
|
|
|
|