Пример #1
0
    def setUp(self):
        '''
        get all parameters
        '''
        self.option = self.params.get("test_opt", default='')
        self.tool = self.params.get("tool", default='')
        self.warn_msg = self.params.get("warn_msg", default='')
        self.pci_device = self.params.get("pci_device", default=None)

        if self.pci_device:
            if 'LOC_CODE' in self.option:
                location_code = pci.get_slot_from_sysfs(self.pci_device)
                self.option = self.option.replace('LOC_CODE', location_code)
            if 'INTERFACE' in self.option:
                adapter_type = pci.get_pci_class_name(self.pci_device)
                interface = pci.get_interfaces_in_pci_address(
                    self.pci_device, adapter_type)[0]
                self.option = self.option.replace('INTERFACE', interface)

        if 'DEVICE_PATH_NAME' in self.option:
            adapter_type = pci.get_pci_class_name(self.pci_device)
            interface = pci.get_interfaces_in_pci_address(
                self.pci_device, adapter_type)[0]
            path = '/sys/class/net/%s/device/uevent' % interface
            output = open(path, 'r').read()
            for line in output.splitlines():
                if "OF_FULLNAME" in line:
                    device_path_name = line.split('=')[-1]
            self.option = self.option.replace('DEVICE_PATH_NAME',
                                              device_path_name)

        smm = SoftwareManager()
        if not smm.check_installed("pciutils") and not smm.install("pciutils"):
            self.cancel("pciutils package is need to test")
Пример #2
0
    def setUp(self):
        """
        Setup the device.
        """
        if 'ppc' not in platform.processor():
            self.cancel("Processor is not ppc64")
        if os.path.exists('/proc/device-tree/bmc'):
            self.cancel("Test Unsupported! on this platform")
        if 'pSeries' in open('/proc/cpuinfo', 'r').read():
            for mdl in ['rpaphp', 'rpadlpar_io']:
                if not linux_modules.module_is_loaded(mdl):
                    linux_modules.load_module(mdl)
        elif 'PowerNV' in open('/proc/cpuinfo', 'r').read():
            if not linux_modules.module_is_loaded("pnv_php"):
                linux_modules.load_module("pnv_php")
        self.dic = {}
        self.device = self.params.get('pci_devices', default="")
        self.peer_ip = self.params.get('peer_ip', default="")
        self.count = int(self.params.get('count', default='1'))
        if not self.device:
            self.cancel("PCI_address not given")
        self.device = self.device.split(" ")
        smm = SoftwareManager()
        if not smm.check_installed("pciutils") and not smm.install("pciutils"):
            self.cancel("pciutils package is need to test")

        for pci_addr in self.device:
            if not os.path.isdir('/sys/bus/pci/devices/%s' % pci_addr):
                self.cancel("%s not present in device path" % pci_addr)
            slot = pci.get_slot_from_sysfs(pci_addr)
            if not slot:
                self.cancel("slot number not available for: %s" % pci_addr)
            self.dic[pci_addr] = slot
Пример #3
0
    def setUp(self):
        '''
        Gather necessary test inputs.
        Test all services.
        '''
        self.install_packages()
        self.rsct_service_start()
        self.hmc_ip = self.params.get("hmc_ip", '*', default=None)
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
        self.hmc_username = self.params.get("hmc_username", '*', default=None)
        self.lpar_1 = self.params.get("lpar_1", '*', default=None)
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.server = self.params.get("server", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.login(self.hmc_ip, self.hmc_username, self.hmc_pwd)
        self.run_command("uname -a")
        cmd = 'lshwres -r io -m %s --rsubtype slot --filter lpar_names=%s ' \
              '-F drc_index,lpar_id,drc_name,bus_id' % (self.server,
                                                        self.lpar_1)
        output = self.run_command(cmd)
        for line in output:
            if self.loc_code in line:
                self.drc_index = line.split(',')[0]
                self.lpar_id = line.split(',')[1]
                self.phb = line.split(',')[3]
                break

        self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s, phb: %s",
                      self.lpar_id, self.loc_code, self.drc_index, self.phb)
