Пример #1
0
 def c_check_node_present_via_ipmi(self):
     global Present_Node
     global NODE_INFO_DICT
     global CASE_PASS
     is_FAIL = False
     temp_text = "- Check Node present via IPMI -"
     CMM.show_message(format_item(temp_text),color="green",timestamp=False)
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     message = temp_text.strip(" -")
     for node_id in range(NODE_NUM):
         NODE_INFO_DICT["Node{0}".format(node_id + 1)] = {}
         temp = check_node_Present(node_id)
         if temp == "01":
             Present_Node.append(node_id+1)
             CMM.show_message("Node{0} is present".format(node_id+1),timestamp=False)
             NODE_INFO_DICT["Node{0}".format(node_id + 1)]["Present"] = "Y"
         elif temp == "00":
             CMM.show_message("Node{0} is not present".format(node_id+1),timestamp=False)
             NODE_INFO_DICT["Node{0}".format(node_id + 1)]["Present"] = "N"
         else:
             is_FAIL = True
             NODE_INFO_DICT["Node{0}".format(node_id + 1)]["Present"] = "Unknown"
     if is_FAIL:
         CASE_PASS = False
         show_step_result(message,"FAIL")
         CMM.save_step_result(main_log,message,"FAIL")
     else:
         show_step_result(message,"PASS")
         CMM.save_step_result(main_log,message,"PASS")
 def c_curl_login(self):
     global CASE_PASS
     global LOGIN_FAIL
     global CSRFToken
     if DOWNLOAD_FW_FAIL:
         LOGIN_FAIL = True
         return False
     CMM.show_message(format_item("Login Web"),
                      color="green",
                      timestamp=False)
     status, output = CMM.curl_login_logout(IP,
                                            flag="login",
                                            username=USERNAME,
                                            password=PASSWORD)
     if status == 0:
         message = "[curl] Login Web successfully."
         CMM.save_data(main_log, message, timestamp=False)
         show_step_result("[curl] Login Web", flag="PASS")
         CSRFToken = output.strip()
     else:
         CASE_PASS = False
         message = "[curl] Login Web FAIL !"
         MAIN_LOG_list.append(message)
         message = "{0}\n{1}".format(message, output)
         CMM.save_data(main_log, message, timestamp=False)
         show_step_result("[curl] Login Web", flag="FAIL")
         LOGIN_FAIL = True
 def c_get_psu_via_ipmi(self):
     global Present_psu
     global IPMI_PSU_INFO
     global IPMI_PSU_FAIL
     global CASE_PASS
     temp_text = "- Get PSU info via IPMI -"
     CMM.show_message(format_item(temp_text),color="green",timestamp=False)
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     for psu_id in range(1,int(PSU_NUM)+1):
         psu = "PSU{0}".format(psu_id)
         is_fail = False
         OEM_psuIndex, OEM_pwrState, OEM_statusWord, OEM_pout, OEM_pin, OEM_vout, OEM_vin, OEM_iout, OEM_iin, \
         OEM_temperature1, OEM_temperature2, OEM_fanSpeed, OEM_fanDuty, OEM_vendor, OEM_psuModel, \
         OEM_psuSN = ["Unknown"] * 16
         OEM_info = GetPSUInfoViaOEM(psu_id)
         if OEM_info:
             temp_list = OEM_info.split()
             OEM_Present = parse_Present(temp_list)
             if OEM_Present[1] == 1:
                 Present_psu.append(psu_id)
                 OEM_isPSUOn = parse_isPSUOn(temp_list)
                 if OEM_isPSUOn == "ON":
                     OEM_pwrState = 2
                 elif OEM_isPSUOn == "OFF":
                     OEM_pwrState = 1
             else:
                 OEM_pwrState = 0
             OEM_statusWord = parse_statusWord(temp_list)
             OEM_psuIndex = parse_id(temp_list)
             OEM_pout = parse_Pout(temp_list)
             OEM_pin = parse_Pin(temp_list)
             OEM_vout = parse_Vout(temp_list)
             OEM_vin = parse_Vin(temp_list)
             OEM_iout = parse_Iout(temp_list)
             OEM_iin = parse_Iin(temp_list)
             temp = parse_Temp(temp_list)
             OEM_temperature1 = temp[0] if isinstance(temp,tuple) else temp
             OEM_temperature2 = temp[1] if isinstance(temp,tuple) else temp
             OEM_fanSpeed = parse_Fan1Speed(temp_list)
             OEM_fanDuty = parse_FanDuty(temp_list)
             OEM_vendor = parse_Vendor(temp_list)
             OEM_psuModel = parse_Model(temp_list)
             OEM_psuSN = parse_SN(temp_list)
         else:
             is_fail = True
             IPMI_PSU_FAIL = True
         IPMI_PSU_INFO.append([OEM_psuIndex, OEM_pwrState, OEM_statusWord, OEM_pout, OEM_pin, OEM_vout, OEM_vin, OEM_iout, OEM_iin,OEM_temperature1, OEM_temperature2, OEM_fanSpeed, OEM_fanDuty, OEM_vendor,OEM_psuModel, OEM_psuSN])
         temp_text = "[{0}] IPMI info".format(psu)
         if is_fail:
             CASE_PASS = False
             CMM.save_step_result(main_log, temp_text, "FAIL")
             show_step_result(temp_text, "FAIL")
             MAIN_LOG_list.append("{0} FAIL !".format(temp_text))
         else:
             CMM.save_step_result(main_log, temp_text, "PASS")
             show_step_result(temp_text, "PASS")
     CMM.save_data(main_log, "IPMI PSU info list\n{0}".format(IPMI_PSU_INFO), timestamp=False)
 def d_set_fan_duty_via_OEM(self):
     global CASE_PASS
     temp_text = "- Set FAN duty via OEM command -"
     CMM.show_message(format_item(temp_text),
                      color="green",
                      timestamp=False)
     CMM.save_data(main_log, temp_text, timestamp=False)
     MAIN_LOG_list.append(temp_text)
     # Switched manual mode
     status, output = CMM.retry_run_cmd(MANUAL_MODE_CMD)
     if status != 0:
         CASE_PASS = False
         fail_text = "[FAIL] Set cooling policy to manual mode."
         MAIN_LOG_list.append(fail_text)
         CMM.save_data(main_log, "{0}\n{1}".format(temp_text, output))
         show_step_result("Set cooling policy to manual mode", flag="FAIL")
         return False
     else:
         show_step_result("Set cooling policy to manual mode", flag="PASS")
     # Set and check FAN Duty
     Duty_fail = False
     Duty_list = [30, 40, 50, 60, 70, 80, 90, 100]
     temp_text = "Set and check FAN Duty: {0}".format(Duty_list)
     CMM.save_data(main_log, temp_text, timestamp=False)
     CMM.show_message(temp_text, timestamp=False, color="blue")
     for id in range(1, int(FAN_NUM) + 1):
         for Duty in Duty_list:
             SetFanDutyViaOEM(id, Duty)
             time.sleep(10)
             duty_pass, FanSpeed = CheckFanDuty(id, Duty)
             message = "FAN{0}_Duty{1}:{2}".format(id, Duty, FanSpeed)
             CMM.show_message(message, timestamp=False)
             CMM.save_data(MAIN_LOG, message, timestamp=False)
             if not duty_pass:
                 Duty_fail = True
     if Duty_fail:
         CASE_PASS = False
         show_step_result("Set and check FAN Duty", flag="FAIL")
         CMM.save_data(main_log,
                       "[FAIL] Set and check FAN Duty",
                       timestamp=False)
         MAIN_LOG_list.append("[FAIL] Set and check FAN Duty")
     else:
         show_step_result("Set and check FAN Duty", flag="PASS")
         CMM.save_data(main_log,
                       "[PASS] Set and check FAN Duty",
                       timestamp=False)
     # Restored auto mode
     status, output = CMM.retry_run_cmd(AUTO_MODE_CMD)
     if status != 0:
         CASE_PASS = False
         fail_text = "[FAIL] Set cooling policy to auto mode."
         MAIN_LOG_list.append(fail_text)
         CMM.save_data(main_log, "{0}\n{1}".format(temp_text, output))
         show_step_result("Set cooling policy to auto mode", flag="FAIL")
         return False
     else:
         show_step_result("Set cooling policy to auto mode", flag="PASS")
 def d_check_all_psu_pout_via_API(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     is_FAIL = False
     temp_text = "- Check all psu pout via API -"
     CMM.show_message(format_item(temp_text), color="green", timestamp=False)
     CMM.save_data(main_log, temp_text, timestamp=False)
     MAIN_LOG_list.append(temp_text)
     message = temp_text.strip(" -")
     json_data = getAllPsus()
     if json_data:
         if len(json_data) != PSU_NUM:
             is_FAIL = True
             MAIN_LOG_list.append("{0}".format(json_data))
             CMM.show_message("{0}".format(json_data),timestamp=False,color="red")
         else:
             for psu_id in range(1,PSU_NUM+1):
                 API_info = GetPSUInfoViaAPI(CSRFToken,psu_id)
                 expect_pout = API_info.get("Pout")
                 if not API_info:
                     is_FAIL = True
                 for item in json_data:
                     get_id = item.get("id")
                     if get_id == psu_id:
                         get_pout = item.get("Pout")
                         if get_id in Present_psu:
                             temp_pout = abs(int(get_pout)-int(expect_pout))
                             """ 两种方式的差值小于等于单一Node检测值的二分之一 即为PASS """
                             if temp_pout > int(expect_pout)/2:
                                 is_FAIL = True
                                 text = "[/cmminfo/psus] PSU{0} {1}".format(psu_id,expect_pout)
                                 MAIN_LOG_list.append(text)
                                 CMM.show_message(text,timestamp=False,color="red")
                                 CMM.save_data(main_log,text,timestamp=False)
                                 text = "[/cmmpower/allpsus] PSU{0} {1}".format(psu_id,get_pout)
                                 MAIN_LOG_list.append(text)
                                 CMM.show_message(text,timestamp=False,color="red")
                                 CMM.save_data(main_log,text,timestamp=False)
                         else:
                             if get_pout != "":
                                 is_FAIL = True
                                 text = "[PSU{0}] {1}".format(psu_id,get_pout)
                                 MAIN_LOG_list.append(text)
                                 CMM.show_message(text,timestamp=False,color="red")
                         break
                 else:
                     is_FAIL = True
     else:
         is_FAIL = True
     if is_FAIL:
         CASE_PASS = False
         show_step_result(message, flag="FAIL")
         CMM.save_step_result(main_log, message, flag="FAIL")
     else:
         show_step_result(message, flag="PASS")
         CMM.save_step_result(main_log, message, flag="PASS")
Пример #6
0
 def c_get_switch_via_ipmi(self):
     global Present_switch
     global IPMI_SWITCH_INFO
     global IPMI_SWITCH_FAIL
     global CASE_PASS
     temp_text = "- Get Switch info via IPMI -"
     CMM.show_message(format_item(temp_text),color="green",timestamp=False)
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     for switch_id in range(1,int(SWITCH_NUM)+1):
         switch = "Switch{0}".format(switch_id)
         is_fail = False
         OEM_switchIndex, OEM_switchState, OEM_switchType, OEM_temperature, OEM_pwrConsump, \
         OEM_ip, OEM_netmask, OEM_gateway, OEM_vendor = ["Unknown"] * 9
         OEM_info = GetSwitchInfoViaOEM(switch_id)
         if OEM_info:
             temp_list = OEM_info.split()
             OEM_Present = parse_Present(temp_list)
             if OEM_Present[1] == 1:
                 Present_switch.append(switch_id)
                 OEM_Power = parse_Status(temp_list)
                 if OEM_Power == "Power On":
                     OEM_switchState = 2
                 elif OEM_Power == "Power Off":
                     OEM_switchState = 1
                 elif OEM_Power == "Communication Lost":
                     OEM_switchState = 7
                 elif OEM_Power == "Over Temp":
                     OEM_switchState = 3
             else:
                 OEM_switchState = 0
             OEM_switchIndex = parse_id(temp_list)
             temp = temp_list[19]
             OEM_switchType = int(temp,16)
             OEM_temperature = parse_Temperature(temp_list)
             OEM_pwrConsump = parse_Pwr_consump(temp_list)
             OEM_ip = parse_IP(temp_list)
             OEM_netmask = parse_Netmask(temp_list)
             OEM_gateway = parse_Gateway(temp_list)
             OEM_vendor = parse_Vendor(temp_list)
         else:
             is_fail = True
             IPMI_SWITCH_FAIL = True
         IPMI_SWITCH_INFO.append([OEM_switchIndex, OEM_switchState, OEM_switchType, OEM_temperature, OEM_pwrConsump,
                                  OEM_ip, OEM_netmask, OEM_gateway, OEM_vendor])
         temp_text = "[{0}] IPMI info".format(switch)
         if is_fail:
             CASE_PASS = False
             CMM.save_step_result(main_log, temp_text, "FAIL")
             show_step_result(temp_text, "FAIL")
             MAIN_LOG_list.append("{0} FAIL !".format(temp_text))
         else:
             CMM.save_step_result(main_log, temp_text, "PASS")
             show_step_result(temp_text, "PASS")
     CMM.save_data(main_log, "IPMI Switch info list\n{0}".format(IPMI_SWITCH_INFO), timestamp=False)
Пример #7
0
 def y_curl_logout(self):
     if LOGIN_FAIL:
         return False
     message = "Logout Web"
     CMM.show_message(format_item(message),color="green",timestamp=False)
     status, output = CMM.curl_login_logout(IP, flag="logout", username=USERNAME, password=PASSWORD, csrf_token=CSRFToken)
     if status == 0:
         show_step_result(message,"PASS")
         CMM.save_step_result(main_log,message,"PASS")
     else:
         show_step_result(message,"FAIL")
         CMM.save_step_result(main_log,message,"FAIL")
Пример #8
0
 def b_ping_test(self):
     global CASE_PASS
     global PING_FAIL
     message = "- Ping CMM IP -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status = Remote.ping_test(IP)
     if not status:
         CASE_PASS = False
         PING_FAIL = True
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
     else:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
 def c_compare_fru_info(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     message = "- Compare FRU info -"
     CMM.show_message(format_item(message), timestamp=False, color="green")
     CMM.save_data(main_log, message, timestamp=False)
     temp_text = message.strip(" -")
     is_FAIL = False
     compareList = [
         "device_id", "chassis_type", "chassis_part_number",
         "chassis_serial", "chassis_extra", "board_manufacturer",
         "board_product", "board_serial", "board_part_number",
         "board_extra", "product_manufacturer", "product_name",
         "product_part_number", "product_version", "product_serial",
         "product_asset_tag", "product_extra"
     ]
     tempData = getCMMFruInfoViaAPI()
     if tempData:
         OEM_data = getCMMFruInfoViaOEM()
         API_data = tempData[0]
         API_data = parseAPIData(API_data)
         if API_data:
             for item in compareList:
                 apiValue = API_data.get(item)
                 oemValue = OEM_data.get(item)
                 if item == "device_id":
                     apiValue = str(apiValue)
                 if apiValue != oemValue:
                     is_FAIL = True
                     text = "[API] {0}: {1}".format(item, apiValue)
                     MAIN_LOG_list.append(text)
                     CMM.show_message(text, timestamp=False, color="red")
                     text = "[OEM] {0}: {1}".format(item, oemValue)
                     MAIN_LOG_list.append(text)
                     CMM.show_message(text, timestamp=False, color="red")
         else:
             is_FAIL = True
     else:
         is_FAIL = True
     if is_FAIL:
         CASE_PASS = False
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
     else:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
 def d_save_configuration(self):
     global CASE_PASS
     global SAVE_CONFIG_FAIL
     if LOGIN_FAIL:
         return False
     message = "- Save BMC configuration -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status = saveConfiguration()
     if status:
         SAVE_CONFIG_FAIL = False
         show_step_result(temp_text, flag="PASS")
         CMM.save_step_result(main_log, temp_text, flag="PASS")
     else:
         CASE_PASS = False
         show_step_result(temp_text, flag="FAIL")
         CMM.save_step_result(main_log, temp_text, flag="FAIL")
Пример #11
0
 def b_curl_login(self):
     global CASE_PASS
     global LOGIN_FAIL
     global CSRFToken
     message = "Login Web"
     CMM.show_message(format_item(message),color="green",timestamp=False)
     status, output = CMM.curl_login_logout(IP, flag="login", username=USERNAME, password=PASSWORD)
     if status == 0:
         show_step_result(message, flag="PASS")
         CMM.save_step_result(main_log,message,"PASS")
         CSRFToken = output.strip()
     else:
         LOGIN_FAIL = True
         CASE_PASS = False
         show_step_result(message,"FAIL")
         CMM.save_step_result(main_log,message,"FAIL")
         MAIN_LOG_list.append("{0} FAIL !".format(message))
Пример #12
0
 def c_check_all_module_status(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     temp_text = "- Check all module status via API -"
     CMM.show_message(format_item(temp_text),
                      color="green",
                      timestamp=False)
     CMM.save_data(main_log, temp_text, timestamp=False)
     MAIN_LOG_list.append(temp_text)
     message = temp_text.strip(" -")
     status = checkAllModuleStatus()
     if status:
         show_step_result(message, flag="PASS")
         CMM.save_step_result(main_log, message, flag="PASS")
     else:
         CASE_PASS = False
         show_step_result(message, flag="FAIL")
         CMM.save_step_result(main_log, message, flag="FAIL")
Пример #13
0
 def c_compare_network_info(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     message = "- Compare Network info -"
     CMM.show_message(format_item(message),timestamp=False,color="green")
     CMM.save_data(main_log, message, timestamp=False)
     temp_text = message.strip(" -")
     is_FAIL = False
     tempData = getNetworkInfoViaAPI()
     """ 判断API得到的返回值是 dict 或 list """
     API_data = {}
     if isinstance(tempData,list):
         for tempDict in tempData:
             if tempDict.get("channel_number") == LAN:
                 API_data = tempDict
                 break
     elif isinstance(tempData,dict):
         if tempData.get("channel_number") == LAN:
             API_data = tempData
     if not API_data:
         is_FAIL = True
     else:
         OEM_data = getNetworkInfoViaOEM()
         compareList = ["mac_address", "ipv4_dhcp_enable", "ipv4_address", "ipv4_subnet", "ipv4_gateway"]
         for item in compareList:
             apiValue = API_data.get(item)
             oemValue = OEM_data.get(item)
             if apiValue != oemValue:
                 text = "[API] {0}: {1}".format(item,apiValue)
                 MAIN_LOG_list.append(text)
                 CMM.show_message(text,timestamp=False,color="red")
                 text = "[OEM] {0}: {1}".format(item,oemValue)
                 MAIN_LOG_list.append(text)
                 CMM.show_message(text,timestamp=False,color="red")
                 is_FAIL = True
     if is_FAIL:
         CASE_PASS = False
         show_step_result(temp_text,"FAIL")
         CMM.save_step_result(main_log,temp_text,"FAIL")
     else:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
 def f_upload_fw(self):
     global CASE_PASS
     global UPLOAD_IMAGE
     if LOGIN_FAIL:
         return False
     elif not ENTER_FLASH_MODE:
         return False
     message = "- Upload firmware -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status = uploadFirmware()
     if status:
         UPLOAD_IMAGE = True
         show_step_result(temp_text, flag="PASS")
         CMM.save_step_result(main_log, temp_text, flag="PASS")
     else:
         CASE_PASS = False
         show_step_result(temp_text, flag="FAIL")
         CMM.save_step_result(main_log, temp_text, flag="FAIL")
 def d_get_switch_number(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     temp_text = "- Get Switch count -"
     CMM.show_message(format_item(temp_text),
                      timestamp=False,
                      color="green")
     CMM.save_data(main_log, temp_text, timestamp=False)
     MAIN_LOG_list.append(temp_text)
     message = temp_text.strip(" -")
     status = getSwitchNumber()
     if status:
         show_step_result(message, "PASS")
         CMM.save_step_result(main_log, message, "PASS")
     else:
         CASE_PASS = False
         show_step_result(message, "FAIL")
         CMM.save_step_result(main_log, message, "FAIL")
 def g_verify_fw(self):
     global CASE_PASS
     global VERIFY_IMAGE
     if LOGIN_FAIL:
         return False
     elif not UPLOAD_IMAGE:
         return False
     message = "- Verify firmware -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status = verifyFirmware()
     if status:
         VERIFY_IMAGE = True
         show_step_result(temp_text, flag="PASS")
         CMM.save_step_result(main_log, temp_text, flag="PASS")
     else:
         CASE_PASS = False
         show_step_result(temp_text, flag="FAIL")
         CMM.save_step_result(main_log, temp_text, flag="FAIL")
Пример #17
0
 def y_curl_logout(self):
     global CASE_PASS
     if LOGIN_FAIL:
         return False
     message = "- Logout Web -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status, output = CMM.curl_login_logout(IP,
                                            flag="logout",
                                            username=USERNAME,
                                            password=PASSWORD,
                                            csrf_token=CSRFToken)
     if status == 0:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
     else:
         CASE_PASS = False
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
Пример #18
0
 def f_set_user_snmp(self):
     if IPMI_SWITCH_FAIL:
         return False
     global CASE_PASS
     global SET_USER_SNMP
     temp_text = "- Set user for SNMP V3 -"
     CMM.show_message(format_item(temp_text),timestamp=False,color="green")
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     status = setUserSNMP()
     message = temp_text.strip(" -")
     if status:
         SET_USER_SNMP = True
         CMM.save_step_result(main_log,message,"PASS")
         show_step_result(message,"PASS")
         time.sleep(20)
     else:
         CASE_PASS = False
         CMM.save_step_result(main_log,message,"FAIL")
         show_step_result(message,"FAIL")
 def e_enter_flash_mode(self):
     global CASE_PASS
     global ENTER_FLASH_MODE
     if LOGIN_FAIL:
         return False
     # 考虑保存BMC配置进行刷新
     if SAVE_CONFIG_FAIL:
         return False
     message = "- Enter flash mode -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status = enterFlashMode()
     if status:
         ENTER_FLASH_MODE = True
         show_step_result(temp_text, flag="PASS")
         CMM.save_step_result(main_log, temp_text, flag="PASS")
     else:
         CASE_PASS = False
         show_step_result(temp_text, flag="FAIL")
         CMM.save_step_result(main_log, temp_text, flag="FAIL")
 def m_set_psu_power_state_via_API(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     temp_text = "- Set psu power state via API -"
     CMM.show_message(format_item(temp_text), color="green", timestamp=False)
     CMM.save_data(main_log, temp_text, timestamp=False)
     MAIN_LOG_list.append(temp_text)
     """
     1. 保证PSU在位数量大于1
     2. 保证所有的PSU均处于Power on状态
     """
     if len(Present_psu) > 1:
         for psu_id in range(1, int(PSU_NUM) + 1):
             if psu_id not in Present_psu:
                 continue
             text = "[PSU{0}] Init state to power on".format(psu_id)
             initStatus = init_psu_powerstate_via_API(psu_id)
             if initStatus:
                 show_step_result(text,flag="PASS")
                 CMM.save_step_result(main_log,text,flag="PASS")
             else:
                 show_step_result(text,flag="FAIL")
                 CMM.save_step_result(main_log,text,flag="FAIL")
                 CASE_PASS = False
                 return False
         for psu_id in range(1, int(PSU_NUM) + 1):
             if psu_id not in Present_psu:
                 continue
             status = set_psu_powerstate_via_API(psu_id)
             message = "[PSU{0}] {1}".format(psu_id,temp_text.strip(" -"))
             if status:
                 show_step_result(message,flag="PASS")
                 CMM.save_step_result(main_log,message,flag="PASS")
             else:
                 CASE_PASS = False
                 show_step_result(message,flag="FAIL")
                 CMM.save_step_result(main_log,message,flag="FAIL")
             time.sleep(1)
 def d_check_blackbox_info(self):
     if LOGIN_FAIL:
         return False
     if DUMP_FAIL:
         return False
     global CASE_PASS
     message = "- Check Black box info -"
     CMM.show_message(format_item(message), timestamp=False, color="green")
     CMM.save_data(main_log, message, timestamp=False)
     MAIN_LOG_list.append(message)
     temp_text = message.strip(" -")
     is_FAIL = False
     status = checkCMMBlackBoxInfo()
     if not status:
         is_FAIL = True
     if is_FAIL:
         CASE_PASS = False
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
     else:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
 def b_download_fw(self):
     global CASE_PASS
     global DOWNLOAD_FW_FAIL
     global IMAGE_FILE
     message = "- Download CMM Firmware -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     flag = "CMM"
     status = collectFirmware(flag)
     if not status:
         CASE_PASS = False
         MAIN_LOG_list.append("{0} FAIL !".format(temp_text))
         CMM.save_step_result(main_log, temp_text, "FAIL")
         show_step_result(temp_text, "FAIL")
     else:
         DOWNLOAD_FW_FAIL = False
         IMAGE_FILE = os.path.join(TMP_DIR, "{0}.ima".format(flag))
         CMM.save_data(main_log,
                       "Image file: {0}".format(IMAGE_FILE),
                       timestamp=False)
         CMM.save_step_result(main_log, temp_text, "PASS")
         show_step_result(temp_text, "PASS")
Пример #23
0
 def c_ipmi_test(self):
     global CASE_PASS
     global IPMI_FAIL
     message = "- Check IPMI command -"
     CMM.show_message(format_item(message), timestamp=False, color="green")
     if PING_FAIL:
         return False
     cmd = "{0} raw 0x06 0x01".format(IPMITOOL)
     temp_text = message.strip(" -")
     status, output = CMM.retry_run_cmd(cmd)
     info = "IPMI command\n{0}\nreturncode: {1}\n{2}".format(
         cmd, status, output)
     CMM.save_data(main_log, info, timestamp=False)
     if status == 0:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
     else:
         IPMI_FAIL = True
         CASE_PASS = False
         CMM.show_message(output, timestamp=False)
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
Пример #24
0
 def c_check_sensor_table(self):
     global CASE_PASS
     message = "- Collect sensor table info -"
     CMM.show_message(format_item(message), timestamp=False, color="green")
     CMM.save_data(main_log, message, timestamp=False)
     MAIN_LOG_list.append(message)
     temp_text = message.strip(" -")
     is_FAIL = False
     OEM_data = getSensorTableViaOEM()
     if OEM_data:
         CMM.save_data(MAIN_LOG,
                       "OEM_Sensor_Table_INFO: {0}".format(OEM_data),
                       timestamp=False)
     else:
         is_FAIL = True
     if is_FAIL:
         CASE_PASS = False
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
     else:
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
 def c_get_fan_via_ipmi(self):
     global Present_FAN
     global IPMI_FAN_INFO
     global IPMI_FAN_FAIL
     global CASE_PASS
     temp_text = "- Get FAN info via IPMI -"
     CMM.show_message(format_item(temp_text),color="green",timestamp=False)
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     for fan_id in range(1,int(FAN_NUM)+1):
         fan = "FAN{0}".format(fan_id)
         is_fail = False
         OEM_id,OEM_FanStatus,OEM_Duty,OEM_FanSpeed1,OEM_FanSpeed2 = ["Unknown"]*5
         OEM_info = GetFanInfoViaOEM(fan_id)
         if OEM_info:
             temp_list = OEM_info.split()
             OEM_Present = parse_Present(temp_list)
             if OEM_Present[1] == 1:
                 Present_FAN.append(fan_id)
             OEM_id = parse_id(temp_list)
             OEM_FanStatus = parse_FanStatus(temp_list)
             OEM_Duty = parse_Duty(temp_list)
             OEM_FanSpeed1 = parse_FanSpeed(temp_list,1)
             OEM_FanSpeed2 = parse_FanSpeed(temp_list,2)
         else:
             is_fail = True
             IPMI_FAN_FAIL = True
         IPMI_FAN_INFO.append([OEM_id,OEM_FanStatus,OEM_Duty,OEM_FanSpeed1,OEM_FanSpeed2])
         temp_text = "[{0}] IPMI info".format(fan)
         if is_fail:
             CASE_PASS = False
             CMM.save_step_result(main_log,temp_text,"FAIL")
             show_step_result(temp_text,"FAIL")
             MAIN_LOG_list.append("{0} FAIL !".format(temp_text))
         else:
             CMM.save_step_result(main_log,temp_text,"PASS")
             show_step_result(temp_text,"PASS")
     CMM.save_data(main_log,"IPMI FAN info list\n{0}".format(IPMI_FAN_INFO),timestamp=False)
 def h_flash_firmware(self):
     global CASE_PASS
     if LOGIN_FAIL:
         return False
     if not VERIFY_IMAGE:
         return False
     message = "- Flash firmware -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status = flashFirmware()
     if status:
         complete_status = getFlashStatus()
         if complete_status:
             show_step_result(temp_text, flag="PASS")
             CMM.save_step_result(main_log, temp_text, flag="PASS")
         else:
             CASE_PASS = False
             show_step_result(temp_text, flag="FAIL")
             CMM.save_step_result(main_log, temp_text, flag="FAIL")
     else:
         CASE_PASS = False
         show_step_result(temp_text, flag="FAIL")
         CMM.save_step_result(main_log, temp_text, flag="FAIL")
Пример #27
0
 def f_curl_login(self):
     global CASE_PASS
     global LOGIN_FAIL
     global CSRFToken
     if PING_FAIL:
         LOGIN_FAIL = True
         return False
     message = "- Login Web -"
     CMM.show_message(format_item(message), color="green", timestamp=False)
     temp_text = message.strip(" -")
     status, output = CMM.curl_login_logout(IP,
                                            flag="login",
                                            username=USERNAME,
                                            password=PASSWORD,
                                            retry_count=3)
     if status == 0:
         CSRFToken = output.strip()
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
     else:
         LOGIN_FAIL = True
         CASE_PASS = False
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
 def g_check_psu_via_snmpv3(self,version="3"):
     if IPMI_PSU_FAIL:
         return False
     global CASE_PASS
     show_version = version[0]
     temp_text = "- Check PSU info via SNMP V{0} -".format(show_version)
     CMM.show_message(format_item(temp_text),color="green",timestamp=False)
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     temp_list = getPSUInfoViaSNMP(version=version)
     total_num = temp_list[0]
     present_num = temp_list[1]
     psu_info = temp_list[2:]
     temp_text = "Check PSU total number"
     if total_num == PSU_NUM:
         show_step_result(temp_text,"PASS")
         CMM.save_step_result(main_log,temp_text,"PASS")
     else:
         CASE_PASS = False
         message = "PSU total number: {0}".format(total_num)
         MAIN_LOG_list.append(message)
         CMM.show_message(message,timestamp=False,color="red")
         show_step_result(temp_text,"FAIL")
         CMM.save_step_result(main_log,temp_text,"FAIL")
     temp_text = "Check PSU present number"
     if present_num == len(Present_psu):
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
     else:
         CASE_PASS = False
         message = "PSU present number: {0}".format(present_num)
         MAIN_LOG_list.append(message)
         CMM.show_message(message,timestamp=False,color="red")
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
     for psu_id in range(1, int(PSU_NUM) + 1):
         psu = "PSU{0}".format(psu_id)
         is_fail = False
         index = psu_id - 1
         temp_snmp = psu_info[index]
         temp_ipmi = map(str,IPMI_PSU_INFO[index])
         temp_text = "[{0}] SNMP V{1} info".format(psu,show_version)
         compare_flag = False
         try:
             if len(temp_snmp) == len(temp_ipmi) == ITEM_NUM:
                 # if temp_snmp[0] == temp_ipmi[0] and temp_snmp[2] == temp_ipmi[2] and temp_snmp[-4:] == temp_ipmi[-4:]:
                 if temp_snmp[0] == temp_ipmi[0] and temp_snmp[2] == temp_ipmi[2] and temp_snmp[-3:] == temp_ipmi[-3:]:
                     """ 两者差值小于IPMI值 即为PASS """
                     temp_pout = float(temp_snmp[2]) - float(temp_ipmi[2])
                     temp_pin = float(temp_snmp[3]) - float(temp_ipmi[3])
                     temp_vout = float(temp_snmp[4]) - float(temp_ipmi[4])
                     temp_vin = float(temp_snmp[5]) - float(temp_ipmi[5])
                     temp_iout = float(temp_snmp[6]) - float(temp_ipmi[6])
                     temp_iin = float(temp_snmp[7]) - float(temp_ipmi[7])
                     temp_temperature = float(temp_snmp[8]) - float(temp_ipmi[8])
                     temp_fanSpeed = float(temp_snmp[9]) - float(temp_ipmi[9])
                     if abs(temp_pout) <= float(temp_ipmi[2]) and \
                         abs(temp_pin) <= float(temp_ipmi[3]) and \
                         abs(temp_vout) <= float(temp_ipmi[4]) and \
                         abs(temp_vin) <= float(temp_ipmi[5]) and \
                         abs(temp_iout) <= float(temp_ipmi[6]) and \
                         abs(temp_iin) <= float(temp_ipmi[7]) and \
                         abs(temp_temperature) <= float(temp_ipmi[8]) and \
                         abs(temp_fanSpeed) <= float(temp_ipmi[9]):
                         if int(temp_snmp[2]) > 0:
                             compare_flag = True
                         elif int(temp_snmp[2]) == 0 and temp_snmp[1] == temp_ipmi[1]:
                             compare_flag = True
         except: pass
         if compare_flag:
             CMM.save_step_result(main_log, temp_text, "PASS")
             show_step_result(temp_text, "PASS")
         else:
             is_fail = True
             message = "[IPMI] {0}".format(temp_ipmi)
             MAIN_LOG_list.append(message)
             CMM.show_message(message,timestamp=False,color="red")
             message = "[SNMP] {0}".format(temp_snmp)
             MAIN_LOG_list.append(message)
             CMM.show_message(message,timestamp=False,color="red")
             CMM.save_step_result(main_log, temp_text, "FAIL")
             show_step_result(temp_text, "FAIL")
         if is_fail:
             CASE_PASS = False
 def n_set_switch_ipv4_via_API(self):
     if LOGIN_FAIL:
         return False
     global CASE_PASS
     temp_text = "- Set Switch ipv4 via Web API -"
     CMM.show_message(format_item(temp_text),
                      color="green",
                      timestamp=False)
     CMM.save_data(main_log, temp_text, timestamp=False)
     MAIN_LOG_list.append(temp_text)
     random_base = random.randrange(100, 200)
     for switch_id in range(1, int(SWITCH_NUM) + 1):
         check_switch = GetSwitchInfoViaAPI(CSRFToken, switch_id)
         if check_switch.get("swPresent") == 0:
             continue
         default_IP = check_switch.get("IP")
         default_Netmask = check_switch.get("Netmask")
         default_Gateway = check_switch.get("Gateway")
         set_IP = "10.0.0.{0}".format(int(switch_id) + random_base)
         set_Netmask = "255.255.255.0"
         set_Gateway = "10.0.0.254"
         set_value = set_switch_ipv4_API(switch_id, set_IP, set_Netmask,
                                         set_Gateway)
         if set_value:
             time.sleep(20)
             API_info = GetSwitchInfoViaAPI(CSRFToken, switch_id)
             set_IP, set_Netmask, set_Gateway = [
                 set_value.get(item)
                 for item in ["IP", "Netmask", "Gateway"]
             ]
             get_IP, get_Netmask, get_Gateway = [
                 API_info.get(item)
                 for item in ["IP", "Netmask", "Gateway"]
             ]
             if set_IP != get_IP or set_Netmask != get_Netmask or set_Gateway != get_Gateway:
                 CASE_PASS = False
                 message = "[API] Set switch{0} ipv4 FAIL !".format(
                     switch_id)
                 MAIN_LOG_list.append(message)
                 message = "{0}\n{1}\n{2}".format(
                     message, "Set value: {0} {1} {2}".format(
                         set_IP, set_Netmask, set_Gateway),
                     "Get value: {0} {1} {2}".format(
                         get_IP, get_Netmask, get_Gateway))
                 CMM.show_message(message, timestamp=False, color="red")
                 CMM.save_data(main_log, message, timestamp=False)
             else:
                 show_step_result(
                     "[API] Set switch{0} ipv4".format(switch_id),
                     flag="PASS")
                 set_value = set_switch_ipv4_API(switch_id, default_IP,
                                                 default_Netmask,
                                                 default_Gateway)
                 if set_value:
                     time.sleep(20)
                     API_info = GetSwitchInfoViaAPI(CSRFToken, switch_id)
                     set_IP, set_Netmask, set_Gateway = [
                         set_value.get(item)
                         for item in ["IP", "Netmask", "Gateway"]
                     ]
                     get_IP, get_Netmask, get_Gateway = [
                         API_info.get(item)
                         for item in ["IP", "Netmask", "Gateway"]
                     ]
                     temp_text = "[API] Restore switch{0} ipv4".format(
                         switch_id)
                     if set_IP == get_IP and set_Netmask == get_Netmask and set_Gateway == get_Gateway:
                         show_step_result(temp_text, flag="PASS")
                         CMM.save_step_result(main_log,
                                              temp_text,
                                              flag="PASS")
                     else:
                         show_step_result(temp_text, flag="FAIL")
                         CMM.save_step_result(main_log,
                                              temp_text,
                                              flag="FAIL")
         else:
             CASE_PASS = False
             message = "[API] Set switch{0} ipv4 FAIL !".format(switch_id)
             CMM.show_message(message, timestamp=False, color="red")
             CMM.save_data(main_log, message, timestamp=False)
             MAIN_LOG_list.append(message)
Пример #30
0
 def g_check_switch_via_snmpv3(self,version="3"):
     if IPMI_SWITCH_FAIL:
         return False
     elif not SET_USER_SNMP:
         return False
     global CASE_PASS
     show_version = version[0]
     temp_text = "- Check Switch info via SNMP V{0} -".format(show_version)
     CMM.show_message(format_item(temp_text),color="green",timestamp=False)
     CMM.save_data(main_log,temp_text,timestamp=False)
     MAIN_LOG_list.append(temp_text)
     temp_list = getSwitchInfoViaSNMP(version=version)
     total_num = temp_list[0]
     present_num = temp_list[1]
     switch_info = temp_list[2:]
     temp_text = "Check Switch total number"
     if total_num == SWITCH_NUM:
         show_step_result(temp_text,"PASS")
         CMM.save_step_result(main_log,temp_text,"PASS")
     else:
         CASE_PASS = False
         message = "Switch total number: {0}".format(total_num)
         MAIN_LOG_list.append(message)
         CMM.show_message(message,timestamp=False,color="red")
         show_step_result(temp_text,"FAIL")
         CMM.save_step_result(main_log,temp_text,"FAIL")
     temp_text = "Check Switch present number"
     if present_num == len(Present_switch):
         show_step_result(temp_text, "PASS")
         CMM.save_step_result(main_log, temp_text, "PASS")
     else:
         CASE_PASS = False
         message = "Switch present number: {0}".format(present_num)
         MAIN_LOG_list.append(message)
         CMM.show_message(message,timestamp=False,color="red")
         show_step_result(temp_text, "FAIL")
         CMM.save_step_result(main_log, temp_text, "FAIL")
     for switch_id in range(1, int(SWITCH_NUM) + 1):
         switch = "Switch{0}".format(switch_id)
         is_fail = False
         index = switch_id - 1
         temp_snmp = switch_info[index]
         temp_ipmi = map(str,IPMI_SWITCH_INFO[index])
         temp_text = "[{0}] SNMP V{1} info".format(switch,show_version)
         compare_flag = False
         if len(temp_snmp) == len(temp_ipmi) == ITEM_NUM:
             if temp_snmp[:3] == temp_ipmi[:3] and temp_snmp[-4:] == temp_ipmi[-4:]:
                 """ 两者差值小于IPMI值 即为PASS """
                 temp_temperature = float(temp_snmp[3]) - float(temp_ipmi[3])
                 temp_pwrConsump = float(temp_snmp[4]) - float(temp_ipmi[4])
                 if abs(temp_temperature) <= float(temp_ipmi[3])/2 and \
                     abs(temp_pwrConsump) <= float(temp_ipmi[4])/2:
                     compare_flag = True
         if compare_flag:
             CMM.save_step_result(main_log, temp_text, "PASS")
             show_step_result(temp_text, "PASS")
         else:
             is_fail = True
             message = "[IPMI] {0}".format(temp_ipmi)
             MAIN_LOG_list.append(message)
             CMM.show_message(message,timestamp=False,color="red")
             message = "[SNMP] {0}".format(temp_snmp)
             MAIN_LOG_list.append(message)
             CMM.show_message(message,timestamp=False,color="red")
             CMM.save_step_result(main_log, temp_text, "FAIL")
             show_step_result(temp_text, "FAIL")
         if is_fail:
             CASE_PASS = False