当前位置: 首页>>代码示例>>Python>>正文


Python OpTestHost.host_check_command方法代码示例

本文整理汇总了Python中common.OpTestHost.OpTestHost.host_check_command方法的典型用法代码示例。如果您正苦于以下问题:Python OpTestHost.host_check_command方法的具体用法?Python OpTestHost.host_check_command怎么用?Python OpTestHost.host_check_command使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.OpTestHost.OpTestHost的用法示例。


在下文中一共展示了OpTestHost.host_check_command方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: OpTestHeartbeat

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestHeartbeat():
    ##  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)
        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 cover following test steps
    #        1. It will check for os level and get kernel version
    #        2. It will check for existence of ps command
    #        3. It will check for kopald service is running 
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_kopald_service(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()

        # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Checking for ps command 
        self.cv_HOST.host_check_command("ps")

        l_cmd = "ps -ef | grep -i kopald"
        print l_cmd
        l_res = self.cv_HOST.host_run_command(l_cmd)
        print l_res
        if (l_res.__contains__('[kopald]')):
            return BMC_CONST.FW_SUCCESS 
        else:
            l_msg = "kopald service is not running"
            print l_msg
            raise OpTestError(l_msg)
开发者ID:open-power,项目名称:op-test-framework,代码行数:58,代码来源:OpTestHeartbeat.py

示例2: OpTestInbandUsbInterface

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestInbandUsbInterface():
    ##  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)
        self.cv_HOST = OpTestHost(i_hostIP, i_hostUser, i_hostPasswd, i_bmcIP)
        self.util = OpTestUtil()

    ##
    # @brief This function will cover following test steps
    #        1. It will get the OS level installed on powernv platform
    #        2. It will check for kernel version installed on the Open Power Machine
    #        3. It will check for ipmitool command existence and ipmitool package
    #        4. Checking Inband ipmitool command functionality with different options
    #           using ipmitool usb interface.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_ipmi_inband_usb_interface(self):
         # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Checking for ipmitool command and lm_sensors package
        self.cv_HOST.host_check_command("ipmitool")

        l_pkg = self.cv_HOST.host_check_pkg_for_utility(l_oslevel, "ipmitool")
        print "Installed package: %s" % l_pkg

        # loading below ipmi modules based on config option
        # ipmi_devintf, ipmi_powernv and ipmi_masghandler
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_DEVICE_INTERFACE,
                                                      BMC_CONST.IPMI_DEV_INTF)
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_POWERNV,
                                                      BMC_CONST.IPMI_POWERNV)
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_HANDLER,
                                                      BMC_CONST.IPMI_MSG_HANDLER)
        print "Inband IPMI[USB]: Chassis tests"
        self.test_chassis()
        print "Inband IPMI[USB]: Chassis Identify tests"
        self.test_chassis_identifytests()
        print "Inband IPMI[USB]: Chassis Bootdevice tests"
        self.test_chassis_bootdev()
        print "Inband IPMI[USB]: Channel tests"
        #self.test_channel()
        print "Inband IPMI[USB]: Info tests"
        self.test_Info()
        print "Inband IPMI[USB]: SDR list tests"
        self.test_sdr_list_by_type()
        print "Inband IPMI[USB]: SDR elist tests"
        self.test_sdr_elist_by_type()
        print "Inband IPMI[USB]: SDR type list tests"
        self.test_sdr_type_list()
        print "Inband IPMI[USB]: SDR get tests"
        self.test_sdr_get_id()
        print "Inband IPMI[USB]: FRU Tests"
        self.test_fru_print()
        self.test_fru_read()
        print "Inband IPMI[USB]: SEL tests"
        self.test_sel_info()
        self.test_sel_list()
        self.test_sel_elist()
        l_res = self.test_sel_time_get()
        self.test_sel_time_set(l_res[-2])
        i_num = "3"
        self.test_sel_list_first_n_entries(i_num)
        self.test_sel_list_last_n_entries(i_num)
        self.test_sel_get_functionality()
        self.test_sel_clear_functionality()
        print "Inband IPMI[USB]: MC tests"
        self.test_mc()
        print "Inband IPMI[USB]: Sensor tests"
        self.test_sensor_list()
        self.test_sensor_byid("Host Status")
        self.test_sensor_byid("OS Boot")
        self.test_sensor_byid("OCC Active")
        print "Inband IPMI[USB]: dcmi tests"
        self.test_dcmi()
        print "Inband IPMI[USB]: echo tests"
        self.test_echo()
        print "Inband IPMI[USB]: event tests"
        self.test_event()
        print "Inband IPMI[USB]: Firewall test"