Пример #4
0
 def test_get_slot_from_sysfs(self):
     pcid = "0002:01:00.1"
     file_values = [
         "S0001",
         "S0001[",
         "Slot2",
         "SLOT1",
         "Backplane USB",
         "U78CB.001.WZS07CU-P1-C9-T1",
         "PLX Slot1",
         "Onboard USB",
         "U78D5.001.CSS130E-P1-P2-P2-C1-T1",
     ]
     expected_values = [
         "S0001",
         "S0001",
         "Slot2",
         "SLOT1",
         "Backplane USB",
         "U78CB.001.WZS07CU-P1-C9",
         "PLX Slot1",
         "Onboard USB",
         "U78D5.001.CSS130E-P1-P2-P2-C1",
     ]
     for value, exp in zip(file_values, expected_values):
         with unittest.mock.patch("os.path.isfile", return_value=True):
             with unittest.mock.patch("avocado.utils.genio.read_file",
                                      return_value=value):
                 self.assertEqual(pci.get_slot_from_sysfs(pcid), exp)
Пример #5
0
 def test_get_slot_from_sysfs(self):
     pcid = '0002:01:00.1'
     file_values = ['S0001', 'S0001[', 'Slot2', 'SLOT1', 'Backplane USB', 'U78CB.001.WZS07CU-P1-C9-T1', 'PLX Slot1', 'Onboard USB', 'U78D5.001.CSS130E-P1-P2-P2-C1-T1']
     expected_values = ['S0001', 'S0001', 'Slot2', 'SLOT1', 'Backplane USB', 'U78CB.001.WZS07CU-P1-C9', 'PLX Slot1', 'Onboard USB', 'U78D5.001.CSS130E-P1-P2-P2-C1']
     for value, exp in zip(file_values, expected_values):
         with unittest.mock.patch('os.path.isfile', return_value=True):
             with unittest.mock.patch('avocado.utils.genio.read_file',
                                      return_value=value):
                 self.assertEqual(pci.get_slot_from_sysfs(pcid), exp)
Пример #6
0
    def setUp(self):
        '''
        Gather necessary test inputs.
        Test all services.
        '''
        self.install_packages()
        self.rsct_service_start()
        self.hmc_ip = self.get_mcp_component("HMCIPAddr")
        if not self.hmc_ip:
            self.cancel("HMC IP not got")
        self.hmc_user = self.params.get("hmc_username", default='hscroot')
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default='********')
        self.lpar_1 = self.get_partition_name("Partition Name")
        if not self.lpar_1:
            self.cancel("LPAR Name not got from lparstat command")
        self.login(self.hmc_ip, self.hmc_user, self.hmc_pwd)
        cmd = 'lssyscfg -r sys  -F name'
        output = self.run_command(cmd)
        self.server = ''
        for line in output:
            if line in self.lpar_1:
                self.server = line
                break
        cmd = 'lssyscfg -r lpar -F name -m %s' % self.server
        output = self.run_command(cmd)
        for line in output:
            if "%s-" % self.lpar_1 in line:
                self.lpar_1 = line
                break
        if not self.server:
            self.cancel("Managed System not got")
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        if self.lpar_2 is not None:
            cmd = 'lshwres -r io -m %s --rsubtype slot --filter lpar_names=%s ' \
                   '-F lpar_id' % (self.server, self.lpar_2)
            output = self.run_command(cmd)
            self.lpar2_id = output[0]
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.run_command("uname -a")
        cmd = 'lshwres -r io -m %s --rsubtype slot --filter lpar_names=%s ' \
              '-F drc_index,lpar_id,drc_name,bus_id' % (self.server,
                                                        self.lpar_1)
        output = self.run_command(cmd)
        for line in output:
            if self.loc_code in line:
                self.drc_index = line.split(',')[0]
                self.lpar_id = line.split(',')[1]
                self.phb = line.split(',')[3]
                break

        self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s, phb: %s",
                      self.lpar_id, self.loc_code, self.drc_index, self.phb)
