class OpTestDropbearSafety():
    ##  Initialize this object
    #  @param i_bmcIP The IP address of the BMC
    #  @param i_bmcUser The userid to log into the BMC with
    #  @param i_bmcPasswd The password of the userid to log into the BMC with
    #  @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with
    #  @param i_bmcPasswdIpmi The password of BMC IPMI userid
    #  @param i_ffdcDir Optional param to indicate where to write FFDC
    #
    # "Only required for inband tests" else Default = None
    # @param i_hostIP The IP address of the HOST
    # @param i_hostuser The userid to log into the HOST
    # @param i_hostPasswd The password of the userid to log into the HOST with
    #
    def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd,
                 i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_hostip=None,
                 i_hostuser=None, i_hostPasswd=None):
        self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir)
        self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi,
                                  i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP)
        self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd,
                         i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip,
                         i_hostuser, i_hostPasswd)
        self.util = OpTestUtil()

    ##
    # @brief  This function will tests Dropbear running functionality in skiroot
    #         1. Power Off the system
    #         2. Power on the system
    #         3. Exit to the petitboot shell
    #         4. Execute ps command
    #         5. test will fail incase dropbear is running and listed out by ps
    #         6. At the end of test reboot the system to OS.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_dropbear_running(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()
        print "Test Dropbear running in Petitboot"
        print "Performing IPMI Power Off Operation"
        self.console = self.cv_SYSTEM.sys_get_ipmi_console()
        self.cv_SYSTEM.sys_ipmi_boot_system_to_petitboot(self.console)
        self.cv_IPMI.ipmi_host_set_unique_prompt(self.console)
        self.cv_IPMI.run_host_cmd_on_ipmi_console("uname -a")
        # we don't grep for 'dropbear' so that our naive line.count
        # below doesn't hit a false positive.
        res = self.cv_IPMI.run_host_cmd_on_ipmi_console("ps|grep drop")
        print res
        self.cv_IPMI.ipmi_set_boot_to_disk()
        for line in res:
            if line.count('dropbear'):
                raise OpTestError("drobear is running in the skiroot")
        return BMC_CONST.FW_SUCCESS