#.........这里部分代码省略.........
开发者ID:shenki,项目名称:op-test-framework,代码行数:103,代码来源:OpTestInbandUsbInterface.py

示例3: OpTestI2Cdriver

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestI2Cdriver():
    ## 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)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP)
        self.util = OpTestUtil()

    ##
    # @brief  This function has following test steps
    #         1. Getting host information(OS and kernel info)
    #         2. Checking the required utilites are present on host or not
    #         3. Loading the necessary modules to test I2C device driver functionalites
    #            (i2c_dev, i2c_opal and at24)
    #         4. Getting the list of i2c buses
    #         5. Querying the i2c bus for devices
    #         3. Getting the list of i2c buses and eeprom chip addresses
    #         4. Accessing the registers visible through the i2cbus using i2cdump utility
    #         5. Listing the i2c adapter conetents and i2c bus entries to make sure sysfs entries
    #            created for each bus.
    #         6. Testing i2cget functionality for limited samples
    #            Avoiding i2cset functionality, it may damage the system.
    #
    # @return BMC_CONST.FW_SUCCESS-success or raise OpTestError-fail
    #
    def testI2Cdriver(self):

        # Get OS level
        self.cv_HOST.host_get_OS_Level()

        # make sure install "i2c-tools" package in-order to run the test

        # Check whether i2cdump, i2cdetect and hexdump commands are available on host
        self.cv_HOST.host_check_command("i2cdump")
        self.cv_HOST.host_check_command("i2cdetect")
        self.cv_HOST.host_check_command("hexdump")
        self.cv_HOST.host_check_command("i2cget")
        self.cv_HOST.host_check_command("i2cset")

        # Get Kernel Version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # loading i2c_opal module based on config option
        l_config = "CONFIG_I2C_OPAL"
        l_module = "i2c_opal"
        self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module)

        # loading i2c_dev module based on config option
        l_config = "CONFIG_I2C_CHARDEV"
        l_module = "i2c_dev"
        self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module)

        # loading at24 module based on config option
        l_config = "CONFIG_EEPROM_AT24"
        l_module = "at24"
        self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module)

        # Get information of EEPROM chips
        self.cv_HOST.host_get_info_of_eeprom_chips()

        # Get list of i2c buses available on host,
        # l_list=["0","1"....]
        # l_list1=["i2c-0","i2c-1","i2c-2"....]
        l_list, l_list1 = self.cv_HOST.host_get_list_of_i2c_buses()

        # Scanning i2c bus for devices attached to it.
        for l_bus in l_list:
            self.query_i2c_bus(l_bus)

        # Get list of pairs of i2c bus and EEPROM device addresses in the host
        l_chips = self.cv_HOST.host_get_list_of_eeprom_chips()
        for l_args in l_chips:
            # Accessing the registers visible through the i2cbus using i2cdump utility
            # l_args format: "0 0x51","1 0x53",.....etc
            self.i2c_dump(l_args)

        # list i2c adapter conetents
        l_res = self.cv_HOST.host_run_command("ls -l /sys/class/i2c-adapter; echo $?")
        l_res = l_res.splitlines()
        if int(l_res[-1]) == 0:
            pass
        else:
            l_msg = "listing i2c adapter contents through the sysfs entry failed"
            print l_msg
            raise OpTestError(l_msg)
#.........这里部分代码省略.........
开发者ID:shenki,项目名称:op-test-framework,代码行数:103,代码来源:OpTestI2Cdriver.py