Пример #7
0
    def setUp(self):
        '''
        set up required packages and gather necessary test inputs
        '''
        sm = SoftwareManager()
        detected_distro = distro.detect()
        self.log.info("Test is running on:" + detected_distro.name)
        if not sm.check_installed("ksh") and not sm.install("ksh"):
            self.error('ksh is needed for the test to be run')
        if detected_distro.name == "Ubuntu":
            if not sm.check_installed("python-paramiko") and not \
                                      sm.install("python-paramiko"):
                self.error('python-paramiko is needed for the test to be run')
            ubuntu_url = self.params.get('ubuntu_url', default=None)
            debs = self.params.get('debs', default=None)
            for deb in debs:
                deb_url = os.path.join(ubuntu_url, deb)
                deb_install = self.fetch_asset(deb_url, expire='7d')
                shutil.copy(deb_install, self.srcdir)
                process.system("dpkg -i %s/%s" % (self.srcdir, deb),
                               ignore_status=True,
                               sudo=True)
        else:
            url = self.params.get('url', default=None)
            rpm_install = self.fetch_asset(url, expire='7d')
            shutil.copy(rpm_install, self.srcdir)
            os.chdir(self.srcdir)
            process.run('chmod +x ibmtools')
            process.run('./ibmtools --install --managed')
        self.hmc_ip = self.params.get("hmc_ip", '*', default=None)
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
        self.hmc_username = self.params.get("hmc_username", '*', default=None)
        self.lpar_1 = self.params.get("lpar_1", '*', default=None)
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.server = self.params.get("server", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.login(self.hmc_ip, self.hmc_username, self.hmc_pwd)
        self.run_command("uname -a")
        cmd = 'lshwres -r io -m ' + self.server + \
              ' --rsubtype slot --filter lpar_names=' + self.lpar_1 + \
              ' -F drc_index,lpar_id,drc_name | grep -i %s ' % self.loc_code

        output = self.run_command(cmd)
        self.drc_index = output[-1].split(',')[0]
        self.lpar_id = output[-1].split(',')[1]
        self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s",
                      self.lpar_id, self.loc_code, self.drc_index)
Пример #8
0
    def setUp(self):
        '''
        set up required packages and gather necessary test inputs
        '''
        sm = SoftwareManager()
        detected_distro = distro.detect()
        self.log.info("Test is running on:" + detected_distro.name)
        if not sm.check_installed("ksh") and not sm.install("ksh"):
            self.error('ksh is needed for the test to be run')
        if detected_distro.name == "Ubuntu":
            if not sm.check_installed("python-paramiko") and not \
                                      sm.install("python-paramiko"):
                self.error('python-paramiko is needed for the test to be run')
            ubuntu_url = self.params.get('ubuntu_url', default=None)
            debs = self.params.get('debs', default=None)
            for deb in debs:
                deb_url = os.path.join(ubuntu_url, deb)
                deb_install = self.fetch_asset(deb_url, expire='7d')
                shutil.copy(deb_install, self.srcdir)
                process.system("dpkg -i %s/%s" % (self.srcdir, deb),
                               ignore_status=True, sudo=True)
        else:
            url = self.params.get('url', default=None)
            rpm_install = self.fetch_asset(url, expire='7d')
            shutil.copy(rpm_install, self.srcdir)
            os.chdir(self.srcdir)
            process.run('chmod +x ibmtools')
            process.run('./ibmtools --install --managed')
        self.hmc_ip = self.params.get("hmc_ip", '*', default=None)
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
        self.hmc_username = self.params.get("hmc_username", '*', default=None)
        self.lpar_1 = self.params.get("lpar_1", '*', default=None)
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.server = self.params.get("server", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.login(self.hmc_ip, self.hmc_username, self.hmc_pwd)
        self.run_command("uname -a")
        cmd = 'lshwres -r io -m ' + self.server + \
              ' --rsubtype slot --filter lpar_names=' + self.lpar_1 + \
              ' -F drc_index,lpar_id,drc_name | grep -i %s ' % self.loc_code

        output = self.run_command(cmd)
        self.drc_index = output[-1].split(',')[0]
        self.lpar_id = output[-1].split(',')[1]
        self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s",
                      self.lpar_id, self.loc_code, self.drc_index)
