Пример #1
0
 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())
Пример #2
0
 def verify_last_boot_order_source_retain(self, cimc_util_obj, config, parameter, con_obj):
     '''Verify last boot order source'''
     log.info('To verify whether the last boot order source is retained on ' + parameter)
     boot_mode = con_obj.get('BootDeviceDetail', 'boot_mode')
     #if boot_mode != 'Legacy' or boot_mode != 'Uefi':
     #    self.skipped('Testbed is not configured to test this test, skipping test')
     boot_order_obj = BootOrder(cimc_util_obj, config)
     log.info('remove existing boot device if any')
     boot_order_obj.remove_boot_dev()
     log.info('create LOCALHDD boot device')
     boot_device = 'myLOCALHDD_RHEL'
     boot_dev_dict = {}
     try:
         options = con_obj.options(boot_device)
     except KeyError:
         self.skipped('LOCALHDD boot device not configured on this testbed')
     for option in options:
         boot_dev_dict[option] = con_obj.get(boot_device, option)
     log.info('Remove boot device, if any created already')
     boot_order_obj.remove_boot_dev()
     res = boot_order_obj.create_and_configure_boot_device(boot_device, con_obj)
     if res is False:
         self.failed('Failed to create boot device for device type: ' + boot_device)
     elif res is 'SKIP':
         self.skipped('Boot device ' + boot_device + ' not configured on the testbed, Skipping test.')
     else:
         log.info('successfully created boot device for device type' + boot_device)
     log.info('Reboot the respective component and check for last boot order source is retained ')
     if boot_order_obj.reboot_operations(parameter) is False:
         self.failed('Failed to power cycle the %s' % (parameter))
     res = boot_order_obj.last_update_config(exp_last_source='CIMC')
     if res is True:
         self.passed('Test Passed')
     else:
         self.failed('Test Failed')
Пример #3
0
 def __init__(self, obj):
     self.bios_util_obj = obj
     self.handle = obj.handle
     self.boot_order_obj = BootOrder(self.bios_util_obj.cimc_obj)
     self.cpu_details = []
     self.processor_config = self.load_cpu_obj()
     self.msr = {"IntelTurboBoostTech" : "1A0", "EnhancedIntelSpeedStep" : "1A0",
                 "ExecuteDisable":"1A0", "HardwarePrefetch":"1A4",
                 "AdjacentCacheLinePrefetch":"1A4", "DirectCacheAccess":"1F8",
                 "lt_lock_memory":"2E7", "pkg_cst":"E2", "plat_info":"0CE",
                 "power_ctl":"1FC", "dynamic_switch":"1FC", "perf_bias":"1FC",
                 "c1e":"1FC", "ia32_energy":"1B0", "Hwpm":"1AA",
                 "cpu_cstate":"E2", 'IA32_Energy_Performance_BIAS':'1B0'}
Пример #4
0
    def inital_setup(self, cimc_util_obj, config):
        global system_capture_object
        system_capture_object = SystemDetailsCapture(cimc_util_obj, config)

        global classparam
        classparam['boot_order_obj'] = BootOrder(cimc_util_obj)
        classparam['host_util_obj'] = HostUtils(cimc_util_obj, config)
        classparam['storage_util_obj'] = StorageUtils(cimc_util_obj, config)
Пример #5
0
 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())
Пример #6
0
 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)
Пример #7
0
    def inital_setup(self, cimc_util_obj, config):
        '''
        Initial Setups
        '''
        global classparam
        classparam['boot_order_object'] = BootOrder(cimc_util_obj, config)
        classparam['cimc_util_obj'] = cimc_util_obj
        classparam['smbios_obj'] = SmbiosLib()
        bios_obj = cimc_util_obj.bios_util_obj

        # 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')
Пример #8
0
    def cdn_enable_test(self, cimc_util_obj, config):
        '''
        Logical ID: RACK-BIOS-DN-CDN-VIC-003
        Test Case: To Check CDN is Enabled from CIMC
        '''
        vic_list = config.inventory_detail
        logger.info('VIC list are: ' + str(vic_list))
        bios_obj = cimc_util_obj.bios_util_obj

        host_util = HostUtils()
        boot_order_obj = BootOrder(cimc_util_obj)
        status = host_util.check_host_up(cimc_util_obj, boot_order_obj, config)
        if status is False:
            logger.warning(
                'Host OS is not pinging after setting the boot order to HDD ')

        bios_token = 'cdnEnable'
        token_new_value = 'Enabled'
        logger.info('Power on the host')
        if cimc_util_obj.set_host_power('on') is False:
            self.failed('Failed to power on host', goto=['cleanup'])
        host_ip = get_host_mgmt_ip(config)
        token_val = bios_obj.get_bios_token_value(bios_token)
        if token_val == token_new_value:
            logger.info('CDN is already enabled on CIMC')
        else:
            logger.info('Set the cdnEnable token Enable and Reboot the host')
            res = bios_obj.set_bios_token_value(bios_token, token_new_value)
            if res is False:
                logger.error('Failed to set bios token value')
                self.failed('Failed to set bios token value', goto=['cleanup'])
            '''Wait for host to reboot'''
            res = cimc_util_obj.verify_host_up(host_ip,
                                               wait_for_ping_fail=False,
                                               wait_time=400)
            if res is False:
                logger.warning('Failed to ping the host after host reboot')
                self.failed('Failed to ping host', goto=['cleanup'])
            scope = 'advanced'
            token_val = bios_obj.get_bios_token_value(bios_token)
            if token_val == token_new_value:
                self.passed(
                    'Successfully verified that CDN token can be enabled from CIMC'
                )
            else:
                self.failed('Failed to verify that CDN token,\
                    Expected is:' + token_new_value + ' But got as: ' +
                            token_val)