Ejemplo n.º 2
0
class OpTestPCI:
    ##  Initialize this object
    #  @param i_bmcIP The IP address of the BMC
    #  @param i_bmcUser The userid to log into the BMC with
    #  @param i_bmcPasswd The password of the userid to log into the BMC with
    #  @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with
    #  @param i_bmcPasswdIpmi The password of BMC IPMI userid
    #  @param i_ffdcDir Optional param to indicate where to write FFDC
    #
    # "Only required for inband tests" else Default = None
    # @param i_hostIP The IP address of the HOST
    # @param i_hostuser The userid to log into the HOST
    # @param i_hostPasswd The password of the userid to log into the HOST with
    #
    def __init__(
        self,
        i_bmcIP,
        i_bmcUser,
        i_bmcPasswd,
        i_bmcUserIpmi,
        i_bmcPasswdIpmi,
        i_ffdcDir=None,
        i_hostip=None,
        i_hostuser=None,
        i_hostPasswd=None,
        i_hostLspci=None,
    ):
        self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir)
        self.cv_IPMI = OpTestIPMI(
            i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd
        )
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP, i_ffdcDir)
        self.cv_SYSTEM = OpTestSystem(
            i_bmcIP,
            i_bmcUser,
            i_bmcPasswd,
            i_bmcUserIpmi,
            i_bmcPasswdIpmi,
            i_ffdcDir,
            i_hostip,
            i_hostuser,
            i_hostPasswd,
        )
        self.util = OpTestUtil()
        self.lspci_file = i_hostLspci

    ##
    # @brief  This function will get the PCI and USB susbsytem Info
    #         And also this test compares known good data of
    #         "lspci -mm -n" which is stored in testcases/data directory
    #         with the current lspci data.
    #         User need to specify the corresponding file name into
    #         machines xml like lspci.txt which contains "lspci -mm -n"
    #         command output in a working good state of system.
    #         tools used are lspci and lsusb
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_host_pci_devices_info(self):
        if self.lspci_file == "empty.txt":
            print "Skipping the pci devices comparision as missing the lspci data file name in machines xml"
            return BMC_CONST.FW_SUCCESS
        filename = os.path.join(os.path.dirname(__file__).split("testcases")[0], self.lspci_file)
        if not os.path.isfile(filename):
            raise OpTestError("lspci file %s not found in top level directory" % filename)
        self.pci_good_data_file = filename
        self.test_skiroot_pci_devices()
        self.cv_IPMI.ipmi_set_boot_to_disk()
        self.cv_IPMI.ipmi_power_off()
        self.cv_IPMI.ipmi_power_on()
        self.cv_IPMI.ipl_wait_for_working_state()
        self.test_host_pci_devices()

    ##
    # @brief  This function will get the "lspci -mm -n" output from the petitboot
    #         and compares it with known good lspci data
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_skiroot_pci_devices(self):
        cmd = "lspci -mm -n"
        self.console = self.cv_SYSTEM.sys_get_ipmi_console()
        self.cv_SYSTEM.sys_ipmi_boot_system_to_petitboot(self.console)
        self.cv_IPMI.ipmi_host_set_unique_prompt(self.console)
        self.cv_IPMI.run_host_cmd_on_ipmi_console("uname -a")
        self.cv_IPMI.run_host_cmd_on_ipmi_console("cat /etc/os-release")
        res = self.cv_IPMI.run_host_cmd_on_ipmi_console(cmd)
        self.cv_SYSTEM.sys_ipmi_close_console(self.console)
        self.pci_data_petitboot = "\n".join(res[1:])
        diff_process = subprocess.Popen(["diff", "-u", self.pci_good_data_file, "-"], stdin=subprocess.PIPE)
        diff_stdout, diff_stderr = diff_process.communicate(self.pci_data_petitboot + "\n")
        r = diff_process.wait()
        if r == 0:
            print "All the pci devices are detected at petitboot"
        else:
            print diff_stdout
            raise OpTestError("There is a mismatch b/w known good output and tested petitboot lspci output")

    ##
    # @brief  This function will get the "lspci -mm -n" output from the host OS
    #         and compares it with known good lspci data
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_host_pci_devices(self):
        self.cv_HOST.host_check_command("lspci", "lsusb")
        self.cv_HOST.host_list_pci_devices()
        self.cv_HOST.host_get_pci_verbose_info()
        self.cv_HOST.host_list_usb_devices()
        l_res = self.cv_HOST.host_run_command("lspci -mm -n")
        self.pci_data_hostos = l_res.replace("\r\n", "\n")
        diff_process = subprocess.Popen(["diff", "-u", self.pci_good_data_file, "-"], stdin=subprocess.PIPE)
        diff_stdout, diff_stderr = diff_process.communicate(self.pci_data_hostos)
        r = diff_process.wait()
        if r == 0:
            print "All the pci devices are detected in host OS"
        else:
            print diff_stdout
            raise OpTestError("There is a mismatch b/w known good output and tested host OS lspci output")