Пример #9
0
 def test_get_slot_from_sysfs(self):
     pcid = '0002:01:00.1'
     file_values = [
         'S0001', 'S0001[', 'Slot2', 'SLOT1', 'Backplane USB',
         'U78CB.001.WZS07CU-P1-C9-T1', 'PLX Slot1', 'Onboard USB',
         'U78D5.001.CSS130E-P1-P2-P2-C1-T1'
     ]
     expected_values = [
         'S0001', 'S0001', 'Slot2', 'SLOT1', 'Backplane USB',
         'U78CB.001.WZS07CU-P1-C9', 'PLX Slot1', 'Onboard USB',
         'U78D5.001.CSS130E-P1-P2-P2-C1'
     ]
     for value, exp in zip(file_values, expected_values):
         with mock.patch('os.path.isfile', return_value=True):
             with mock.patch('avocado.utils.genio.read_file',
                             return_value=value):
                 self.assertEqual(pci.get_slot_from_sysfs(pcid), exp)
    def usys(self, tool, option, pci_device):
        '''
        run usysident and usysattn
        '''
        location_code = pci.get_slot_from_sysfs(pci_device)
        interface = pci.get_interfaces_in_pci_address(pci_device, "net")[0]
        cmd = "%s %s" % (tool, option)
        if '-P' in cmd:
            cmd += " -l %s" % location_code
        if '-t' in cmd:
            cmd += " -d %s" % interface

        result = process.run(cmd, shell=True, ignore_status=True)
        if tool == "usysident":
            if "There is no identify indicator" in result.stdout_text:
                self.log.warn("%s option %s failed" % (tool, self.option))
        elif tool == "usysattn":
            if "There is no fault indicator" in result.stdout_text:
                self.log.warn("%s option %s failed" % (tool, self.option))
Пример #11
0
    def setUp(self):
        '''
        set up required packages and gather necessary test inputs.
        Test all services.
        '''
        smm = SoftwareManager()
        detected_distro = distro.detect()
        self.log.info("Test is running on: %s", detected_distro.name)
        if not smm.check_installed("ksh") and not smm.install("ksh"):
            self.cancel('ksh is needed for the test to be run')
        if detected_distro.name == "Ubuntu":
            if not smm.check_installed("python-paramiko") and not \
                                      smm.install("python-paramiko"):
                self.cancel('python-paramiko is needed for the test to be run')
            ubuntu_url = self.params.get('ubuntu_url', default=None)
            debs = self.params.get('debs', default=None)
            for deb in debs:
                deb_url = os.path.join(ubuntu_url, deb)
                deb_install = self.fetch_asset(deb_url, expire='7d')
                shutil.copy(deb_install, self.workdir)
                process.system("dpkg -i %s/%s" % (self.workdir, deb),
                               ignore_status=True,
                               sudo=True)
        else:
            url = self.params.get('url', default=None)
            rpm_install = self.fetch_asset(url, expire='7d')
            shutil.copy(rpm_install, self.workdir)
            os.chdir(self.workdir)
            process.run('chmod +x ibmtools')
            process.run('./ibmtools --install --managed')
        try:
            process.run("startsrc -g rsct", shell=True, sudo=True)
        except CmdError as details:
            self.log.debug(str(details))
            self.cancel("Command startsrc -g rsct failed")

        try:
            process.run("startsrc -g rsct_rm", shell=True, sudo=True)
        except CmdError as details:
            self.log.debug(str(details))
            self.cancel("Command startsrc -g rsct_rm failed")

        output = process.system_output("lssrc -a",
                                       ignore_status=True,
                                       shell=True,
                                       sudo=True)
        if "inoperative" in output:
            self.cancel("Failed to start the rsct and rsct_rm services")

        self.hmc_ip = self.params.get("hmc_ip", '*', default=None)
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default=None)
        self.hmc_username = self.params.get("hmc_username", '*', default=None)
        self.lpar_1 = self.params.get("lpar_1", '*', default=None)
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.server = self.params.get("server", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.login(self.hmc_ip, self.hmc_username, self.hmc_pwd)
        self.run_command("uname -a")
        cmd = 'lshwres -r io -m %s --rsubtype slot --filter lpar_names=%s ' \
              '-F drc_index,lpar_id,drc_name,bus_id' % (self.server,
                                                        self.lpar_1)
        output = self.run_command(cmd)
        for line in output:
            if self.loc_code in line:
                self.drc_index = line.split(',')[0]
                self.lpar_id = line.split(',')[1]
                self.phb = line.split(',')[3]
                break

        self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s, phb: %s",
                      self.lpar_id, self.loc_code, self.drc_index, self.phb)
