def initial_setup(self, cimc_util_obj, common_config, config): ''' Initial Setups ''' global classparam classparam['firmware_utils'] = FirmwareUtils(cimc_util_obj, common_config, config) classparam['bios_obj'] = cimc_util_obj.bios_util_obj classparam['system_capture_object'] = SystemDetailsCapture(cimc_util_obj, config) classparam['host_ip'] = common_utils.get_host_mgmt_ip(config) #sys_image = '/auto/savbu-rack-builds01/firmware-containers/delnorte1/freel_peak_mr2/3.0.2.26/images/CIMC/C220M4-3.0.2.26.zip' try: bios_image_path = os.environ['BIOS_IMAGE'] log.info('BIOS Image Path:' + bios_image_path) except KeyError: self.skipped('SYSTEM IMAGE not provided in the env, please set system image and run',\ goto=['CommonCleanup']) bios_obj = classparam['bios_obj'] firmware_utils_obj = classparam['firmware_utils'] log.info('Fetch BIOS version associated with bios system image') file = bios_image_path+ '/' + 'BIOSID.BIN' cfc_image_ver_file = subprocess.getoutput('ls '+file) if 'No such file or directory' in cfc_image_ver_file: log.error('BIOS CFC image version file does not exists') self.failed('BIOS Image version file BIOSID.BIN does not exists', goto=['CommonCleanup']) else: cmd = 'cat ' + file classparam['bios_version'] = subprocess.check_output(cmd, shell=True).decode('utf_16').rstrip('\x00') print('============================') print(classparam['bios_version']) print('============================')
def setup(self, cimc_util_obj, config, con_obj): ''' Setup method for all possible boot devices ''' self.boot_order_obj = BootOrder(cimc_util_obj, config) self.host_handle = self.boot_order_obj.host_handle self.host_serial_handle = cimc_util_obj.telnet_handle self.host_util_obj = HostUtils(cimc_util_obj, config) bios_obj = cimc_util_obj.bios_util_obj self.config_obj = config.boot_device_detail log.info(self.config_obj) self.host_ip = common_utils.get_host_mgmt_ip(config) log.info('Display all boot order details:') for key in self.config_obj.keys(): log.info(self.config_obj[key]) boot_mode = con_obj.get('BootDeviceDetail', 'boot_mode') log.info('Testbed is configured in: ' + boot_mode) mode = self.boot_order_obj.get_boot_mode() log.info('Current configured boot mode: ' + mode) if mode != boot_mode: self.boot_order_obj.configure_boot_mode(boot_mode) cimc_util_obj.verify_host_up(self.host_ip) # Disable SOL if bios_obj.enable_disable_sol(value='no') is False: log.warning('Failed to set console redirect default values') if bios_obj.console_redirect_defaults() is False: log.warning('Failed to set console redirect default values') aetest.loop.mark( self.verify_boot_order, boot_device=self.config_obj.keys())
def mac_linux(self, cimc_util_obj, config): #cimc_util_obj.verify_host_up(hostname=host_os_ip, wait_for_ping_fail=False, wait_time=600) host_ip = common_utils.get_host_mgmt_ip(config) host_ping_status = cimc_util_obj.verify_host_up( hostname=host_ip, wait_for_ping_fail=False, wait_time=30) if host_ping_status is True: logger.info("Host OS is pinging ...") else: boot_order_obj = BootOrder(cimc_util_obj, config) output = boot_order_obj.set_boot_order_HDD() if output == True: host_ping_status = cimc_util_obj.verify_host_up( hostname=host_ip, wait_for_ping_fail=False, wait_time=600) if host_ping_status is True: logger.info("Host OS is pinging ...") else: logger.error("ERROR :Host OS is not pinging \ ,after setting the boot order to HDD and retrying ..." ) logger.error( "Testcase failed .... since Unabke to boot to OS") return False os_handle = cimc_util_obj.host_handle output = [] os_handle.connect() output = os_handle.execute_cmd( 'ifconfig | grep -o -E "([[:xdigit:]]{1,2}:){5}[[:xdigit:]]{1,2}"') logger.info("OS mac info", str(output)) return output.lower()
def check_host_up(self, cimc_util_obj, boot_order_obj, config): ''' Procedure to check host is pinging or not. If not, will set the boot order to HDD and reboot host and try to ping host again. Return values: True: if host OS is pinging False: if host OS is not pinging ''' host_ip = common_utils.get_host_mgmt_ip(config) ping_status = cimc_util_obj.verify_host_up(hostname=host_ip, wait_for_ping_fail=False) if ping_status is True: logger.info('Host OS is UP and is pinging...') return True else: output = boot_order_obj.set_boot_order_HDD() if output == True: ping_status = cimc_util_obj.verify_host_up( hostname=host_ip, wait_for_ping_fail=False, wait_time=600) if ping_status is True: logger.info('Host OS is up and it is pinging...') return True else: logger.error( 'Host OS is not pinging after setting the boot order to HDD' ) return False
def pci_setup(self, cimc_util_obj, config): ''' Setup method for all possible variables and object initializations ''' self.pcie_config_dict = pcie_config_details(config) log.info('PCI Adapter details present in the dictionary') log.info(self.pcie_config_dict) self.host_ip = common_utils.get_host_mgmt_ip(config) self.mgmt_handle = cimc_util_obj.handle
def setup(self, cimc_util_obj, config): ''' Setup method for all possible variables and object initializations ''' log.info('setup test case') self.pcie_config_dict = pcie_config_details(config) log.info(self.pcie_config_dict) self.host_ip = common_utils.get_host_mgmt_ip(config) self.mgmt_handle = cimc_util_obj.handle # clear the SEL logs log.info('Clearing the SEL logs') cimc_util_obj.clear_cimc_sel_logs(log_scope='sel') log.info('setup section passed')
def __init__(self, cimc_utils_obj, common_config, config=None): self.handle = cimc_utils_obj.handle self.cimc_utils_obj = cimc_utils_obj self.common_config = common_config self.tftp_ip = self.common_config.tftp_share.tftp_server_ip self.tftp_user = self.common_config.tftp_share.tftp_user self.tftp_password = self.common_config.tftp_share.tftp_password self.tftp_handle = LinuxUtils(self.tftp_ip, self.tftp_user, self.tftp_password) self.tftp_root_dir = self.common_config.tftp_share.tftp_root_path self.cap_image_file_path = None self.host_ip = common_utils.get_host_mgmt_ip(config)
def initial_setup(self, cimc_util_obj, config, con_obj): ''' Initial Setups ''' global classparam host_ip = common_utils.get_host_mgmt_ip(config) print('%%%%%%%%%%%%%%%%%%%%%%%%') print(host_ip) print('%%%%%%%%%%%%%%%%%%%%%%%%') host_ip3 = config.host_info[0].nw_intf_list[0].ip_address print('===============') print(host_ip3) print('===============') exit() classparam['host_ip'] = get_host_mgmt_ip(config) ####classparam['bmc_serial_handle'] = cimc_util_obj.telnet_handle mgmt_detail_obj = config.mgmtdetail classparam['bmc_ip'] = mgmt_detail_obj.bmc_mgmt_ip classparam['bmc_login'] = mgmt_detail_obj.bmc_login classparam['bmc_passwd'] = mgmt_detail_obj.bmc_password
def connect_host_and_execute_command(self, cmd, boot_order_obj, wait_time=None): ''' proc to Connect to host and return the output of the executed command return - False if failed ''' host_handle = self.cimc_util_obj.host_handle host_ip = common_utils.get_host_mgmt_ip(self.config) host_ping_status = self.cimc_util_obj.verify_host_up( hostname=host_ip, wait_for_ping_fail=False, wait_time=600) if host_ping_status is True: logger.info("Host OS is pinging ...") time.sleep(10) host_handle.connect() else: output = boot_order_obj.set_boot_order_HDD() if output == True: host_ping_status = self.cimc_util_obj.verify_host_up( hostname=host_ip, wait_for_ping_fail=False, wait_time=600) if host_ping_status is True: logger.info("Host OS is pinging ...") time.sleep(10) host_handle.connect() else: logger.error("ERROR :Host OS is not pinging \ ,after setting the boot order to HDD and retrying ..." ) logger.error( "Testcase failed .... since Unabke to boot to OS") return False else: logger.error( " ERROR :Host OS is not pinging , failed to Set the boot order to HDD" ) return False # Execute the command for and get the output if wait_time == None: wait_time = 4 output = host_handle.execute_cmd(cmd, buffer_size=150000, wait_time=wait_time) logger.info(output) host_handle.disconnect() return output
def initial_setup(self, cimc_util_obj, config): ''' Initial Setups ''' global classparam classparam['bios_obj'] = cimc_util_obj.bios_util_obj classparam['host_utils'] = HostUtils() classparam['boot_order_obj'] = BootOrder(cimc_util_obj, config) classparam['host_ip'] = get_host_mgmt_ip(config) # Disable SOL if cimc_util_obj.bios_util_obj.enable_disable_sol(value='no') is False: log.warning('Failed to set console redirect default values') if cimc_util_obj.bios_util_obj.console_redirect_defaults() is False: log.warning('Failed to set console redirect default values') ################# Common setup Ends ############################################## '''
def setup(self, cimc_util_obj, config, con_obj): ''' Setup method for all possible basic boot devices ''' self.boot_order_obj = BootOrder(cimc_util_obj, config) self.host_handle = self.boot_order_obj.host_handle self.host_serial_handle = cimc_util_obj.telnet_handle self.host_util_obj = HostUtils(cimc_util_obj, config) self.config_obj = config.basic_boot_device_detail self.host_ip = common_utils.get_host_mgmt_ip(config) bios_obj = cimc_util_obj.bios_util_obj log.info('Display all basic boot order details:') for key in self.config_obj.keys(): log.info(self.config_obj[key]) # Disable SOL if bios_obj.enable_disable_sol(value='no') is False: log.warning('Failed to set console redirect default values') if bios_obj.console_redirect_defaults() is False: log.warning('Failed to set console redirect default values') aetest.loop.mark( self.verify_basic_boot_order, boot_device=self.config_obj.keys())
def setup(self, mem_mode_array, cimc_util_obj, config): ''' Loops through testcase for all the memory mode config passed from job file and loads host related details ''' host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail logger.info("IP : " + host_detail_config.ip_address + "\n user : "******"\n pass : "******"Host OS is pinging ...") else: output = self.boot_order_obj.set_boot_order_HDD() if output == True: host_ping_status = cimc_util_obj.verify_host_up( hostname=self.host_ip, wait_for_ping_fail=False, wait_time=600) if host_ping_status is True: logger.info("Host OS is pinging ...") else: logger.error("ERROR :Host OS is not pinging \ ,after setting the boot order to HDD and retrying ..." ) logger.error( "Testcase failed .... since Unabke to boot to OS") aetest.loop.mark(self.validate_memory_config_in_cimc_and_host, mem_mode=mem_mode_array)
def setup(self, cimc_util_obj, config, con_obj): ''' Setup method for all possible variables and object initializations ''' log.info('setup section') host_util_obj = classparam['host_util_obj'] boot_order_obj = classparam['boot_order_obj'] storage_util_obj = classparam['storage_util_obj'] self.host_ip = common_utils.get_host_mgmt_ip(config) self.mgmt_handle = cimc_util_obj.handle self.host_serial_handle = cimc_util_obj.telnet_handle self.pcie_config_dict = pcie_config_details(config) log.info(self.pcie_config_dict) boot_mode = con_obj.get('BootDeviceDetail', 'boot_mode') log.info('Testbed is configured in: ' + boot_mode) self.uefi_vd_no = con_obj.get('BootDeviceDetail', 'uefi_vd') log.info('UEFI VD no: ' + str(self.uefi_vd_no)) legacy_vd_no = con_obj.get('BootDeviceDetail', 'legacy_vd') log.info('Legacy VD no: ' + str(legacy_vd_no)) expected_boot_mode = 'Legacy' mode = boot_order_obj.get_boot_mode() log.info('Current configured boot mode: ' + mode) if mode != expected_boot_mode: # configure boot vd res = storage_util_obj.configure_boot_vd(legacy_vd_no) if res is False: self.failed('Failed to set VD/PD as boot VD/PD') # configure to Legacy mode boot_order_obj.configure_boot_mode(expected_boot_mode) cimc_util_obj.verify_host_up(self.host_ip, wait_for_ping_fail=False)
def cpu_frequency_eist_turbo_ed(self, config, parameter, cimc_util_obj): bios_obj = classparam['bios_obj'] procc_obj = classparam['procc_obj'] host_util = classparam['host_utils'] ######## Bios Default ############################# if bios_obj.load_bios_defaults() is False: self.failed("Failed to load bios defaults") else: logger.info("Waiting for host to reboot after load bios default") time.sleep(180) ################################################## if bios_obj.set_bios_token_value( parameter, 'Disabled', commit_wait=150) is False: self.failed("Failed to Disable " + parameter) else: turbo_value = bios_obj.get_bios_token_value(parameter) if 'Disabled' not in turbo_value: self.failed("Disabling " + parameter + " token failed") host_detail_config = config.host_info[0].nw_intf_list[0] host_info_config = config.host_info[0].host_detail logger.info("IP : " + host_detail_config.ip_address + "\n user : "******"\n pass : "******"Host OS is not pinging") if host.connect() is False: self.failed("Unable to connect to host") else: logger.info( "Successfully booted to os after token change without any error" ) logger.info("Keeping host for 5mins before PTU monitor") time.sleep(300) param_key = PARAM_TOKEN[parameter] config_frequency = float( getattr(procc_obj.processor_config, param_key)) logger.info("Config core val " + str(config_frequency)) if host_util.start_ptu_gen(host, wait=60) is False: self.failed("Failed to start PTU stress") host.disconnect() else: platform_type = config.mgmtdetail.platform_series avg_cpu_list = host_util.get_ptu_monitor_out(host) if len(avg_cpu_list) < 1: self.failed("Error is getting average frequency") for ind, core_freq in enumerate(avg_cpu_list): if platform_type == 'M5': core_freq = core_freq * 1000 if core_freq - 1000 <= config_frequency <= core_freq + 1000: logger.info("Successfully Verified core " + str(ind) + " frequency after stress when " + parameter + " Disabled :(" + str(core_freq) + ")") else: logger.error("Core " + str(ind) + " value not satisfied with config : " + str(core_freq)) result = 'Fail' host.disconnect() if result == 'Pass': self.passed( "Processor frequency verification for all cores successful" ) else: self.failed( "Frequency value in idle state not matched with PTU value")
def get_numa_config_detail(self, host_handle, token_status): ''' Description: To get the average cpu or memory frequency from PTU output Parameter : host handle , which frequency(cpu or mem), and hjow much time to monitor Returns : List of averages frequency of each cpu ''' try: logger.info('Current token status: ' + token_status) host_ip = common_utils.get_host_mgmt_ip(self.config) res = cimc_utils.CimcUtils.verify_host_up(self, hostname=host_ip, wait_for_ping_fail=False) if res is False: logger.warning('Failed to ping the host') else: logger.info("Host IP pinging successfully") '''connect to host''' logger.info( 'Sleeping some time for host to restart all its services') time.sleep(30) if host_handle.connect() is False: logger.error('Failed to connect to Host') return False cmd = 'grep -i numa /var/log/dmesg' host_handle.execute_cmd('rm -f /tmp/numa_cntl.txt') host_handle.execute_cmd(cmd + " > /tmp/numa_cntl.txt", wait_time=20) time.sleep(5) out = host_handle.execute_cmd("cat /tmp/numa_cntl.txt", wait_time=20) if token_status == 'Disabled': exp_msg = 'No NUMA configuration found' match = re.search('No NUMA configuration found', out) if match != None: logger.info( 'Successfully validated NUMA token. As expected, %s, \ when NUMA token is Disabled' % (exp_msg)) return True else: logger.info('Failed to verify NUMA token. Not find %s, \ when NUMA token is Disabled' % (exp_msg)) return False elif token_status == 'Enabled': exp_msg = 'Enabling automatic NUMA balancing' match = re.search('Enabling automatic NUMA balancing', out) if match != None: logger.info( 'Successfully validated NUMA token. Expected message %s seen, \ when NUMA token is Enabled' % (exp_msg)) return True else: logger.info('Failed to verify NUMA token. Found %s msg , \ when NUMA token is Enabled, Not expected' % (exp_msg)) return False except: curframe = inspect.currentframe() calframe = inspect.getouterframes(curframe, 2) logger.error("Error occured at the library function call name :" + str(calframe[1][3])) logger.error("Error occured is " + sys.exc_info().__str__()) return False