Ejemplo n.º 3
0
class OpTestNVRAM():
    ##  Initialize this object
    #  @param i_bmcIP The IP address of the BMC
    #  @param i_bmcUser The userid to log into the BMC with
    #  @param i_bmcPasswd The password of the userid to log into the BMC with
    #  @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with
    #  @param i_bmcPasswdIpmi The password of BMC IPMI userid
    #  @param i_ffdcDir Optional param to indicate where to write FFDC
    #
    # "Only required for inband tests" else Default = None
    # @param i_hostIP The IP address of the HOST
    # @param i_hostuser The userid to log into the HOST
    # @param i_hostPasswd The password of the userid to log into the HOST with
    #
    def __init__(self,
                 i_bmcIP,
                 i_bmcUser,
                 i_bmcPasswd,
                 i_bmcUserIpmi,
                 i_bmcPasswdIpmi,
                 i_ffdcDir=None,
                 i_hostip=None,
                 i_hostuser=None,
                 i_hostPasswd=None):
        self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir)
        self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi,
                                  i_ffdcDir, i_hostip, i_hostuser,
                                  i_hostPasswd)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP)
        self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd,
                                      i_bmcUserIpmi, i_bmcPasswdIpmi,
                                      i_ffdcDir, i_hostip, i_hostuser,
                                      i_hostPasswd)
        self.util = OpTestUtil()

    ##
    # @brief  This function tests nvram partition access, print/update
    #         the config data and dumping the partition's data. All
    #         these operations are done on supported partitions in both
    #         host OS and Petitboot.
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_nvram_configuration(self):
        # Execute these tests in host OS
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()
        self.cv_HOST.host_run_command("uname -a")
        self.cv_HOST.host_run_command("cat /etc/os-release")
        self.cv_HOST.host_run_command("nvram -v")
        self.cv_HOST.host_run_command("nvram --print-config -p ibm,skiboot")
        self.cv_HOST.host_run_command("nvram --print-config -p common")
        self.cv_HOST.host_run_command("nvram --print-config -p lnx,oops-log")
        self.cv_HOST.host_run_command("nvram --print-config -p wwwwwwwwwwww")
        self.cv_HOST.host_run_command("nvram --print-vpd")
        self.cv_HOST.host_run_command("nvram --print-all-vpd")
        self.cv_HOST.host_run_command("nvram --print-err-log")
        self.cv_HOST.host_run_command("nvram --print-event-scan")
        self.cv_HOST.host_run_command("nvram --partitions")
        self.cv_HOST.host_run_command("nvram --dump common")
        self.cv_HOST.host_run_command("nvram --dump ibm,skiboot")
        self.cv_HOST.host_run_command("nvram --dump lnx,oops-log")
        self.cv_HOST.host_run_command("nvram --dump wwwwwwwwwwww")
        self.cv_HOST.host_run_command("nvram --ascii common")
        self.cv_HOST.host_run_command("nvram --ascii ibm,skiboot")
        self.cv_HOST.host_run_command("nvram --ascii lnx,oops-log")
        self.cv_HOST.host_run_command("nvram --ascii wwwwwwwwwwww")
        try:
            self.test_nvram_update_part_config_in_host("common")
            self.test_nvram_update_part_config_in_host("ibm,skiboot")
            self.test_nvram_update_part_config_in_host("lnx,oops-log")
            self.test_nvram_update_part_config_in_host("wwwwwwwwwwww")
        except OpTestError:
            print "There is a failure in updating one of NVRAM partitions"

        # Execute these tests in petitboot
        self.console = self.cv_SYSTEM.sys_get_ipmi_console()
        try:
            self.cv_SYSTEM.sys_ipmi_boot_system_to_petitboot(self.console)
            self.cv_IPMI.ipmi_host_set_unique_prompt(self.console)
            self.cv_IPMI.run_host_cmd_on_ipmi_console("uname -a")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("cat /etc/os-release")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram -v")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --print-config -p ibm,skiboot")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --print-config -p common")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --print-config -p lnx,oops-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --print-config -p wwwwwwwwwwww")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-vpd")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-all-vpd")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-err-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --print-event-scan")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --partitions")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --dump common")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --dump ibm,skiboot")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --dump lnx,oops-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --dump wwwwwwwwwwww")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --ascii common")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --ascii ibm,skiboot")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --ascii lnx,oops-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console(
                "nvram --ascii wwwwwwwwwwww")
            try:
                self.test_nvram_update_part_config_in_petitboot("common")
                self.test_nvram_update_part_config_in_petitboot("ibm,skiboot")
                self.test_nvram_update_part_config_in_petitboot("lnx,oops-log")
                self.test_nvram_update_part_config_in_petitboot("wwwwwwwwwwww")
            except OpTestError:
                print "There is a failure in updating one of NVRAM partitions"
        except:
            self.cv_IPMI.ipmi_set_boot_to_disk()
        self.cv_IPMI.ipmi_set_boot_to_disk()

    ##
    # @brief This function tests nvram update/print config functions for partition i_part
    #        these functions will be tested in host OS
    #
    # @param i_part @type string:partition to access i.e common, ibm,skiboot etc
    #
    # @return l_res @type list: output of command or raise OpTestError
    #
    def test_nvram_update_part_config_in_host(self, i_part):
        part = i_part
        self.cv_HOST.host_run_command(
            "nvram -p %s --update-config 'test-cfg=test-value'" % part)
        res = self.cv_HOST.host_run_command(
            "nvram -p %s --print-config=test-cfg" % part)
        if "test-value" in res:
            print "Update config to the partition %s works fine" % part
        else:
            msg = "failed to update nvram config into the partition %s" % part
            print msg
            raise OpTestError(msg)

    ##
    # @brief This function tests nvram update/print config functions for partition i_part
    #        these functions will be tested in Petitboot.
    #
    # @param i_part @type string:partition to access i.e common, ibm,skiboot etc
    #
    # @return l_res @type list: output of command or raise OpTestError
    #
    def test_nvram_update_part_config_in_petitboot(self, i_part):
        part = i_part
        self.cv_IPMI.run_host_cmd_on_ipmi_console(
            "nvram -p %s --update-config 'test-cfg=test-value'" % part)
        res_list = self.cv_IPMI.run_host_cmd_on_ipmi_console(
            "nvram -p %s --print-config=test-cfg" % part)
        res = ''.join(res_list)
        if "test-value" in res:
            print "Update config to the partition %s works fine" % part
        else:
            msg = "failed to update nvram config into the partition %s" % part
            print msg
            raise OpTestError(msg)