示例4: OpTestHMIHandling

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestHMIHandling():
    ## 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, 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()

    ##
    # @brief This is a common function for all the hmi test cases. This will be executed before
    #        any test case starts. Basically this provides below requirements.
    #        1. Validates all required host commands
    #        2. It will clone skiboot source repository
    #        3. Compile the necessary tools xscom-utils and gard utility to test HMI.
    #        4. Get the list Of Chips and cores in the form of dictionary.
    #           Ex: [['00000000', ['4', '5', '6', 'c', 'd', 'e']], ['00000001', ['4', '5', '6', 'c', 'd', 'e']], ['00000010', ['4', '5', '6', 'c', 'd', 'e']]]
    #        5. In-order to inject HMI errors on cpu's, cpu should be running,
    #           so disabling the sleep states 1 and 2 of all CPU's.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_init(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()

        # Get OS level
        self.l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Check whether git and gcc commands are available on the host
        self.cv_HOST.host_check_command("git")
        self.cv_HOST.host_check_command("gcc")

        # It will clone skiboot source repository
        l_dir = "/tmp/skiboot"
        self.cv_HOST.host_clone_skiboot_source(l_dir)
        # Compile the necessary tools xscom-utils and gard utility
        self.cv_HOST.host_compile_xscom_utilities(l_dir)
        self.cv_HOST.host_compile_gard_utility(l_dir)

        # Getting list of processor chip Id's(executing getscom -l to get chip id's)
        l_res = self.cv_HOST.host_run_command("cd %s/external/xscom-utils/; ./getscom -l" % l_dir)
        l_res = l_res.splitlines()
        l_chips = []
        for line in l_res:
            matchObj = re.search("(\d{8}).*processor", line)
            if matchObj:
                l_chips.append(matchObj.group(1))
        if not l_chips:
            l_msg = "Getscom failed to list processor chip id's"
            raise OpTestError(l_msg)
        l_chips.sort()
        print l_chips # ['00000000', '00000001', '00000010']

        # Currently getting the list of active core id's with respect to each chip is by using opal msg log
        # TODO: Need to identify best way to get list of cores(If Opal msg log is empty)
        l_cmd = "cat /sys/firmware/opal/msglog | grep -i CHIP"
        l_res = self.cv_HOST.host_run_command(l_cmd)
        l_cores = {}
        self.l_dic = []
        l_res = l_res.splitlines()
        for line in l_res:
            matchObj = re.search("Chip (\d{1,2}) Core ([a-z0-9])", line)
            if matchObj:
                if l_cores.has_key(int(matchObj.group(1))):
                    (l_cores[int(matchObj.group(1))]).append(matchObj.group(2))
                else:
                    l_cores[int(matchObj.group(1))] = list(matchObj.group(2))
        if not l_cores:
            l_msg = "Failed in getting core id's information from OPAL msg log"
            raise OpTestError(l_msg)

        print l_cores # {0: ['4', '5', '6', 'c', 'd', 'e'], 1: ['4', '5', '6', 'c', 'd', 'e'], 10: ['4', '5', '6', 'c', 'd', 'e']}
        l_cores = sorted(l_cores.iteritems())
        print l_cores
        i=0
        for tup in l_cores:
            new_list = [l_chips[i], tup[1]]
            self.l_dic.append(new_list)
            i+=1
        print self.l_dic
        # self.l_dic is a list of chip id's, core id's . and is of below format 
        # [['00000000', ['4', '5', '6', 'c', 'd', 'e']], ['00000001', ['4', '5', '6', 'c', 'd', 'e']], ['00000010', ['4', '5', '6', 'c', 'd', 'e']]]

#.........这里部分代码省略.........
开发者ID:open-power,项目名称:op-test-framework,代码行数:103,代码来源:OpTestHMIHandling.py

示例5: OpTestPrdDriver

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]