Пример #9
0
 def verify_boot_when_wrong_attr_set(self, cimc_util_obj, config, parameter, con_obj):
     '''Verify boot device when wrong attribute set'''
     log.info('Verify that the host boots to the other available configured device \
             by setting the wrong attributes')
     boot_mode = con_obj.get('BootDeviceDetail', 'boot_mode')
     #if boot_mode != 'Legacy' or boot_mode != 'Uefi':
     #    self.skipped('Testbed is not configured to test this test, skipping test')
     boot_order_obj = BootOrder(cimc_util_obj, config)
     boot_device = 'myPXE'
     boot_dev_dict = {}
     try:
         options = con_obj.options(boot_device)
     except KeyError:
         self.skipped('PXE boot device not configured on testbed config file')
     for option in options:
         boot_dev_dict[option] = con_obj.get(boot_device, option)
     log.info('Boot configure parameters:')
     log.info(boot_dev_dict)
     boot_config_dict = {k:v for k, v in (x.split(':') for x in boot_dev_dict['config'].split(','))}
     slot_id = boot_config_dict['slot']
     port_id = boot_config_dict['port']
     log.info('Slot: %s and port: %s' % (slot_id, port_id))
     log.info(boot_config_dict)
     log.info('remove existing boot device if any')
     boot_order_obj.remove_boot_dev()
     log.info('create PXE boot device and enable the state, set order to 1, and wrong slot')
     if boot_order_obj.create_and_config_pxe_boot_device(slot_id, port_id, device_type='PXE', wrong_slot='MLOM') is False:
         self.failed('Failed to create PXE boot device')
     log.info('create LOCALHDD boot device and enable the state, set order to 2')
     if boot_order_obj.create_and_config_localhdd_boot_device(device_type=parameter, dev_order='2') is False:
         self.failed('Failed to create LOCALHDD boot device')
     log.info('Power cycle the host and verify that host boots into PXE boot device')
     boot_order_obj.powercycle_and_wait_for_host_comes_up()
     log.info('verify the actual boot order after host reboot')
     res1 = boot_order_obj.verify_host_booted_from_configured_device(device_type=parameter)
     if res1 is True:
         self.passed('Test Passed')
     else:
         self.failed('Test Failed')