Пример #12
0
    def test(self):
        '''
        Test
        '''
        error = []
        for pci_addr in pci.get_pci_addresses():
            self.log.info("Checking for PCI Address: %s\n\n", pci_addr)
            vpd_output = pci.get_vpd(pci_addr)
            if vpd_output:

                # Slot Match
                if 'slot' in vpd_output:
                    sys_slot = pci.get_slot_from_sysfs(pci_addr)
                    if sys_slot:
                        sys_slot = sys_slot.strip('\0')
                    vpd_slot = vpd_output['slot']
                    self.log.info("Slot from sysfs: %s", sys_slot)
                    self.log.info("Slot from lsvpd: %s", vpd_slot)
                    if sys_slot in [sys_slot, vpd_slot[:vpd_slot.rfind('-')]]:
                        self.log.info("=======>>> slot matches perfectly\n\n")
                    else:
                        error.append(pci_addr + "-> slot")
                        self.log.info("--->>Slot Numbers not Matched\n\n")
                else:
                    self.log.error("Slot info not available in vpd output\n")

                # Device ID match
                sys_pci_id_output = pci.get_pci_id_from_sysfs(pci_addr)
                vpd_device_id = vpd_output['pci_id'][4:]
                sysfs_device_id = sys_pci_id_output[5:-10]
                self.log.info("Device ID from sysfs: %s", sysfs_device_id)
                self.log.info("Device ID from vpd: %s", vpd_device_id)
                if vpd_device_id == sysfs_device_id:
                    self.log.info("=======>>Device ID Match Success\n\n")
                else:
                    self.log.error("----->>Device ID did not Match\n\n")
                    error.append(pci_addr + "-> Device_id")

                # Subvendor ID Match
                sysfs_subvendor_id = sys_pci_id_output[10:-5]
                vpd_subvendor_id = vpd_output['pci_id'][:4]
                self.log.info("Subvendor ID frm sysfs: %s", sysfs_subvendor_id)
                self.log.info("Subvendor ID from vpd : %s", vpd_subvendor_id)
                if sysfs_subvendor_id == vpd_subvendor_id:
                    self.log.info("======>>>Subvendor ID Match Success\n\n")
                else:
                    self.log.error("---->>Subvendor_id Not Matched\n\n")
                    error.append(pci_addr + "-> Subvendor_id")

                # PCI ID Match
                lspci_pci_id = pci.get_pci_id(pci_addr)
                self.log.info(" PCI ID from Sysfs: %s", sys_pci_id_output)
                self.log.info("PCI ID from Vpd : %s", lspci_pci_id)

                if sys_pci_id_output == lspci_pci_id:
                    self.log.info("======>>>> All PCI ID match Success\n\n")
                else:
                    self.log.error("---->>>PCI info Did not Matches\n\n")
                    error.append(pci_addr + "-> pci_id")

                # PCI Config Space Check
                if process.system("lspci -xxxx -s %s" % pci_addr,
                                  ignore_status=True,
                                  sudo=True):
                    error.append(pci_addr + "->pci_config_space")

        if error:
            self.fail("Errors for above pci addresses: %s" % error)