#.........这里部分代码省略.........
    def test_prd_for_fir(self, FIR, FIMR, ERROR):
        chip_id = "0x" + self.random_chip
        print chip_id
        print "OPAL-PRD: Injecting error 0x%x on FIR: %s" % (ERROR, FIR)
        # Read Local Fault Isolation register
        l_cmd = "./getscom -c %s %s" % (chip_id, FIR)
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)

        # Reading Local Fault Isolation mask register
        l_cmd = "./getscom -c %s %s" % (chip_id, FIMR)
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)
        print l_res

        # Changing the FIMR value to un-masked value.
        LEN = 16
        l_len = len(l_res[-1])
        l_val = hex(int(("0x" + "0"*(LEN - l_len) + l_res[-1]), 16)& (ERROR ^ 0xffffffffffffffff))

        # Writing the same value to Local Fault Isolation mask register again
        l_cmd = "./putscom -c %s %s %s" % (chip_id, BMC_CONST.PBA_FAULT_ISOLATION_MASK_REGISTER, l_val)
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)

        # Inject a core error on FIR
        l_cmd = "./putscom -c %s %s %s" % (chip_id, FIR, hex(ERROR))
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)

        time.sleep(30)

        # Read Local Fault Isolation register again
        l_cmd = "./getscom -c %s %s" % (chip_id, FIR)
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)
        print l_res

        # Check FIR got cleared by opal-prd
        if l_res[-1] == BMC_CONST.FAULT_ISOLATION_REGISTER_CONTENT:
            print "Opal-prd handles core hardware error"
        else:
            l_msg = "Opal-prd not clearing hardware errors in runtime"
            print l_msg
            raise OpTestError(l_msg)

        # Reading the Local Fault Isolation Mask Register again
        l_cmd = "./getscom -c %s %s" % (chip_id, FIMR)
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)
        print l_res

        # check for IPOLL mask register value to see opal-prd cleared the value
        l_cmd = "./getscom -c %s %s" % (chip_id, BMC_CONST.IPOLL_MASK_REGISTER)
        l_res = self.cv_IPMI.run_host_cmd_on_ipmi_console(l_cmd)
        if l_res[-1] == BMC_CONST.IPOLL_MASK_REGISTER_CONTENT:
            print "Opal-prd cleared the IPOLL MASK REGISTER"
            return BMC_CONST.FW_SUCCESS
        else:
            l_msg = "Opal-prd is not clearing the IPOLL MASK REGISTER after injecting core FIR error"
            print l_msg
            raise OpTestError(l_msg)

    ##
    # @brief This is a common function for all the PRD test cases. This will be executed before
    #        any test case starts. Basically this provides below requirements.
    #        1. Validates all required host commands
    #        2. It will clone skiboot source repository
    #        3. Compile the necessary tools -xscom-utils(getscom and putscom)
    #        4. Get the list Of Chips.
    #           Ex: ['00000000', '00000001', '00000010']
    #        5. generate a random chip.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_init(self):
        # Get OS level
        self.cv_HOST.host_get_OS_Level()

        # Check whether git and gcc commands are available on host
        self.cv_HOST.host_check_command("git", "gcc")

        # It will clone skiboot source repository 
        self.cv_HOST.host_clone_skiboot_source(BMC_CONST.CLONE_SKIBOOT_DIR)

        # Compile the necessary tools xscom-utils and gard utility
        self.cv_HOST.host_compile_xscom_utilities(BMC_CONST.CLONE_SKIBOOT_DIR)

        # Getting list of processor chip Id's(executing getscom -l to get chip id's)
        l_res = self.cv_HOST.host_run_command("cd %s/external/xscom-utils/; ./getscom -l" % BMC_CONST.CLONE_SKIBOOT_DIR)
        l_res = l_res.splitlines()
        l_chips = []
        for line in l_res:
            matchObj = re.search("(\d{8}).*processor", line)
            if matchObj:
                l_chips.append(matchObj.group(1))
        if not l_chips:
            l_msg = "Getscom failed to list processor chip id's"
            raise OpTestError(l_msg)
        l_chips.sort()
        print l_chips # ['00000000', '00000001', '00000010']
        self.random_chip = random.choice(l_chips)

        # Below will be useful for debug purposes to compare chip information
        l_res = self.cv_HOST.host_read_msglog_core()
        print l_res
开发者ID:open-power,项目名称:op-test-framework,代码行数:104,代码来源:OpTestPrdDriver.py

示例6: OpTestOOBIPMI

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestOOBIPMI():
    ##  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)
        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  It will execute and test all Out-of-band ipmi commands.
    #         bmc, channel, chassis, dcmi, echo, event, exec, firewall, fru, lan
    #         mc, pef, power, raw, sdr, sel, sensor, session, user
    #
    # @return l_res @type list: output of command or raise OpTestError
    #
    def test_oob_ipmi(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()
         # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Checking for ipmitool command and lm_sensors package
        self.cv_HOST.host_check_command("ipmitool")

        l_pkg = self.cv_HOST.host_check_pkg_for_utility(l_oslevel, "ipmitool")
        print "Installed package: %s" % l_pkg

        # loading below ipmi modules based on config option
        # ipmi_devintf, ipmi_powernv and ipmi_masghandler
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_DEVICE_INTERFACE,
                                                      BMC_CONST.IPMI_DEV_INTF)
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_POWERNV,
                                                      BMC_CONST.IPMI_POWERNV)
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_HANDLER,
                                                      BMC_CONST.IPMI_MSG_HANDLER)

        test_cases = [self.test_chassis, self.test_chassisIdentifytests,
        self.test_chassisBootdev, self.test_Info, self.test_sdr_list_by_type,
        self.test_sdr_elist_by_type, self.test_sdr_type_list, self.test_sdr_get_id,
        self.test_fru_print, self.test_fru_read, self.test_mc,
        self.test_sensor_list, self.test_sensor_get_host_status,
        self.test_sensor_get_os_boot, self.test_sel_info, self.test_sel_list,
        self.test_sel_elist, self.test_set_sel_time,
        self.test_sel_time_get, self.test_sel_list_first_3_entries,
        self.test_sel_list_last_3_entries, self.test_sel_get_functionality,
        self.test_sel_clear_functionality, self.test_channel,
        self.test_dcmi, self.test_echo, self.test_event,
        self.test_firewall, self.test_pef, self.test_raw,
        self.test_exec, self.test_bmc_golden_side_version,
        self.test_get_pnor_partition_size_cmd,
        self.test_bmc_boot_completed_cmd,
        self.test_get_led_state_cmd, self.test_set_led_state_cmd]

        fail_count = 0

        for test in test_cases:
            try:
                print "OOB IPMI: test case %s" % test
                test(self)
            except:
                print "Test Fail: %s failed" % test
                fail_count += 1
                print sys.exc_info()
                continue

        print "OOB IPMI: Test case failure count %s" % fail_count

        print self.cv_IPMI.ipmi_get_bmc_golden_side_version()
        print self.cv_IPMI.ipmi_get_pnor_partition_size("NVRAM")
        print self.cv_IPMI.ipmi_get_pnor_partition_size("GUARD")
        print self.cv_IPMI.ipmi_get_pnor_partition_size("BOOTKERNEL")
        print self.cv_IPMI.ipmi_get_bmc_boot_completion_status()
        print self.cv_IPMI.ipmi_get_fault_led_state()
        print self.cv_IPMI.ipmi_get_power_on_led_state()
        print self.cv_IPMI.ipmi_get_host_status_led_state()
        print self.cv_IPMI.ipmi_get_chassis_identify_led_state()
        self.cv_IPMI.ipmi_enable_fan_control_task_command()
        self.cv_IPMI.ipmi_get_fan_control_task_state_command()
        self.cv_IPMI.ipmi_disable_fan_control_task_command()
        self.cv_IPMI.ipmi_get_fan_control_task_state_command()
