Ejemplo n.º 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())
Ejemplo n.º 2
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)
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
 def initial_setup(self, cimc_util_obj):
     '''
     Initial Setups
     '''
     global classparam
     classparam['bios_obj'] = cimc_util_obj.bios_util_obj
     classparam['procc_obj'] = ProcessorUtils(classparam['bios_obj'])
     classparam['cpu_info'] = classparam['procc_obj'].get_cpu_info()
     classparam['host_utils'] = HostUtils()
Ejemplo n.º 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())
Ejemplo n.º 6
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 ##############################################
        '''
Ejemplo n.º 7
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)
Ejemplo n.º 8
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')
Ejemplo n.º 9
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')
Ejemplo n.º 10
0
 def set_known_host_remove_selectors(self):
     self.known_host_remove_selectors = HostUtils.host_selectors(_Const().get_known_host_remove_selectors,
                                                                 self.article.domain)
Ejemplo n.º 11
0
 def set_known_host_remove_selectors(self):
     self.known_host_remove_selectors = HostUtils.host_selectors(KNOWN_HOST_REMOVE_SELECTORS,
                                                                 self.article.domain)
Ejemplo n.º 12
0
 def set_known_host_content_tags(self):
     self.known_host_content_tags = HostUtils.host_selectors(_Const().get_known_host_content_tags,
                                                             self.article.domain)
Ejemplo n.º 13
0
 def set_known_host_content_tags(self):
     self.known_host_content_tags = HostUtils.host_selectors(KNOWN_HOST_CONTENT_TAGS,
                                                             self.article.domain)
Ejemplo n.º 14
0
 def get_host_by_name(self, name):
     host_details = self.client.factory.create("EnumHostDetailLevel")
     response = self.client.service.hostRetrieveByName(name,
                                                       sID=self.session_id)
     return HostUtils(self.config).create_host(response)