update bmc test scripts
This commit is contained in:
parent
135cb1b56a
commit
f150bcc489
16
04.bmc_self_test/config.json
Normal file
16
04.bmc_self_test/config.json
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"Proj_name":"ZiJin",
|
||||
"BMCIP":"100.2.76.193",
|
||||
"BMC_USER":"ADMIN",
|
||||
"BMC_PW":"ADMIN",
|
||||
"OS_USER":"root",
|
||||
"OS_PW":"Inspur@123",
|
||||
"IPMI":"Enable",
|
||||
"ipmi_module":{
|
||||
"ipmi_mc":"Enable"
|
||||
},
|
||||
"REDFISH":"Enable",
|
||||
"redfish_module":{
|
||||
"redfish_fru":"Enable"
|
||||
}
|
||||
}
|
||||
1
04.bmc_self_test/ipmi/ipmi_mc.py
Normal file
1
04.bmc_self_test/ipmi/ipmi_mc.py
Normal file
@ -0,0 +1 @@
|
||||
import os
|
||||
5
04.bmc_self_test/ipmi/ipmi_test.py
Normal file
5
04.bmc_self_test/ipmi/ipmi_test.py
Normal file
@ -0,0 +1,5 @@
|
||||
import os
|
||||
import ipmi_mc
|
||||
|
||||
def start_ipmi_test(conf):
|
||||
return
|
||||
53
04.bmc_self_test/main.py
Normal file
53
04.bmc_self_test/main.py
Normal file
@ -0,0 +1,53 @@
|
||||
import os
|
||||
import datetime
|
||||
import settings
|
||||
from ipmi.ipmi_test import start_ipmi_test
|
||||
from redfish.redfish_test import start_redfish_test
|
||||
|
||||
LOG_FILE="result.log"
|
||||
CONFIG_FILE="config.json"
|
||||
|
||||
def append_log(message):
|
||||
timestamp=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
||||
|
||||
with open(LOG_FILE, '+a') as file:
|
||||
file.write("{} | ".format(timestamp) + message)
|
||||
|
||||
|
||||
def prepare_env():
|
||||
|
||||
# check if log present,then clean it
|
||||
if os.path.exists(LOG_FILE) == True:
|
||||
os.unlink(LOG_FILE)
|
||||
|
||||
append_log("Clean the log file!\n")
|
||||
# get configuration from file system
|
||||
conf = settings.configuration(CONFIG_FILE)
|
||||
conf.get_config()
|
||||
conf.parse_general_config()
|
||||
conf.parse_ipmi_config()
|
||||
conf.parse_redfish_config()
|
||||
|
||||
return conf
|
||||
|
||||
def proc_ipmi_test(conf):
|
||||
|
||||
if conf.is_enable_ipmi_test == "Enable":
|
||||
append_log("Enable IPMI Module Test\n")
|
||||
start_ipmi_test(conf)
|
||||
else:
|
||||
append_log("Disable IPMI Module Test\n")
|
||||
|
||||
|
||||
def proc_redfish_test(conf):
|
||||
|
||||
if conf.is_enable_redfish_test == "Enable":
|
||||
append_log("Enable IPMI Module Test\n")
|
||||
start_redfish_test(conf)
|
||||
else:
|
||||
append_log("Disable IPMI Module Test\n")
|
||||
|
||||
if __name__=="__main__":
|
||||
conf = prepare_env()
|
||||
proc_ipmi_test(conf)
|
||||
proc_redfish_test(conf)
|
||||
1
04.bmc_self_test/redfish/redfish_fru.py
Normal file
1
04.bmc_self_test/redfish/redfish_fru.py
Normal file
@ -0,0 +1 @@
|
||||
import os
|
||||
4
04.bmc_self_test/redfish/redfish_test.py
Normal file
4
04.bmc_self_test/redfish/redfish_test.py
Normal file
@ -0,0 +1,4 @@
|
||||
import os
|
||||
|
||||
def start_redfish_test(conf):
|
||||
return
|
||||
28
04.bmc_self_test/settings.py
Normal file
28
04.bmc_self_test/settings.py
Normal file
@ -0,0 +1,28 @@
|
||||
import os
|
||||
import json
|
||||
from main import append_log as add_log
|
||||
|
||||
class configuration:
|
||||
|
||||
def __init__(self, _conf_file) :
|
||||
self.conf_file = _conf_file
|
||||
|
||||
def get_config(self):
|
||||
add_log("Start Parse Configuration, file : {}\n".format(self.conf_file))
|
||||
|
||||
with open(self.conf_file, 'r') as jsonfile:
|
||||
self.conf_data = json.load(jsonfile)
|
||||
|
||||
def parse_general_config(self):
|
||||
self.Proj_name = self.conf_data['Proj_name']
|
||||
self.BMCIP = self.conf_data['BMCIP']
|
||||
self.BMC_USER = self.conf_data['BMC_USER']
|
||||
self.BMC_PW = self.conf_data['BMC_PW']
|
||||
self.OS_USER = self.conf_data['OS_USER']
|
||||
self.OS_PW = self.conf_data['OS_PW']
|
||||
|
||||
def parse_ipmi_config(self):
|
||||
self.is_enable_ipmi_test = self.conf_data['IPMI']
|
||||
|
||||
def parse_redfish_config(self):
|
||||
self.is_enable_redfish_test = self.conf_data['REDFISH']
|
||||
Loading…
Reference in New Issue
Block a user