#.........这里部分代码省略.........
开发者ID:open-power,项目名称:op-test-framework,代码行数:103,代码来源:OpTestOOBIPMI.py

示例7: OpTestInbandIPMI

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestInbandIPMI():
    ##  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)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd, i_bmcIP)
        self.util = OpTestUtil()

    ##
    # @brief This function will cover following test steps
    #        1. It will get the OS level installed on powernv platform
    #        2. It will check for kernel version installed on the Open Power Machine 
    #        3. It will check for ipmitool command existence and ipmitool package
    #        4. Checking Inband ipmitool command functionality with different options
    #           using ipmitool.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_ipmi_inband_functionality(self):

        # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Checking for ipmitool command and lm_sensors package
        self.cv_HOST.host_check_command("ipmitool")

        l_pkg = self.cv_HOST.host_check_pkg_for_utility(l_oslevel, "ipmitool")
        print "Installed package: %s" % l_pkg


        # Checking Inband ipmitool command functionality with different options
        l_cmd = "ipmitool sdr; echo $?"
        output = self.cv_HOST.host_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool sdr not working,exiting...."
            raise OpTestError(l_msg)

        l_cmd = "ipmitool sdr elist full; echo $?"
        output = self.cv_HOST.host_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool sdr elist full not working,exiting...."
            raise OpTestError(l_msg)

        l_cmd = "ipmitool sdr type temperature; echo $?"
        l_res = self.cv_HOST.host_run_command(l_cmd)
        if l_res.__contains__("Temp"):
            print "ipmitool sdr type temperature is working"
        else:
            l_msg = "ipmitool sdr type temperature is not working"
            raise OpTestError(l_msg)


        l_cmd = "ipmitool lan print 1; echo $?"
        output = self.cv_HOST.host_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool lan print command is not working,exiting...."
            raise OpTestError(l_msg)


        l_cmd = "ipmitool fru print; echo $?"
        output = self.cv_HOST.host_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool fru print is not working,exiting...."
            raise OpTestError(l_msg)


        l_cmd = "ipmitool chassis status | grep \"System Power\""
        l_res = self.cv_HOST.host_run_command(l_cmd)
        if l_res.__contains__("System Power         : on"):
            print "ipmitool Chassis status is working"
        else:
            l_msg = "ipmitool chassis status is not working"
            raise OpTestError(l_msg)

        l_cmd = "ipmitool chassis identify 1; echo $?"
        l_res = self.cv_HOST.host_run_command(l_cmd)
        if l_res.__contains__("Chassis identify interval: 1 seconds"):
            print "ipmitool Chassis identify interval is working"
#.........这里部分代码省略.........
开发者ID:shenki,项目名称:op-test-framework,代码行数:103,代码来源:OpTestInbandIPMI.py