Пример #10
0
    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 ##############################################
        '''
Пример #11
0
class BootOrderTest(aetest.Testcase):
    '''Class to verify boot device for PXE/ISCSI/SDCARD/SAN/USB/VMEDIA/PCHSTORAGE/UEFISHELL/NVME'''
    @aetest.setup
    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())
    @aetest.test
    def verify_boot_order(self, cimc_util_obj, boot_device, con_obj):
        '''Verify L2 boot order for all possible boot device configured on config file'''
        log.info('Running the test for boot device: ' + boot_device)
        log.info('Boot Configuration values are: ' + str(self.config_obj[boot_device]))
        boot_dev_dict = {}
        options = con_obj.options(boot_device)
        for option in options:
            boot_dev_dict[option] = con_obj.get(boot_device, option)
        log.info('Boot configure parameters:')
        log.info(boot_dev_dict)
        if boot_dev_dict['device_type'] == 'VMEDIA':
            res = self.boot_order_obj.check_vmedia_mapping(boot_dev_dict['device_sub_type'])
            if res  is not True:
                log.error('Failed to create VMEDIA mapping on the server for device: ')
        log.info('Remove boot device, if any created already')
        self.boot_order_obj.remove_boot_dev()
        '''Create boot and configure boot device'''
        res = self.boot_order_obj.create_and_configure_boot_device(boot_device, con_obj)
        if res is False:
            self.failed('Failed to create boot device for device type: ' + boot_device)
        elif res is 'SKIP':
            self.skipped('Boot device ' + boot_device + ' not configured on the testbed, Skipping test.')
        else:
            log.info('successfully created boot device for device type' + boot_device)
        log.info('Boot verify dictionary:')
        boot_verify_dict = {k:v for k, v in (x.split(':') for x in boot_dev_dict['verify'].split(','))}
        log.info(boot_verify_dict)
        cmd = boot_verify_dict['cmd']
        '''Power cycle host and verify whether host has booted to respective boot device'''
        if boot_verify_dict['ssh_telnet'] == 'ssh':
            log.info('Validation: connecting host over SSH')
            cimc_util_obj.power_cycle_host()
            res1 = self.host_util_obj.check_file_on_host(self.host_handle, cmd)
        elif boot_verify_dict['ssh_telnet'] == 'telnet':
            log.info('Validation: connecting host over telnet')
            self.host_serial_handle.connect_to_host_serial()
            cimc_util_obj.power_cycle_host()
            log.info('Waiting for host to boot into respective boot device')
            cimc_util_obj.verify_host_up(self.host_ip, wait_for_ping_fail=False, wait_time=500)
            res1 = self.host_serial_handle.check_file_on_console_host(cmd)
            self.host_serial_handle.disconnect()
        elif boot_verify_dict['ssh_telnet'] == 'console_log':
            log.info('Validation: connecting host over telnet and verify console logs')
            self.host_serial_handle.connect_to_host_serial()
            cimc_util_obj.power_cycle_host()
            log.info('Expected string is: ' + str(cmd.encode()))
            res1 = self.host_serial_handle.validate_host_console_output(exp_string=cmd.encode())
            self.host_serial_handle.disconnect()
        else:
            log.error('Invalid choice, please re-check testbed config file')
        '''Verify configured boot device and actual boot device should match '''
        try:
            act_boot_device = boot_dev_dict['act_device_type']
        except:
            act_boot_device = boot_dev_dict['device_type']
        log.info('verify the actual boot order after host reboot')
        res2 = self.boot_order_obj.verify_host_booted_from_configured_device(act_boot_device)
        if res1 is True and res2 is True:
            self.passed('Test Passed')
        else:
            self.failed('Test Failed')
    @aetest.test.loop(uids=['verify_boot_when_wrong_attr_set'], parameter=['HDD'])
    def verify_boot_when_wrong_attr_set(self, cimc_util_obj, config, parameter, con_obj):
        '''Verify boot device when wrong attribute set'''
        log.info('Verify that the host boots to the other available configured device \
                by setting the wrong attributes')
        boot_mode = con_obj.get('BootDeviceDetail', 'boot_mode')
        #if boot_mode != 'Legacy' or boot_mode != 'Uefi':
        #    self.skipped('Testbed is not configured to test this test, skipping test')
        boot_order_obj = BootOrder(cimc_util_obj, config)
        boot_device = 'myPXE'
        boot_dev_dict = {}
        try:
            options = con_obj.options(boot_device)
        except KeyError:
            self.skipped('PXE boot device not configured on testbed config file')
        for option in options:
            boot_dev_dict[option] = con_obj.get(boot_device, option)
        log.info('Boot configure parameters:')
        log.info(boot_dev_dict)
        boot_config_dict = {k:v for k, v in (x.split(':') for x in boot_dev_dict['config'].split(','))}
        slot_id = boot_config_dict['slot']
        port_id = boot_config_dict['port']
        log.info('Slot: %s and port: %s' % (slot_id, port_id))
        log.info(boot_config_dict)
        log.info('remove existing boot device if any')
        boot_order_obj.remove_boot_dev()
        log.info('create PXE boot device and enable the state, set order to 1, and wrong slot')
        if boot_order_obj.create_and_config_pxe_boot_device(slot_id, port_id, device_type='PXE', wrong_slot='MLOM') is False:
            self.failed('Failed to create PXE boot device')
        log.info('create LOCALHDD boot device and enable the state, set order to 2')
        if boot_order_obj.create_and_config_localhdd_boot_device(device_type=parameter, dev_order='2') is False:
            self.failed('Failed to create LOCALHDD boot device')
        log.info('Power cycle the host and verify that host boots into PXE boot device')
        boot_order_obj.powercycle_and_wait_for_host_comes_up()
        log.info('verify the actual boot order after host reboot')
        res1 = boot_order_obj.verify_host_booted_from_configured_device(device_type=parameter)
        if res1 is True:
            self.passed('Test Passed')
        else:
            self.failed('Test Failed')
    @aetest.test.loop(uids=['host_reboot', 'cimc_reboot', 'apc_cycle'], parameter=['host', 'cimc', 'apc_cycle'])
    def verify_last_boot_order_source_retain(self, cimc_util_obj, config, parameter, con_obj):
        '''Verify last boot order source'''
        log.info('To verify whether the last boot order source is retained on ' + parameter)
        boot_mode = con_obj.get('BootDeviceDetail', 'boot_mode')
        #if boot_mode != 'Legacy' or boot_mode != 'Uefi':
        #    self.skipped('Testbed is not configured to test this test, skipping test')
        boot_order_obj = BootOrder(cimc_util_obj, config)
        log.info('remove existing boot device if any')
        boot_order_obj.remove_boot_dev()
        log.info('create LOCALHDD boot device')
        boot_device = 'myLOCALHDD_RHEL'
        boot_dev_dict = {}
        try:
            options = con_obj.options(boot_device)
        except KeyError:
            self.skipped('LOCALHDD boot device not configured on this testbed')
        for option in options:
            boot_dev_dict[option] = con_obj.get(boot_device, option)
        log.info('Remove boot device, if any created already')
        boot_order_obj.remove_boot_dev()
        res = boot_order_obj.create_and_configure_boot_device(boot_device, con_obj)
        if res is False:
            self.failed('Failed to create boot device for device type: ' + boot_device)
        elif res is 'SKIP':
            self.skipped('Boot device ' + boot_device + ' not configured on the testbed, Skipping test.')
        else:
            log.info('successfully created boot device for device type' + boot_device)
        log.info('Reboot the respective component and check for last boot order source is retained ')
        if boot_order_obj.reboot_operations(parameter) is False:
            self.failed('Failed to power cycle the %s' % (parameter))
        res = boot_order_obj.last_update_config(exp_last_source='CIMC')
        if res is True:
            self.passed('Test Passed')
        else:
            self.failed('Test Failed')
Пример #12
0
class BasisBootOrderTest(aetest.Testcase):
    '''Basic Boot order setup'''
    @aetest.setup
    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())
    @aetest.test
    def verify_basic_boot_order(self, cimc_util_obj, boot_device, con_obj):
        log.info('Configuring and testing of %s basic boot device' %(boot_device))
        basic_boot_dev_dict = {}
        options = con_obj.options(boot_device)
        for option in options:
            basic_boot_dev_dict[option] = con_obj.get(boot_device, option)
        log.info('Basic boot configure parameters:')
        log.info(basic_boot_dev_dict)
        log.info('Boot verify dictionary:')
        basic_boot_verify_dict = {k:v for k, v in (x.split(':') for x in basic_boot_dev_dict['verify'].split(','))}
        log.info(basic_boot_verify_dict)
        try:
            act_boot_device = basic_boot_dev_dict['act_device_type']
        except:
            act_boot_device = basic_boot_dev_dict['device_type']
        '''Create basic boot device '''
        res = self.boot_order_obj.create_basic_boot_order(boot_device, act_boot_device)
        if res is False:
            self.failed('Failed to create %s boot device' %(boot_device))
        cmd = basic_boot_verify_dict['cmd']
        if basic_boot_verify_dict['ssh_telnet'] == 'ssh':
            log.info('Validation: connecting host over SSH')
            cimc_util_obj.power_cycle_host()
            res1 = self.host_util_obj.check_file_on_host(self.host_handle, cmd)
        elif basic_boot_verify_dict['ssh_telnet'] == 'telnet':
            log.info('Validation: connecting host over telnet')
            self.host_serial_handle.connect_to_host_serial()
            cimc_util_obj.power_cycle_host()
            log.info('Waiting for host to boot into respective boot device')
            cimc_util_obj.verify_host_up(self.host_ip, wait_for_ping_fail=False, wait_time=500)
            res1 = self.host_serial_handle.check_file_on_console_host(cmd)
            self.host_serial_handle.disconnect()
        elif basic_boot_verify_dict['ssh_telnet'] == 'console_log':
            log.info('Validation: connecting host over serial and verify console logs')
            self.host_serial_handle.connect_to_host_serial()
            cimc_util_obj.power_cycle_host()
            log.info('Expected string is: ' + str(cmd.encode()))
            res1 = self.host_serial_handle.validate_host_console_output(exp_string=cmd.encode())
            self.host_serial_handle.disconnect()
        else:
            log.error('Invalid choice, please re-check testbed config file')
        '''Verify configured boot device and actual boot device should match '''
        log.info('verify the actual boot order after host reboot')
        res2 = self.boot_order_obj.verify_host_booted_from_configured_device(act_boot_device)
        if res1 is True and res2 is True:
            self.passed('Test Passed')
        else:
            self.failed('Test Failed')
Пример #13
0
 def __init__(self, cimc_util_obj, config):
     self.cimc_util_obj = cimc_util_obj
     self.config = config
     self.boot_order_obj = BootOrder(cimc_util_obj, config)
Пример #14
0
class MemoryModeAndPorTest(aetest.Testcase):
    '''
    Note :mem_mode_array=["Maximum_Performance", "Mirroring", "Lockstep"]
     has to be passed from the job file
    '''
    @aetest.setup
    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)

    @aetest.test
    def validate_memory_config_in_cimc_and_host(self, mem_mode, cimc_util_obj,
                                                config):
        '''
        Test case covers configuring memory mode and validating in CIMC , host,
        EFI Shell , BIOS post
        '''
        mem_obj = MemoryLib(cimc_util_obj)
        self.mem_obj = mem_obj
        # set memory mode
        res_mem_mode = mem_obj.configure_ras_mode(mem_mode)
        res_host_up = False
        if res_mem_mode == True:
            logger.info('Memory mode configured successfully')
            #host_ip = config.host_info[0].host_detail.os_host_name
            # power cycle host
            cimc_util_obj.power_cycle_host()
            time.sleep(60)
            # verify host is up
            res_host_up = cimc_util_obj.verify_host_up(hostname=self.host_ip,
                                                       wait_for_ping_fail=True)
            if res_host_up:
                logger.info(
                    'Host rebooted successfully after memory configuration')
            else:
                output = self.boot_order_obj.set_boot_order_HDD()
                if output == 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.warning(
                        'Issue with host reboot starting to collect tech support'
                    )
                    cimc_util_obj.upload_techsupport_data()
                    self.failed('Issue with host')
            # verify memory por after config
            res_mem_por = mem_obj.verify_expected_frequency()
            # verify total and effective memory
            res_mem_config = mem_obj.verify_memory_config()
            # Linux host validation
            host_details = config.host_info[0].host_detail
            self.host_handle = LinuxUtils(host_details.os_host_name,
                                          host_details.os_login,
                                          host_details.os_password)
            self.host_handle.connect()
            mem_obj = MemoryLib(cimc_util_obj, self.host_handle)
            self.mem_obj = mem_obj
            res_mem_host = mem_obj.verify_memory_config_in_linux_host()
            res_mem_efi = mem_obj.verify_memory_config_in_efi_shell()
            if res_mem_por and res_mem_config and res_mem_host and res_mem_efi[
                    0] and res_mem_efi[1]:
                self.passed('memory validation in host is successful')
            else:
                logger.error(
                    'memory por , mem_config ,host results,EFI and POST results are below:'
                )
                logger.error(res_mem_por)
                logger.error(res_mem_config)
                logger.error(res_mem_host)
                logger.error(res_mem_efi[0])
                logger.error(res_mem_efi[1])
                self.failed('Issue with memory validation in host')
        else:
            logger.error('Issue in configuring memory mode')
            cimc_util_obj.upload_techsupport_data()
            self.failed('test cases failed because of memory configuration')

    @aetest.test
    def verify_dimm_pid(self, cimc_util_obj, config):
        '''
        validates cimc dimm pid inventory with config file
        '''
        mem_obj = MemoryLib(cimc_util_obj)
        self.mem_obj = mem_obj
        mem_dict = mem_obj.get_mem_pid()
        dimm_validation = True
        for val in mem_dict:
            if mem_dict[val] in config.dimm_pid:
                continue
            else:
                dimm_validation = False
                logger.error('DIMM pid not found in list' + str(mem_dict[val]))
        if dimm_validation:
            logger.info('PID list from config')
            logger.info(config.dimm_pid)
            self.passed('DIMM PID verified')
        else:
            self.failed('DIMM PID verification failed')

    @aetest.test
    def cpu_and_memory_stress_using_ptu(self, cimc_util_obj):
        '''
        Runs ptugen and ptumon and monitor for any errors
        '''
        host_ping_status = cimc_util_obj.verify_host_up(
            hostname=self.host_ip, wait_for_ping_fail=False, wait_time=30)
        if host_ping_status is True:
            logger.info("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:
                    self.failed(
                        "Testcase failed .... since Unabke to boot to OS")
        host = self.host
        host_utils = self.host_utils
        ptu_gen_cmd = "/root/tools/ptugen -ct 1 -mt 2 -t "
        ptu_gen_log_path = 'cat /root/tools/ptu_gen_file.txt'
        wait_time = 60
        host.connect()
        time.sleep(5)
        logs_before_stress = host_utils.get_host_logs(host)
        cimc_log_before = cimc_util_obj.get_cimc_sel_log_latest_event()
        sel_log_before = cimc_util_obj.get_cimc_sel_log_latest_event(
            log_scope='sel')
        logger.info(
            "Successfully booted to os after token change without any error")
        ptugen_out = host_utils.start_ptu_gen(host,
                                              ptu_gen_cmd,
                                              wait=wait_time)
        time.sleep(wait_time)
        ptumon_out = host_utils.get_ptu_monitor_out(host, scope='MEM')
        time.sleep(wait_time)
        ptugen_out = host.execute_cmd(ptu_gen_log_path,
                                      buffer_size=500000,
                                      wait_time=wait_time)
        logs_after_stress = host_utils.get_host_logs(host)
        cimc_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
            cimc_log_before)
        cimc_log_flag = True
        sel_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
            sel_log_before, log_scope='sel')
        sel_log_flag = True
        host_log_flag = host_utils.check_host_logs_diff(
            logs_before_stress, logs_after_stress)
        logger.info('ptugen out')
        logger.info(ptugen_out)
        logger.info('ptumon out')
        logger.info(ptumon_out)
        host.disconnect()
        if host_log_flag and cimc_log_flag and sel_log_flag:
            self.passed("Stress ran successfully")
        else:
            self.failed("Issue during stress")

    @aetest.test
    def mprime_test(self, cimc_util_obj):
        '''
        Runs mprime and monitor for error
        '''
        host_ping_status = cimc_util_obj.verify_host_up(
            hostname=self.host_ip, wait_for_ping_fail=False, wait_time=30)
        if host_ping_status is True:
            logger.info("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:
                    self.failed(
                        "Testcase failed .... since Unabke to boot to OS")
        mprime_cmd = "/root/tools/mprime >> /root/tools/mprime.txt &"
        mprime_stress_time = 1800
        mprime_pid = ''
        mprime_kill = "kill -9 " + mprime_pid
        host = self.host
        host_utils = self.host_utils
        host.connect()
        logs_before_stress = host_utils.get_host_logs(host)
        cimc_log_before = cimc_util_obj.get_cimc_sel_log_latest_event()
        sel_log_before = cimc_util_obj.get_cimc_sel_log_latest_event(
            log_scope='sel')
        mprime_pid = host.execute_cmd(mprime_cmd)
        mprime_pid = self.get_pid(mprime_pid)
        time.sleep(mprime_stress_time)
        logger.info('mprime pid is : ' + mprime_pid)
        host.execute_cmd(mprime_kill)
        time.sleep(5)
        logs_after_stress = host_utils.get_host_logs(host)
        cimc_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
            cimc_log_before)
        sel_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
            sel_log_before, log_scope='sel')
        sel_log_flag = True
        host_log_flag = host_utils.check_host_logs_diff(
            logs_before_stress, logs_after_stress)
        host.disconnect()
        if host_log_flag and cimc_log_flag and sel_log_flag:
            self.passed("Stress ran successfully")
        else:
            self.failed("Issue during stress")

    @aetest.test
    def specjvm_test(self, cimc_util_obj):
        '''
        Runs specjvm at 30,90 and 180 ops and checks for error in
        host , cimc log , sel log
        '''
        host_ping_status = cimc_util_obj.verify_host_up(
            hostname=self.host_ip, wait_for_ping_fail=False, wait_time=30)
        if host_ping_status is True:
            logger.info("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:
                    self.failed(
                        "Testcase failed .... since Unabke to boot to OS")
        ops_list = [30, 90, 180]
        spec_jvm_pid = ''
        spec_jvm_kill = "kill -9 " + spec_jvm_pid
        time_out = 2
        host = self.host
        host.connect()
        host_utils = self.host_utils
        host_log_flag = False
        sel_log_flag = False
        cimc_log_flag = False
        handle_2 = LinuxUtils(host.ip, host.username, host.password)
        handle_2.connect()
        for ops in ops_list:
            logger.info("Running specJVM at " + str(ops) + " Ops")
            logs_before_stress = host_utils.get_host_logs(host)
            cimc_log_before = cimc_util_obj.get_cimc_sel_log_latest_event()
            sel_log_before = cimc_util_obj.get_cimc_sel_log_latest_event(
                log_scope='sel')
            spec_jvm_cmd = "java -jar /root/tools/SPECjvm2008.jar -ikv -ops " + \
                str(ops) + " crypto.aes > /root/tools/specjvm.txt 2>&1 &"
            spec_jvm_pid = self.get_pid(handle_2.execute_cmd(spec_jvm_cmd))
            start_time = strftime("%H", gmtime())
            end_time = strftime("%H", gmtime())
            time.sleep((3600 * time_out) / 4)
            while (abs(int(start_time) - int(end_time)) <= time_out):
                end_time = strftime("%H", gmtime())
                out = host.execute_cmd("ps -ef | grep SPECjvm")
                ps_out = '\t'.join([line.strip() for line in out.splitlines()])
                logger.info("process out is" + ps_out)
                if spec_jvm_pid in ps_out:
                    time.sleep(60)
                else:
                    break
            if (abs(int(start_time) - int(end_time))) > time_out:
                host.execute_cmd('kill -9 ' + spec_jvm_pid)
            logs_after_stress = host_utils.get_host_logs(host)
            cimc_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
                cimc_log_before)
            cimc_log_flag = True
            sel_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
                sel_log_before, log_scope='sel')
            sel_log_flag = True
            host_log_flag = host_utils.check_host_logs_diff(
                logs_before_stress, logs_after_stress)
            if host_log_flag and cimc_log_flag and sel_log_flag:
                continue
            else:
                self.failed("Difference in host log")
        host.disconnect()
        handle_2.disconnect()
        if host_log_flag:
            self.passed("Spec JVM ran successfully")
        else:
            self.failed("Difference in host log")

    @aetest.test
    def mem_test(self, cimc_util_obj):
        '''Random value,XOR comparison,SUB comparison,MUL comparison,DIV comparison,OR comparison ,AND comparison
        Sequential Increment, Block Sequential, Solid Bits, Bit Flip, Checkerboard ,Walking Ones ,Walking Zeroes , Bit Spread
        '''
        host_ping_status = cimc_util_obj.verify_host_up(
            hostname=self.host_ip, wait_for_ping_fail=False, wait_time=30)
        if host_ping_status is True:
            logger.info("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:
                    self.failed(
                        "Testcase failed .... since Unabke to boot to OS")
        memory_in_mb = '20000'
        memtest_cmd = "memtester " + memory_in_mb + \
            " >> /root/tools/memtest.txt &"
        memtest_stress_time = 1800
        memtest_pid = ''
        memtest_kill = "kill -9 " + memtest_pid
        host = self.host
        host_utils = self.host_utils
        host.connect()
        logs_before_stress = host_utils.get_host_logs(host)
        cimc_log_before = cimc_util_obj.get_cimc_sel_log_latest_event()
        sel_log_before = cimc_util_obj.get_cimc_sel_log_latest_event(
            log_scope='sel')
        memtest_pid = host.execute_cmd(memtest_cmd)
        memtest_pid = self.get_pid(memtest_pid)
        time.sleep(memtest_stress_time)
        logger.info('memtest pid is : ' + memtest_pid)
        host.execute_cmd(memtest_kill)
        time.sleep(5)
        logs_after_stress = host_utils.get_host_logs(host)
        cimc_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
            cimc_log_before)
        cimc_log_flag = True
        sel_log_flag = cimc_util_obj.check_cimc_sel_log_diff_event(
            sel_log_before, log_scope='sel')
        sel_log_flag = True
        host_log_flag = host_utils.check_host_logs_diff(
            logs_before_stress, logs_after_stress)
        host.disconnect()
        if host_log_flag and sel_log_flag and cimc_log_flag:
            self.passed("Stress ran successfully")
        else:
            self.failed("Issue during stress")

    def get_pid(self, process_log):
        '''
        process the log and gets the process id
        '''
        return process_log.splitlines()[1].replace('[1]', '').replace(' ', '')
Пример #15
0
class ProcessorUtils():
    '''
    Holding collections of object required for processor
    '''
    def __init__(self, obj):
        self.bios_util_obj = obj
        self.handle = obj.handle
        self.boot_order_obj = BootOrder(self.bios_util_obj.cimc_obj)
        self.cpu_details = []
        self.processor_config = self.load_cpu_obj()
        self.msr = {"IntelTurboBoostTech" : "1A0", "EnhancedIntelSpeedStep" : "1A0",
                    "ExecuteDisable":"1A0", "HardwarePrefetch":"1A4",
                    "AdjacentCacheLinePrefetch":"1A4", "DirectCacheAccess":"1F8",
                    "lt_lock_memory":"2E7", "pkg_cst":"E2", "plat_info":"0CE",
                    "power_ctl":"1FC", "dynamic_switch":"1FC", "perf_bias":"1FC",
                    "c1e":"1FC", "ia32_energy":"1B0", "Hwpm":"1AA",
                    "cpu_cstate":"E2", 'IA32_Energy_Performance_BIAS':'1B0'}

    def is_msr_bitSet(self, operand, mask_string, flag, bit_position):
        '''
        Bit Manipulator
        Procedure to masks the bits of the msr value per core to get
        the value of the required bit
        Parameter:
        param: operant - Corevalue from EFI
               mask_string - Mask value
               flag - "and" or "or"
               bit_position - bit position to check
        Return:
            Bit value: Success
            False : Failure

        Author: Suren kumar Moorthy
        '''
        try:
            per_core_value = int("0x" + operand, 16)
            mask_value = int("0x" + mask_string, 16)
            if flag == "and":
                res = per_core_value & mask_value
                if res > 0:
                    bit_array = list("{0:b}".format(res))
                    bit_array.reverse()
                    return bit_array[int(bit_position)]
                else:
                    return res
            elif flag == "or":
                return per_core_value | mask_value
            else:
                return False
        except:
            dump_error_in_lib()
            return False

    def get_cpu_info(self):
        '''
        Get Cpu info from CimcUtils
        Procedure loads the cpu info in processor object

        Return:
            Object populated with processor details : SUCCESS
            False : FAILURE

        Authhor : Suren Kumar Moorthy
        '''
        try:

            self.handle.execute_cmd_list("top", "scope chassis")
            out = self.handle.execute_cmd("show cpu detail")
            token_list = ["name", "manufacturer", "family", "thread-count", 'core-count',
                          "version", "current-speed", "signature", 'cpu-status']
            main_param_list = []
            out_list = out.split("---")
            for out_bloc in out_list[1:]:
                param_list = []
                for token in token_list:
                    regex = re.escape(token) + r'\s*\:\s+([^\r\n]+)'
                    value = re.search(regex, out_bloc).group(1)
                    param_list.append(value)
                    if token == 'version':                        
                        model_regex = r'(?:(?:Xeon\(R\)\s*CPU\s+([a-zA-Z0-9\s\-]+)\s+\@)|(?:Xeon\(R\)\s*([a-zA-Z0-9\s\-]+)\s+CPU))'
                        model_reg_out = re.search(model_regex, value)
                        model = str(model_reg_out.group(2)) if model_reg_out.group(1) is None else str(model_reg_out.group(1))                        
                        print('=========*****========****====')
                        print(model)
                        print('=========*****========****====')
                        rep1 = re.compile(r'\s$')
                        model = rep1.sub('', model)
                        rep2 = re.compile(r'\s+')
                        model = rep2.sub('-', model)
                param_list.append(model)
                main_param_list.append(param_list)
            self.handle.execute_cmd_list("top", "scope chassis")
            pid_out = self.handle.execute_cmd("show cpu-pid detail", wait_time=20)
            token_list_pid = ["Description", "PID"]
            pid_out_list = pid_out.split("---")
            i = 0
            for pid_out_bloc in pid_out_list[1:]:
                for token_pid in token_list_pid:
                    regex_pid = re.escape(token_pid) + r'\s*\:\s+([^\r\n]+)'
                    value_pid = re.search(regex_pid, pid_out_bloc).group(1)
                    main_param_list[i].append(value_pid)
                self.cpu_details.append(Processor(main_param_list[i][0], main_param_list[i][1],
                                                  main_param_list[i][2], main_param_list[i][3],
                                                  main_param_list[i][4], main_param_list[i][5],
                                                  main_param_list[i][6], main_param_list[i][7],
                                                  main_param_list[i][8], main_param_list[i][9],
                                                  main_param_list[i][10], main_param_list[i][11]))
                i += 1
            return self.cpu_details
        except:
            dump_error_in_lib()
            return False
    def get_cpu_info_host(self, host_handle, token=None):
        '''
            Collect proccesor information like threads and core from
            host

            Parameter :
                host handle
                token : passing this token will send
                        only the specific tokens(thread,cores)

            Return :
                Returns dictionary with host details
                if token parameter is none else it will
                return the token value : Success
                False : Failure
        '''
        try:
            cpu_info_host = {}
            out = host_handle.execute_cmd("cat /proc/cpuinfo", buffer_size=100000, wait_time=20)
            cpu_info_host['thread'] = len(re.findall(r'processor\s*\:\s*(\d+)', out))
            cpu_info_host['cores'] = re.search(r'cpu\s*cores\s*\:\s*(\d+)', out).group(1)
            if token is None:
                return cpu_info_host
            else:
                return cpu_info_host[token]
        except:
            dump_error_in_lib()
            return False

    def verify_cpu_info(self, cpu_info, token):
        '''
        Verify Cpu info from CimcUtils
        Procedure verify the cpu parameter with
        corresponding processor model in processor config

        Return:
            Object populated with processor details : SUCCESS
            False : FAILURE

        Authhor : Suren Kumar Moorthy
        '''
        try:
            logger.info(getattr(self.processor_config, token))
            if getattr(cpu_info, token) in getattr(self.processor_config, token):
                return True
            else:
                return False

        except:
            dump_error_in_lib()
            return False

    def load_cpu_obj(self):
        '''
            To Load CPU object from config
            Return:
                Object populated with processor details : SUCCESS
                False : FAILURE

            Authhor : Suren Kumar Moorthy
        '''
        try:
            logger.info("Loading CPU object from Config")
            self.handle.execute_cmd_list("top", "scope chassis")
            out = self.handle.execute_cmd("show cpu detail")
            regex = r'(?:(?:Xeon\(R\)\s*CPU\s+([a-zA-Z0-9\s\-]+)(?:\s+)?\@)|(?:Xeon\(R\)\s*([a-zA-Z0-9\s\-]+)\s+CPU))'
            model_reg_out = re.search(regex, out)
            model = str(model_reg_out.group(2)) if model_reg_out.group(1) is None else str(model_reg_out.group(1))
            rep = re.compile(r'\s+$')
            model = rep.sub('', model)
            rep = re.compile(r'\s+')
            model = rep.sub('-', model)
            logger.info('Model selected: ' +model)
            con = ConfigParser()
            proccessor_config = con.load_processor_config(model).proceesor_details
            return proccessor_config
        except:
            dump_error_in_lib()
            return False

    def verify_msr_mode(self, mode, mask_id, bit, verify_bit, out=None):
        '''
            To verify the mode
            Parameter :
                mode : MSR value
                mask_id : Mask id for the msr value
                bit : which bit to check(Ex : 18 th bit)
                verify_bit : Bit to verify (1 or 0)
            Return:
                True or false

            Author : Suren Kumar Moorthy
        '''
        try:
            if out is None:
                host_serial_handle = self.bios_util_obj.cimc_obj.telnet_handle
                efi_out = self.boot_order_obj.boot_to_efi_shell()
                if efi_out is False:
                    return False
                msr_input = 'MSR ' + self.msr[mode]
                out = host_serial_handle.execute_cmd_serial_host(msr_input, wait_time=40)
                logger.info(out)
                host_serial_handle.disconnect()
                time.sleep(60)
            match = re.search(r'\d+\s+\d+\s+\d+\s+([0-9A-Z]{8})\s+([0-9A-Z]{8})', out)
            if match is None:
                logger.error('Unknown MSR Output')
                return False
            core = 1
            fail_flag = 0
            pattern = re.compile(r'\d+\s+\d+\s+\d+\s+([0-9A-Z]{8})\s+([0-9A-Z]{8})')
            for (data1, msr_bit) in re.findall(pattern, out):
                msr_val = data1 + msr_bit
                logger.info("Verify BIT value" + msr_val)
                bit_val = self.is_msr_bitSet(msr_val, mask_id, "and", bit)
                logger.info("Bit Value got is %s" % bit_val)
                logger.info("verify Value got is %s" % verify_bit)
                if int(bit_val) == int(verify_bit):
                    logger.info("Bit value for core " + str(core) + " passed")
                else:
                    fail_flag = 1
                core += 1
            if fail_flag == 1:
                return False
            else:
                return out
        except:
            dump_error_in_lib()
            return False

    def get_smbiosview_processor_param(self, smbios_view):
        '''
            Procedure to get specific tokens form smbios view 4 and 7
            with respective to processor test cases

            Return:
                In case of smbios view 4 returns dictionary of tokens
                In case of smbios 7 returns list of dictionary

            Author : Suren Kumar Moorthy
        '''
        try:
            host_serial_handle = self.bios_util_obj.cimc_obj.telnet_handle
            efi_out = self.boot_order_obj.boot_to_efi_shell()
            smbios_view_token_list = {
                '4' : {'smbios_version' : 'Version', 'name' : 'Socket', \
                       'current_speed' : 'CurrentSpeed', \
                       'processor_upgrade':'Processor Upgrade', \
                       'core_count' : 'CoreCount', \
                       }, \
                 '7' : ['Cache Error Correcting Type', 'Cache System Cache Type']\
            }

            smbios_input = 'smbiosview -t ' + smbios_view
            out = host_serial_handle.execute_cmd_serial_host(smbios_input, wait_time=40)
            logger.info(out)

            if smbios_view == '4':
                smbios_dict = defaultdict(dict)
                for tok in smbios_view_token_list[smbios_view].keys():
                    regex = re.escape(smbios_view_token_list[smbios_view][tok]) + \
                                      r'\s*\:\s+([^\r\n]+)'
                    smbios_dict[tok] = re.search(regex, out, re.IGNORECASE).group(1)
                ret = smbios_dict
            else:
                pattern = re.compile(
                    r'(Type\=7\s*\,[\w\W]*?CPU\s*Internal\s*L3\s*(?:[\w\s]+\s*\:\s*[^\r\n]+\s*)*)')
                cpu = []
                tokens = smbios_view_token_list[smbios_view]
                for core_block in re.findall(pattern, out):
                    smbios_dict = defaultdict(dict)
                    cache_array = re.compile("[=]+?[\n\r]").split(core_block)
                    if len(cache_array) < 4:
                        logger.error("smbios view output format is improper")
                        ret = False
                    else:
                        cache_name = ['l1_cache', 'l1_cache_p', 'l2_cache', 'l3_cache']
                        for cache_key, cache_level in zip(cache_name, cache_array):
                            smbios_dict[cache_key] = defaultdict(dict)
                            for token in tokens:
                                regex = re.escape(token) + r'\s*\:\s*([^\r\n]+)'
                                value = re.search(regex, cache_level).group(1)
                                smbios_dict[cache_key][token] = value
                        cpu.append(smbios_dict)
                ret = cpu

            host_serial_handle.disconnect()
            return ret
        except:
            dump_error_in_lib()
            return False
Пример #16
0
    def verify_memory_config_in_efi_shell(self):
        boot_order_lib = BootOrder(self.cimc_utils_obj)
        memory_cmd = 'Smbiosview -t 203'
        total_mem = ''
        eff_mem = ''
        eff_mem_mode = ''
        mem_vol_efi = 0.0
        boot_result = boot_order_lib.boot_to_efi_shell(post_flag=True)
        logger.info('Boot result data is')
        logger.info(boot_result)
        boot_result = re.sub('[^A-Za-z0-9]+', '', boot_result[1])
        total_mem_post = re.search(r'TotalMemory(.*?)GB', boot_result).group(1)
        logger.info('Total mem post:' + total_mem_post)
        eff_mem_post = re.search(r'EffectiveMemory(.*?)GB',
                                 boot_result).group(1)
        operating_speed_post = re.search(r'MemoryOperatingSpeed(.*?)Mhz',
                                         boot_result).group(1)
        telnet_handle = self.cimc_utils_obj.telnet_handle
        efi_output = telnet_handle.execute_cmd_serial_host(memory_cmd)
        logger.info('EFI shell output is:' + efi_output)
        for data in efi_output.splitlines():
            if 'Total Memory' in data:
                total_mem = data.split(':')[1]
            elif 'Effective Memory' in data:
                eff_mem = data.split(':')[1]
            elif 'Operating Memory Mode' in data:
                eff_mem_mode = data.split(':')[1].replace(" ", "")
                if eff_mem_mode == 'Independent':
                    logger.info('Check1: MaximumPerformance')
                    eff_mem_mode = 'MaximumPerformance'
                if eff_mem_mode == 'MirrorMode':
                    logger.info('Check2: MirrorMode1LM')
                    eff_mem_mode = 'MirrorMode1LM'
            elif 'Operating Memory Voltage' in data:
                mem_vol_efi = float(
                    data.split(':')[1].replace('0V', '').replace(' ', ''))
        mem_vol_cli = self.get_mem_voltage()
        mem_summary = self.get_memory_summary()
        eff_mem_cli = mem_summary['effectivememory']
        total_mem_cli = mem_summary['totalmemory']
        ras_mode_cli = mem_summary['configuration']
        mem_speed = mem_summary['memoryspeed'].replace(' ',
                                                       '').replace('MHz', '')
        logger.info('POST data below:')
        logger.info(total_mem_post)
        logger.info(eff_mem_post)
        logger.info(operating_speed_post)
        logger.info(mem_speed)
        boot_order_lib.change_boot_order(boot_option='hdd')
        telnet_handle.disconnect()
        '''BIOS POST verification
        '''
        total_mem_post = int(total_mem_post) * 1024
        eff_mem_post = int(eff_mem_post) * 1024
        post_result = False

        logger.info(
            'EFI:: total_mem_post: %s and cli: %s' %
            (total_mem_post, total_mem_cli.replace(' ', '').replace('MB', '')))
        logger.info('EFI:: eff_mem_post: %s and cli: %s' %
                    (eff_mem_post,
                     int(eff_mem_cli.replace(' ', '').replace('MB', ''))))
        logger.info('EFI:: operating speed %s and cli %s' %
                    (operating_speed_post, mem_speed))
        if total_mem_post == int(
                total_mem_cli.replace(' ', '').replace(
                    'MB', '')) and eff_mem_post == int(
                        eff_mem_cli.replace(' ', '').replace(
                            'MB', '')) and operating_speed_post == mem_speed:
            logger.info('Memory validation ins post passed')
            post_result = True
        else:
            logger.error('memory validation in post failed')
            logger.error('Total mem in post:' + str(total_mem_post) +
                         ' and cli:' +
                         total_mem_cli.replace(' ', '').replace('MB', ''))
            logger.error('eff mem in post:' + str(eff_mem_post) + ' and cli:' +
                         eff_mem_cli.replace(' ', '').replace('MB', ''))
            logger.error('mem freq in post:' + operating_speed_post +
                         ' and cli:' + mem_speed)
            post_result = False

        #if total_mem.replace('\s', '') == total_mem_cli.replace('\s', '') and eff_mem.replace('\s', '') == eff_mem_cli.replace(
        #        '\s', '') and eff_mem_mode.replace('\s', '') == ras_mode_cli.replace('\s', '') and mem_vol_cli == mem_vol_efi:
        #    logger.info('mem validation success in efi shell')
        #    return [True, post_result]
        if total_mem.replace('\s', '') == total_mem_cli.replace(
                '\s', '') and eff_mem.replace('\s', '') == eff_mem_cli.replace(
                    '\s', '') and eff_mem_mode.replace(
                        ' ', '') == ras_mode_cli.replace(' ', ''):
            logger.info('mem validation success in efi shell')
            return [True, post_result]
        else:
            logger.error('memory validation in EFI shell failed')
            logger.error('Total mem in efi:' + total_mem + ' and cli:' +
                         total_mem_cli)
            logger.error('eff mem in efi:' + eff_mem + ' and cli:' +
                         eff_mem_cli)
            logger.error('mem mode in efi:' + eff_mem_mode + ' and cli:' +
                         ras_mode_cli)
            logger.error('memory voltage in efi:' + str(mem_vol_efi) +
                         'and cli:' + str(mem_vol_cli))
            return [False, post_result]
Пример #17
0
class SystemDetailsCapture(object):
    '''
       Class SystemDetails Lib for System Details capture
    '''
    def __init__(self, cimc_util_obj, config):
        self.cimc_util_obj = cimc_util_obj
        self.config = config
        self.boot_order_obj = BootOrder(cimc_util_obj, config)

    def connect_host_execute_command(self,
                                     testbed_name,
                                     cmd,
                                     cmd_wait_time=None):
        '''
        proc to Connect to host and return the output of the executed command
        return - False if failed
        '''
        smbios_obj = SmbiosLib()
        os_handle = self.cimc_util_obj.host_handle
        host_os_ip = smbios_obj.get_host_mgmt_ip(self.config)
        host_ping_status = self.cimc_util_obj.verify_host_up(
            hostname=host_os_ip, wait_for_ping_fail=False, wait_time=600)

        if host_ping_status is True:
            logger.info("Host OS is pinging  ...")
            time.sleep(10)
            os_handle.connect()
        else:
            output = self.boot_order_obj.set_boot_order_HDD()
            if output == True:
                host_ping_status = self.cimc_util_obj.verify_host_up(
                    hostname=host_os_ip,
                    wait_for_ping_fail=False,
                    wait_time=600)
                if host_ping_status is True:
                    logger.info("Host OS is pinging  ...")
                    time.sleep(10)
                    os_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 host_ping_status is True:
            if cmd_wait_time == None:
                cmd_wait_time = 4
            output = os_handle.execute_cmd(cmd,
                                           buffer_size=150000,
                                           wait_time=cmd_wait_time)
            logger.info(output)
            os_handle.disconnect()
            return output

    def generate_file_from_output(self, output, file_name):
        '''
        generate the file based on the content and save the file to path
        return - True if successfull
        return - False if unsuccessfull
        '''
        logger.info(output)
        # ##convert Output to byts
        try:
            output = str(output).replace('\b', '')
            # ## open a file
            file_handle = open(file_name, "w")
            # ## dump the command output to the file
            file_handle.write(output)
            # ## close the file
            file_handle.close()
            logger.info("File is generated successfully  : " + file_name)
            # ## the save in the location /data/software/capture system details
            return True
        except:
            dump_error_in_lib()
            logger.error("Error in generating the file" + file_name)
            return False

    def copy_file_to_share(self, file_name, path_to_copy):
        '''
        copies the file to share path
        returns - True if successfull
        returns - False if unscessfull
        '''
        try:
            if not os.path.exists(path_to_copy):
                logger.info(
                    path_to_copy +
                    " Directory doesnt exists .Hence creating directory")
                os.makedirs(path_to_copy)
                os.chmod(path_to_copy, stat.S_IRWXO)
            copy_command = "cp -rf " + file_name + " " + path_to_copy
            copy_output = subprocess.check_output(copy_command,
                                                  shell=True,
                                                  stderr=subprocess.STDOUT)
            logger.info(str(copy_output))
            file_path = path_to_copy + file_name
            if os.path.exists(file_path):
                logger.info("Successfull copied the file to the path :" +
                            file_path)
                return True
            else:
                logger.error("Error in copying the file: " + file_name +
                             "to directory:" + path_to_copy)
                return False
        except:
            dump_error_in_lib()
            logger.error("Expection obtained in Copying the file" + file_name +
                         "to directory:" + path_to_copy)
            return False

    def file_compare(self, file_path_1, file_path_2):
        '''
        Compares two files and returns True if there is no difference
        '''
        try:
            file1 = open(file_path_1, "r")
            file2 = open(file_path_2, 'r')
            file_diff = difflib.context_diff(file1.readlines(),
                                             file2.readlines())
            delta = ''.join(file_diff)
            if not delta:
                logger.info(
                    " There is not differece between the STD and Lstest data" +
                    str(delta))
                return True
            else:
                logger.error(
                    " There is difference between STD and latest data" +
                    str(delta))
                return False
        except:
            dump_error_in_lib()
            logger.info(
                " Exception obtained while comparing the STD and laetst config files"
            )
            return False

    def get_slot_cimc(self):

        try:
            mgmt_handle = self.cimc_util_obj.handle

            output = mgmt_handle.execute_cmd_list(
                'top', 'scope chassis', 'show network-adapter detail')
            slot_id = []
            logger.info("Output......" + output)
            for block in output.split("---")[1:]:
                slot = re.search(r'Slot:*\s+([^\r\n]+)', block).group(1)
                slot_id.append(slot)
                interface = re.search(r'NoOfInterfaces:*\s+([^\r\n]+)',
                                      block).group(1)
                logger.info(str(interface))
                logger.info("SLot info ...." + slot)
            return slot_id
        except:
            dump_error_in_lib()
            logger.error(" Error in getting SLOT ID")
            return False

    def get_mac_cimc(self, slot_id):

        try:
            mgmt_handle = self.cimc_util_obj.handle
            for val in slot_id:
                output = mgmt_handle.execute_cmd_list(
                    'scope network-adapter ' + str(val),
                    'show mac-list detail')
                mac_address = []
                for block in output.split("---")[1:]:
                    mac = re.search(r'MacAddress:*\s+([^\r\n]+)',
                                    block).group(1)
                    mac_address.append(mac)
                    logger.info("cimc mac info...." + str(mac_address))
                return mac_address
        except:
            dump_error_in_lib()
            logger.error(" Error in getting  MAC address for the SLOT ID" +
                         slot_id)
            return False