Ejemplo n.º 4
0
class OpTestNVRAM():
    ##  Initialize this object
    #  @param i_bmcIP The IP address of the BMC
    #  @param i_bmcUser The userid to log into the BMC with
    #  @param i_bmcPasswd The password of the userid to log into the BMC with
    #  @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with
    #  @param i_bmcPasswdIpmi The password of BMC IPMI userid
    #  @param i_ffdcDir Optional param to indicate where to write FFDC
    #
    # "Only required for inband tests" else Default = None
    # @param i_hostIP The IP address of the HOST
    # @param i_hostuser The userid to log into the HOST
    # @param i_hostPasswd The password of the userid to log into the HOST with
    #
    def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd,
                 i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_hostip=None,
                 i_hostuser=None, i_hostPasswd=None):
        self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir)
        self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi,
                                  i_ffdcDir, i_hostip, i_hostuser, i_hostPasswd)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP)
        self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd,
                         i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_hostip,
                         i_hostuser, i_hostPasswd)
        self.util = OpTestUtil()

    ##
    # @brief  This function tests nvram partition access, print/update
    #         the config data and dumping the partition's data. All
    #         these operations are done on supported partitions in both
    #         host OS and Petitboot.
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_nvram_configuration(self):
        # Execute these tests in host OS
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()
        self.cv_HOST.host_run_command("uname -a")
        self.cv_HOST.host_run_command("cat /etc/os-release")
        self.cv_HOST.host_run_command("nvram -v")
        self.cv_HOST.host_run_command("nvram --print-config -p ibm,skiboot")
        self.cv_HOST.host_run_command("nvram --print-config -p common")
        self.cv_HOST.host_run_command("nvram --print-config -p lnx,oops-log")
        self.cv_HOST.host_run_command("nvram --print-config -p wwwwwwwwwwww")
        self.cv_HOST.host_run_command("nvram --print-vpd")
        self.cv_HOST.host_run_command("nvram --print-all-vpd")
        self.cv_HOST.host_run_command("nvram --print-err-log")
        self.cv_HOST.host_run_command("nvram --print-event-scan")
        self.cv_HOST.host_run_command("nvram --partitions")
        self.cv_HOST.host_run_command("nvram --dump common")
        self.cv_HOST.host_run_command("nvram --dump ibm,skiboot")
        self.cv_HOST.host_run_command("nvram --dump lnx,oops-log")
        self.cv_HOST.host_run_command("nvram --dump wwwwwwwwwwww")
        self.cv_HOST.host_run_command("nvram --ascii common")
        self.cv_HOST.host_run_command("nvram --ascii ibm,skiboot")
        self.cv_HOST.host_run_command("nvram --ascii lnx,oops-log")
        self.cv_HOST.host_run_command("nvram --ascii wwwwwwwwwwww")
        try:
            self.test_nvram_update_part_config_in_host("common")
            self.test_nvram_update_part_config_in_host("ibm,skiboot")
            self.test_nvram_update_part_config_in_host("lnx,oops-log")
            self.test_nvram_update_part_config_in_host("wwwwwwwwwwww")
        except OpTestError:
            print "There is a failure in updating one of NVRAM partitions"

        # Execute these tests in petitboot
        self.console = self.cv_SYSTEM.sys_get_ipmi_console()
        try:
            self.cv_SYSTEM.sys_ipmi_boot_system_to_petitboot(self.console)
            self.cv_IPMI.ipmi_host_set_unique_prompt(self.console)
            self.cv_IPMI.run_host_cmd_on_ipmi_console("uname -a")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("cat /etc/os-release")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram -v")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-config -p ibm,skiboot")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-config -p common")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-config -p lnx,oops-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-config -p wwwwwwwwwwww")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-vpd")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-all-vpd")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-err-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --print-event-scan")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --partitions")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --dump common")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --dump ibm,skiboot")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --dump lnx,oops-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --dump wwwwwwwwwwww")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --ascii common")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --ascii ibm,skiboot")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --ascii lnx,oops-log")
            self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram --ascii wwwwwwwwwwww")
            try:
                self.test_nvram_update_part_config_in_petitboot("common")
                self.test_nvram_update_part_config_in_petitboot("ibm,skiboot")
                self.test_nvram_update_part_config_in_petitboot("lnx,oops-log")
                self.test_nvram_update_part_config_in_petitboot("wwwwwwwwwwww")
            except OpTestError:
                print "There is a failure in updating one of NVRAM partitions"
        except:
            self.cv_IPMI.ipmi_set_boot_to_disk()
        self.cv_IPMI.ipmi_set_boot_to_disk()

    ##
    # @brief This function tests nvram update/print config functions for partition i_part
    #        these functions will be tested in host OS
    #
    # @param i_part @type string:partition to access i.e common, ibm,skiboot etc
    #
    # @return l_res @type list: output of command or raise OpTestError
    #
    def test_nvram_update_part_config_in_host(self, i_part):
        part = i_part
        self.cv_HOST.host_run_command("nvram -p %s --update-config 'test-cfg=test-value'" % part)
        res = self.cv_HOST.host_run_command("nvram -p %s --print-config=test-cfg" % part)
        if "test-value" in res:
            print "Update config to the partition %s works fine" % part
        else:
            msg = "failed to update nvram config into the partition %s" % part
            print msg
            raise OpTestError(msg)

    ##
    # @brief This function tests nvram update/print config functions for partition i_part
    #        these functions will be tested in Petitboot.
    #
    # @param i_part @type string:partition to access i.e common, ibm,skiboot etc
    #
    # @return l_res @type list: output of command or raise OpTestError
    #
    def test_nvram_update_part_config_in_petitboot(self, i_part):
        part = i_part
        self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram -p %s --update-config 'test-cfg=test-value'" % part)
        res_list = self.cv_IPMI.run_host_cmd_on_ipmi_console("nvram -p %s --print-config=test-cfg" % part)
        res = ''.join(res_list)
        if "test-value" in res:
            print "Update config to the partition %s works fine" % part
        else:
            msg = "failed to update nvram config into the partition %s" % part
            print msg
            raise OpTestError(msg)