示例8: OpTestSwitchEndianSyscall

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestSwitchEndianSyscall():
    ## 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)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd,i_bmcIP)
        self.util = OpTestUtil()

    ##
    # @brief  If git and gcc commands are availble on host, this function will clone linux
    #         git repository and check for switch_endian_test directory and make
    #         the required files. And finally execute bin file switch_endian_test.
    #
    # @return BMC_CONST.FW_SUCCESS-success or BMC_CONST.FW_FAILED-fail
    #
    def testSwitchEndianSysCall(self):

        # Get OS level
        self.cv_HOST.host_get_OS_Level()

        # Check whether git and gcc commands are available on host
        self.cv_HOST.host_check_command("git")
        self.cv_HOST.host_check_command("gcc")

        # Clone latest linux git repository into l_dir
        l_dir = "/tmp/linux"
        self.cv_HOST.host_clone_linux_source(l_dir)

        # Check for switch_endian test directory.
        self.check_dir_exists(l_dir)

        # make the required files
        self.make_test(l_dir)

        # Run the switch_endian sys call test once
        l_rc = self.run_once(l_dir)
        if int(l_rc) == 1:
            print "Switch endian sys call test got succesful"
            return BMC_CONST.FW_SUCCESS
        else:
            print "Switch endian sys call test failed"
            return BMC_CONST.FW_FAILED

    ##
    # @brief  It will check for existence of switch_endian directory in the cloned repository
    #
    # @param i_dir @type string: linux source directory
    #
    # @return 1-success or raise OpTestError
    #
    def check_dir_exists(self, i_dir):
        l_dir = '%s/tools/testing/selftests/powerpc/switch_endian' % i_dir
        l_cmd = "test -d %s; echo $?" % l_dir
        print l_cmd
        l_res = self.cv_HOST.host_run_command(l_cmd)
        print l_res
        l_res = l_res.replace("\r\n", "")
        if int(l_res) == 0:
            print "Switch endian test directory exists"
            return 1
        else:
            l_msg = "Switch endian directory is not present"
            print l_msg
            raise OpTestError(l_msg)

    ##
    # @brief  It will prepare for executable bin files using make command
    #         At the end it will check for bin file switch_endian_test and
    #         will throw an exception in case of missing bin file after make
    #
    # @param i_dir @type string: linux source directory
    #
    # @return 1-success or raise OpTestError
    #
    def make_test(self, i_dir):
        l_cmd = "cd %s/tools/testing/selftests/powerpc/switch_endian;\
                 make;" % i_dir
        print l_cmd
        l_res = self.cv_HOST.host_run_command(l_cmd)
        l_cmd = "test -f %s/tools/testing/selftests/powerpc/switch_endian/switch_endian_test; echo $?" % i_dir
        l_res = self.cv_HOST.host_run_command(l_cmd)
        l_res = l_res.replace("\r\n", "")
        if int(l_res) == 0:
            print "Executable binary switch_endian_test is available"
            return 1
#.........这里部分代码省略.........
开发者ID:shenki,项目名称:op-test-framework,代码行数:103,代码来源:OpTestSwitchEndianSyscall.py

示例9: __init__

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]

#.........这里部分代码省略.........
        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")
开发者ID:open-power,项目名称:op-test-framework,代码行数:104,代码来源:OpTestPCI.py

示例10: OpTestAt24driver

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestAt24driver():
    ## 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)
        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 has following test steps
    #         1. Getting the host infromation(OS and kernel information)
    #         2. Loading the necessary modules to test at24 device driver functionalites
    #            (i2c_dev, i2c_opal and at24)
    #         3. Getting the list of i2c buses and eeprom chip addresses
    #         4. Accessing the registers visible through the i2cbus using i2cdump utility
    #         5. Getting the eeprom device data using hexdump utility in hex + Ascii format
    #
    # @return BMC_CONST.FW_SUCCESS-success or raise OpTestError
    #
    def testAt24driver(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()
        # Get OS level
        self.cv_HOST.host_get_OS_Level()

        # Check whether i2cdump and hexdump commands are available on host
        self.cv_HOST.host_check_command("i2cdump", "hexdump")

        # Get Kernel Version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Loading i2c_opal module based on config option
        l_config = "CONFIG_I2C_OPAL"
        l_module = "i2c_opal"
        self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module)

        # Loading i2c_dev module based on config option
        l_config = "CONFIG_I2C_CHARDEV"
        l_module = "i2c_dev"
        self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module)

        # Loading at24 module based on config option
        l_config = "CONFIG_EEPROM_AT24"
        l_module = "at24"
        self.cv_HOST.host_load_module_based_on_config(l_kernel, l_config, l_module)

        # Get infomtion of EEPROM chips
        self.cv_HOST.host_get_info_of_eeprom_chips()

        # Get list of pairs of i2c bus and EEPROM device addresses in the host
        l_chips = self.cv_HOST.host_get_list_of_eeprom_chips()
        for l_args in l_chips:
            # Accessing the registers visible through the i2cbus using i2cdump utility
            # l_args format: "0 0x51","1 0x53",.....etc
            self.i2c_dump(l_args)

        # Getting the list of sysfs eeprom interfaces
        l_res = self.cv_HOST.host_run_command("find /sys/ -name eeprom; echo $?")
        l_res = l_res.splitlines()
        if int(l_res[-1]) == 0:
            pass
        else:
            l_msg = "EEPROM sysfs entries are not created"
            print l_msg
            raise OpTestError(l_msg)
        for l_dev in l_res:
            if l_dev.__contains__("eeprom"):
                # Getting the eeprom device data using hexdump utility in hex + Ascii format
                self.cv_HOST.host_hexdump(l_dev)
            else:
                pass
        return BMC_CONST.FW_SUCCESS

    ##
    # @brief This i2cdump function takes arguments in pair of a string like "i2cbus address".
    #        i2cbus indicates the number or name of the I2C bus to be scanned. This number should
    #        correspond  to  one  of  the busses listed by i2cdetect -l. address indicates
    #        the address to be scanned on that bus, and is an integer between 0x03 and 0x77
    #        i2cdump is a program to examine registers visible through the I2C bus
    #
    # @param i_args @type string: this is the argument to i2cdump utility
    #                             args are in the form of "i2c-bus-number eeprom-chip-address"
    #                             Ex: "0 0x51","3 0x52" ....etc