Пример #13
0
    def test(self):
        '''
        Test
        '''
        error = []
        for pci_adres in pci.get_pci_addresses():
            print "Comparing for PCI Adress : ", pci_adres, "\n\n"
            vpd_output = pci.get_vpd(pci_adres)
            if vpd_output:
                '''
                Slot Match
                '''
                if vpd_output.has_key('slot'):
                    sys_slot = pci.get_slot_from_sysfs(pci_adres)
                    if sys_slot:
                        sys_slot = sys_slot.strip('\0')
                    vpd_slot = vpd_output['slot']
                    self.log.info("Slot from sysfs:%s", sys_slot)
                    self.log.info("Slot from lsvpd:%s", vpd_slot)
                    if sys_slot in [sys_slot, vpd_slot[:vpd_slot.rfind('-')]]:
                        self.log.info("=======>>> slot matches perfectly\n\n")
                    else:
                        error.append(pci_adres + "->slot")
                        self.log.info("--->>Slot Numbers not Matched\n\n")
                else:
                    self.log.error("Slot info not available in vpd output\n")
                '''
                Device ID match
                '''
                sys_pci_id_output = pci.get_pci_id_from_sysfs(pci_adres)
                vpd_device_id = vpd_output['pci_id'][4:]
                sysfs_device_id = sys_pci_id_output[5:-10]
                self.log.info("Device ID from sysfs :%s", sysfs_device_id)
                self.log.info("Device ID from vpd:%s", vpd_device_id)
                if vpd_device_id == sysfs_device_id:
                    self.log.info("=======>>Device ID Match Success\n\n")
                else:
                    self.log.error("----->>Device ID did not Match\n\n")
                    error.append(pci_adres + "->Device_id")
                '''
                Subvendor ID Match
                '''
                sysfs_subvendor_id = sys_pci_id_output[10:-5]
                vpd_subvendor_id = vpd_output['pci_id'][:4]
                self.log.info("Subvendor ID frm sysfs:%s", sysfs_subvendor_id)
                self.log.info("Subvendor ID from vpd :%s", vpd_subvendor_id)
                if sysfs_subvendor_id == vpd_subvendor_id:
                    self.log.info("======>>>Subvendor ID Match Success\n\n")
                else:
                    self.log.error("---->>Subvendor_id Not Matched\n\n")
                    error.append(pci_adres + "->Subvendor_id")
                '''
                PCI ID Match
                '''
                lspci_pci_id = pci.get_pci_id(pci_adres)
                self.log.info(" PCI ID from Sysfs:%s", sys_pci_id_output)
                self.log.info("PCI ID from Vpd :%s", lspci_pci_id)

                if sys_pci_id_output == lspci_pci_id:
                    self.log.info("======>>>> All PCI ID match Success\n\n")
                else:
                    self.log.error("---->>>PCI info Did not Matches\n\n")
                    error.append(pci_adres + "->pci_id")

        if error:
            self.log.error("failed pci addresses:%s", error)
            self.fail("Data mismatched for above pci addresses:")
