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)