#.........这里部分代码省略.........
开发者ID:open-power,项目名称:op-test-framework,代码行数:103,代码来源:OpTestAt24driver.py

示例11: OpTestSensors

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestSensors():
    ##  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)
        self.cv_HOST = OpTestHost(i_hostip, i_hostuser, i_hostPasswd,i_bmcIP)
        self.util = OpTestUtil()

    ##
    # @brief This function will cover following test steps
    #        1. It will check for kernel config option CONFIG_SENSORS_IBMPOWERNV
    #        2. It will load ibmpowernv driver only on powernv platform
    #        3. It will check for sensors command existence and lm_sensors package
    #        4. start the lm_sensors service and detect any sensor chips
    #           using sensors-detect.
    #        5. At the end it will test sensors command functionality
    #           with different options
    #
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_hwmon_driver(self):

        # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Checking for sensors config option CONFIG_SENSORS_IBMPOWERNV
        l_config = "CONFIG_SENSORS_IBMPOWERNV"

        l_val = self.cv_HOST.host_check_config(l_kernel, l_config)
        if l_val == "y":
            print "Driver build into kernel itself"
        else:
            print "Driver will be built as module"

        # Loading ibmpowernv driver only on powernv platform
        self.cv_HOST.host_load_ibmpowernv(l_oslevel)

        # Checking for sensors command and lm_sensors package
        self.cv_HOST.host_check_command("sensors")

        l_pkg = self.cv_HOST.host_check_pkg_for_utility(l_oslevel, "sensors")
        print "Installed package: %s" % l_pkg

        # Restart the lm_sensor service
        self.cv_HOST.host_start_lm_sensor_svc(l_oslevel)

        # To detect different sensor chips and modules
        res = self.cv_HOST.host_run_command("yes | sensors-detect")
        print res

        # Checking sensors command functionality with different options
        output = self.cv_HOST.host_run_command("sensors; echo $?")
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "sensors not working,exiting...."
            raise OpTestError(l_msg)
        print output
        output = self.cv_HOST.host_run_command("sensors -f; echo $?")
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "sensors -f not working,exiting...."
            raise OpTestError(l_msg)
        print output
        output = self.cv_HOST.host_run_command("sensors -A; echo $?")
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "sensors -A not working,exiting...."
            raise OpTestError(l_msg)
        print output
        output = self.cv_HOST.host_run_command("sensors -u; echo $?")
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "sensors -u not working,exiting...."
            raise OpTestError(l_msg)
        print output
        return BMC_CONST.FW_SUCCESS
开发者ID:shenki,项目名称:op-test-framework,代码行数:97,代码来源:OpTestSensors.py