Пример #14
0
    def setUp(self):
        '''
        Gather necessary test inputs.
        Test all services.
        '''
        self.session = None
        self.install_packages()
        self.rsct_service_start()
        self.hmc_ip = self.get_mcp_component("HMCIPAddr")
        if not self.hmc_ip:
            self.cancel("HMC IP not got")
        self.hmc_user = self.params.get("hmc_username", default='hscroot')
        self.hmc_pwd = self.params.get("hmc_pwd", '*', default='********')
        self.sriov = self.params.get("sriov", default="no")
        self.lpar_1 = self.get_partition_name("Partition Name")
        if not self.lpar_1:
            self.cancel("LPAR Name not got from lparstat command")
        self.session = Session(self.hmc_ip, user=self.hmc_user,
                               password=self.hmc_pwd)
        if not self.session.connect():
            self.cancel("failed connecting to HMC")
        cmd = 'lssyscfg -r sys  -F name'
        output = self.session.cmd(cmd)
        self.server = ''
        for line in output.stdout_text.splitlines():
            if line in self.lpar_1:
                self.server = line
                break
        if not self.server:
            self.cancel("Managed System not got")
        self.lpar_2 = self.params.get("lpar_2", '*', default=None)
        if self.lpar_2 is not None:
            cmd = 'lshwres -r io -m %s --rsubtype slot --filter \
                   lpar_names=%s -F lpar_id' % (self.server, self.lpar_2)
            output = self.session.cmd(cmd)
            self.lpar2_id = output.stdout_text[0]
        self.pci_device = self.params.get("pci_device", '*', default=None)
        self.loc_code = pci.get_slot_from_sysfs(self.pci_device)
        self.num_of_dlpar = int(self.params.get("num_of_dlpar", default='1'))
        if self.loc_code is None:
            self.cancel("Failed to get the location code for the pci device")
        self.session.cmd("uname -a")
        if self.sriov == "yes":
            cmd = "lshwres -r sriov --rsubtype logport -m %s \
            --level eth --filter lpar_names=%s -F \
            'adapter_id,logical_port_id,phys_port_id,lpar_id,location_code,drc_name'" \
                   % (self.server, self.lpar_1)
            output = self.session.cmd(cmd)
            for line in output.stdout_text.splitlines():
                if self.loc_code in line:
                    self.adapter_id = line.split(',')[0]
                    self.logical_port_id = line.split(',')[1]
                    self.phys_port_id = line.split(',')[2]
                    self.lpar_id = line.split(',')[3]
                    self.location_code = line.split(',')[4]
                    self.phb = line.split(',')[5].split(' ')[1]
                    break
            self.log.info("lpar_id : %s, loc_code: %s",
                          self.lpar_id, self.loc_code)
        else:
            cmd = 'lshwres -r io -m %s --rsubtype slot \
                   --filter lpar_names=%s -F drc_index,lpar_id,drc_name,bus_id' \
                   % (self.server, self.lpar_1)
            output = self.session.cmd(cmd)
            for line in output.stdout_text.splitlines():
                if self.loc_code in line:
                    self.drc_index = line.split(',')[0]
                    self.lpar_id = line.split(',')[1]
                    self.phb = line.split(',')[3]
                    break

            self.log.info("lpar_id : %s, loc_code: %s, drc_index: %s, phb: %s",
                          self.lpar_id, self.loc_code, self.drc_index,
                          self.phb)
    def test(self):
        '''
        Test
        '''
        error = []
        for pci_addr in pci.get_pci_addresses():
            self.log.info("Checking for PCI Address: %s\n\n", pci_addr)
            vpd_output = pci.get_vpd(pci_addr)
            if vpd_output:

                # Slot Match
                if 'slot' in vpd_output:
                    sys_slot = pci.get_slot_from_sysfs(pci_addr)
                    if sys_slot:
                        sys_slot = sys_slot.strip('\0')
                    vpd_slot = vpd_output['slot']
                    self.log.info("Slot from sysfs: %s", sys_slot)
                    self.log.info("Slot from lsvpd: %s", vpd_slot)
                    if sys_slot in [sys_slot, vpd_slot[:vpd_slot.rfind('-')]]:
                        self.log.info("=======>>> slot matches perfectly\n\n")
                    else:
                        error.append(pci_addr + "-> slot")
                        self.log.info("--->>Slot Numbers not Matched\n\n")
                else:
                    self.log.error("Slot info not available in vpd output\n")

                # Device ID match
                sys_pci_id_output = pci.get_pci_id_from_sysfs(pci_addr)
                vpd_dev_id = vpd_output['pci_id'][4:]
                sysfs_dev_id = sys_pci_id_output[5:-10]
                sysfs_sdev_id = sys_pci_id_output[15:]
                self.log.info("Device ID from sysfs: %s", sysfs_dev_id)
                self.log.info("Sub Device ID from sysfs: %s", sysfs_sdev_id)
                self.log.info("Device ID from vpd: %s", vpd_dev_id)
                if vpd_dev_id == sysfs_sdev_id or vpd_dev_id == sysfs_dev_id:
                    self.log.info("=======>>Device ID Match Success\n\n")
                else:
                    self.log.error("----->>Device ID did not Match\n\n")
                    error.append(pci_addr + "-> Device_id")

                # Subvendor ID Match
                sysfs_subvendor_id = sys_pci_id_output[10:-5]
                vpd_subvendor_id = vpd_output['pci_id'][:4]
                self.log.info("Subvendor ID frm sysfs: %s", sysfs_subvendor_id)
                self.log.info("Subvendor ID from vpd : %s", vpd_subvendor_id)
                if sysfs_subvendor_id == vpd_subvendor_id:
                    self.log.info("======>>>Subvendor ID Match Success\n\n")
                else:
                    self.log.error("---->>Subvendor_id Not Matched\n\n")
                    error.append(pci_addr + "-> Subvendor_id")

                # PCI ID Match
                lspci_pci_id = pci.get_pci_id(pci_addr)
                self.log.info(" PCI ID from Sysfs: %s", sys_pci_id_output)
                self.log.info("PCI ID from Vpd : %s", lspci_pci_id)

                if sys_pci_id_output == lspci_pci_id:
                    self.log.info("======>>>> All PCI ID match Success\n\n")
                else:
                    self.log.error("---->>>PCI info Did not Matches\n\n")
                    error.append(pci_addr + "-> pci_id")

                # PCI Config Space Check
                if process.system("lspci -xxxx -s %s" % pci_addr,
                                  ignore_status=True, sudo=True):
                    error.append(pci_addr + "->pci_config_space")

        if error:
            self.fail("Errors for above pci addresses: %s" % error)