Ejemplo n.º 5
0
class OpTestPCI():
    ##  Initialize this object
    #  @param i_bmcIP The IP address of the BMC
    #  @param i_bmcUser The userid to log into the BMC with
    #  @param i_bmcPasswd The password of the userid to log into the BMC with
    #  @param i_bmcUserIpmi The userid to issue the BMC IPMI commands with
    #  @param i_bmcPasswdIpmi The password of BMC IPMI userid
    #  @param i_ffdcDir Optional param to indicate where to write FFDC
    #
    # "Only required for inband tests" else Default = None
    # @param i_hostIP The IP address of the HOST
    # @param i_hostuser The userid to log into the HOST
    # @param i_hostPasswd The password of the userid to log into the HOST with
    #
    def __init__(self,
                 i_bmcIP,
                 i_bmcUser,
                 i_bmcPasswd,
                 i_bmcUserIpmi,
                 i_bmcPasswdIpmi,
                 i_ffdcDir=None,
                 i_hostip=None,
                 i_hostuser=None,
                 i_hostPasswd=None,
                 i_hostLspci=None):
        self.cv_BMC = OpTestBMC(i_bmcIP, i_bmcUser, i_bmcPasswd, i_ffdcDir)
        self.cv_IPMI = OpTestIPMI(i_bmcIP, i_bmcUserIpmi, i_bmcPasswdIpmi,
                                  i_ffdcDir, i_hostip, i_hostuser,
                                  i_hostPasswd)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP,
                                  i_ffdcDir)
        self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd,
                                      i_bmcUserIpmi, i_bmcPasswdIpmi,
                                      i_ffdcDir, i_hostip, i_hostuser,
                                      i_hostPasswd)
        self.util = OpTestUtil()
        self.lspci_file = i_hostLspci

    ##
    # @brief  This function will get the PCI and USB susbsytem Info
    #         And also this test compares known good data of
    #         "lspci -mm -n" which is stored in testcases/data directory
    #         with the current lspci data.
    #         User need to specify the corresponding file name into
    #         machines xml like lspci.txt which contains "lspci -mm -n"
    #         command output in a working good state of system.
    #         tools used are lspci and lsusb
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_host_pci_devices_info(self):
        if self.lspci_file == "empty.txt":
            print "Skipping the pci devices comparision as missing the lspci data file name in machines xml"
            return BMC_CONST.FW_SUCCESS
        filename = os.path.join(
            os.path.dirname(__file__).split('testcases')[0], self.lspci_file)
        if not os.path.isfile(filename):
            raise OpTestError(
                "lspci file %s not found in top level directory" % filename)
        self.pci_good_data_file = filename
        self.test_skiroot_pci_devices()
        self.cv_IPMI.ipmi_set_boot_to_disk()
        self.cv_IPMI.ipmi_power_off()
        self.cv_IPMI.ipmi_power_on()
        self.cv_IPMI.ipl_wait_for_working_state()
        self.test_host_pci_devices()

    ##
    # @brief  This function will get the "lspci -mm -n" output from the petitboot
    #         and compares it with known good lspci data
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_skiroot_pci_devices(self):
        cmd = "lspci -mm -n"
        self.console = self.cv_SYSTEM.sys_get_ipmi_console()
        self.cv_SYSTEM.sys_ipmi_boot_system_to_petitboot(self.console)
        self.cv_IPMI.ipmi_host_set_unique_prompt(self.console)
        self.cv_IPMI.run_host_cmd_on_ipmi_console("uname -a")
        self.cv_IPMI.run_host_cmd_on_ipmi_console("cat /etc/os-release")
        res = self.cv_IPMI.run_host_cmd_on_ipmi_console(cmd)
        self.cv_SYSTEM.sys_ipmi_close_console(self.console)
        self.pci_data_petitboot = '\n'.join(res[1:])
        diff_process = subprocess.Popen(
            ['diff', "-u", self.pci_good_data_file, "-"],
            stdin=subprocess.PIPE)
        diff_stdout, diff_stderr = diff_process.communicate(
            self.pci_data_petitboot + '\n')
        r = diff_process.wait()
        if r == 0:
            print "All the pci devices are detected at petitboot"
        else:
            print diff_stdout
            raise OpTestError(
                "There is a mismatch b/w known good output and tested petitboot lspci output"
            )

    ##
    # @brief  This function will get the "lspci -mm -n" output from the host OS
    #         and compares it with known good lspci data
    #
    # @return BMC_CONST.FW_SUCCESS or BMC_CONST.FW_FAILED
    #
    def test_host_pci_devices(self):
        self.cv_HOST.host_check_command("lspci", "lsusb")
        self.cv_HOST.host_list_pci_devices()
        self.cv_HOST.host_get_pci_verbose_info()
        self.cv_HOST.host_list_usb_devices()
        l_res = self.cv_HOST.host_run_command("lspci -mm -n")
        self.pci_data_hostos = l_res.replace("\r\n", "\n")
        diff_process = subprocess.Popen(
            ['diff', "-u", self.pci_good_data_file, "-"],
            stdin=subprocess.PIPE)
        diff_stdout, diff_stderr = diff_process.communicate(
            self.pci_data_hostos)
        r = diff_process.wait()
        if r == 0:
            print "All the pci devices are detected in host OS"
        else:
            print diff_stdout
            raise OpTestError(
                "There is a mismatch b/w known good output and tested host OS lspci output"
            )