示例12: OpTestEM

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestEM():
    ##  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)
        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 cover following test steps
    #        1. It will get the OS and kernel versions.
    #        2. Check the cpupower utility is available in host.
    #        3. Get available cpu scaling frequencies
    #        4. Set the userspace governer for all cpu's
    #        5. test the cpufreq driver by set/verify cpu frequency
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_cpu_freq_states(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()

        # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        self.cv_HOST.host_check_command("cpupower")
        # Get available cpu scaling frequencies
        l_res = self.cv_HOST.host_run_command("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies")
        freq_list = (l_res.strip()).split(' ')
        print freq_list

        # Set the cpu governer to userspace
        self.set_cpu_gov("userspace")
        self.verify_cpu_gov("userspace")
        for i in range(1, 100):
            i_freq = random.choice(freq_list)
            self.set_cpu_freq(i_freq)
            self.verify_cpu_freq(i_freq)

        return BMC_CONST.FW_SUCCESS

    ##
    # @brief This function will cover following test steps
    #        1. It will get the OS and kernel versions.
    #        2. Check the cpupower utility is available in host.
    #        3. Set the userspace governer for all cpu's
    #        4. test the cpuidle driver by enable/disable/verify the idle states
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_cpu_idle_states(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()

        # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        self.cv_HOST.host_check_command("cpupower")
        # currently p8 cpu has 3 states
        for i in (0, 1, 2):
            self.enable_idle_state(i)
            self.verify_enable_idle_state(i)
        for i in (0, 1, 2):
            self.disable_idle_state(i)
            self.verify_disable_idle_state(i)

        return BMC_CONST.FW_SUCCESS

    ##
    # @brief sets the cpu frequency with i_freq value
    #
    # @param i_freq @type str: this is the frequency of cpu to be set
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def set_cpu_freq(self, i_freq):
        l_cmd = "for i in /sys/devices/system/cpu/cpu*/cpufreq/scaling_setspeed; do echo %s > $i; done" % i_freq
        self.cv_HOST.host_run_command(l_cmd)
#.........这里部分代码省略.........
开发者ID:open-power,项目名称:op-test-framework,代码行数:103,代码来源:OpTestEM.py

示例13: OpTestIPMILockMode

# 需要导入模块: from common.OpTestHost import OpTestHost [as 别名]
# 或者: from common.OpTestHost.OpTestHost import host_check_command [as 别名]
class OpTestIPMILockMode():
    ##  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 cover following test steps
    #        1. It will get the OS level installed on power platform
    #        2. It will check for kernel version installed on the Open Power Machine
    #        3. It will check for ipmitool command existence and ipmitool package
    #        4. Load the necessary ipmi modules based on config values
    #        5. Issue a ipmi lock command through out-of-band authenticated interface
    #        6. Now BMC IPMI is in locked mode, at this point only white listed
    #           in-band ipmi commands sholud work(No other in-band ipmi command should work)
    #        7. Execute and test the functionality of whitelisted in-band ipmi
    #           commands in locked mode
    #        8. At the end of test issue a ipmi unlock command to revert the availablity of all
    #           in-band ipmi commands in unlocked mode.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def test_ipmi_lock_mode(self):
        self.cv_SYSTEM.sys_bmc_power_on_validate_host()

        # Get OS level
        l_oslevel = self.cv_HOST.host_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_HOST.host_get_kernel_version()

        # Checking for ipmitool command and lm_sensors package
        self.cv_HOST.host_check_command("ipmitool")

        l_pkg = self.cv_HOST.host_check_pkg_for_utility(l_oslevel, "ipmitool")
        print "Installed package: %s" % l_pkg

        # loading below ipmi modules based on config option
        # ipmi_devintf, ipmi_powernv and ipmi_masghandler
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_DEVICE_INTERFACE,
                                                      BMC_CONST.IPMI_DEV_INTF)
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_POWERNV,
                                                      BMC_CONST.IPMI_POWERNV)
        self.cv_HOST.host_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_HANDLER,
                                                      BMC_CONST.IPMI_MSG_HANDLER)

        # Issue a ipmi lock command through authenticated interface
        print "Issuing ipmi lock command through authenticated interface"
        l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LOCK_CMD)
        l_res = l_res.splitlines()
        if int(l_res[-1]):
            l_msg = "IPMI:Lock command failed, There may be two reasons here.\n\
                a. check the corresponding parches available in AMI driver code,\n\
                b. if patches available then command is failing"
            print l_msg
            raise OpTestError(l_msg)
        print "IPMI:Lock command executed successfully"

        try:
            self.run_inband_ipmi_whitelisted_cmds()
        except:
            l_msg = "One of white listed in-band ipmi command execution failed"
            print sys.exc_info()
        finally:
            # Issue a ipmi unlock command at the end of test.
            print "Issuing ipmi unlock command through authenticated interface"
            self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_UNLOCK_CMD)

    ##
    # @brief This function will execute whitelisted in-band ipmi commands
    #        and test the functionality in locked mode.
    #
    # @return BMC_CONST.FW_SUCCESS or raise OpTestError
    #
    def run_inband_ipmi_whitelisted_cmds(self):
        l_con = self.cv_SYSTEM.sys_get_ipmi_console()
        self.cv_IPMI.ipmi_host_login(l_con)
        self.cv_IPMI.ipmi_host_set_unique_prompt(l_con)
        self.cv_IPMI.run_host_cmd_on_ipmi_console("uname -a")

#.........这里部分代码省略.........
开发者ID:open-power,项目名称:op-test-framework,代码行数:103,代码来源:OpTestIPMILockMode.py


注:本文中的common.OpTestHost.OpTestHost.host_check_command方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。