程序执行到那里时,我的程序中有一个处理程序:
def ipmi_handler(data):
action = data.get('action')
if action == STATUS:
try:
ipmi_data = data.get('data')
msg = ipmi_status(ipmi_data.get('ipmi_addr'), ipmi_data.get('bmc_uname'), ipmi_data.get('bmc_pwd'))
return msg
except Exception as e:
return e
def ipmi_status(ipmi_addr, bmc_uname='ADMIN', bmc_pwd='ADMIN'):
message = os.system('ipmitool -H ' + ipmi_addr + ' -I lanplus -U ' + bmc_uname + ' -P ' + bmc_pwd + ' power ' + STATUS)
return message
此行:
msg = ipmi_status(ipmi_data.get('ipmi_addr'), ipmi_data.get('bmc_uname'), ipmi_data.get('bmc_pwd'))
ipmi_status()
函数将在CentOS终端中打印日志:
Chassis Power is on
并且在我想使用msg
接收日志之前,但是失败了,只能得到0
:
msg = ipmi_status(ipmi_data.get('ipmi_addr'), ipmi_data.get('bmc_uname'), ipmi_data.get('bmc_pwd'))
如何在其中获取日志?