一、IPMI RAW格式转化
IPMItool在使用时有两种命令格式,字符串 形式 (如 chassis status )或十六进制的原始代码RAW形式 (如 raw 0x00 0x01 。 )
RAW格式常用于修改特定的FRU或者厂商内部设定的功能选项。
针对FRU信息的转化,使用python编写了一个从ASCII转成HEX(RAW格式)的小工具。
二、Python源码
import csv
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
with open("log.csv", "w", encoding="utf-8", newline='') as csvfile:
fieldnames = ['ASCII', 'HEX']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writeheader()
csvfile.close()
with open('FRU_ASCII.csv') as f:
reader = csv.reader(f)
print("打开FRU_ASCII获取服务器FRU信息")
for row in reader:
if row:
FRU_ASCII = (str(row[0]))
FRU_HEX= ' '.join(hex(ord(i)) for i in row[0])
print(FRU_ASCII,FRU_HEX)
with open("log.csv", "a+", encoding="utf-8", newline='') as csvfile:
fieldnames = ['ASCII', 'HEX']
writer = csv.DictWriter(csvfile, fieldnames=fieldnames)
writer.writerow({'ASCII': str(FRU_ASCII),'HEX': FRU_HEX})
continue
FRU_ASCII=FRU_HEX="NA"
Over = input("""
*************************************程序执行结束,请按回车键退出!****************************************
""")