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_lparIP The IP address of the LPAR
    # @param i_lparuser The userid to log into the LPAR
    # @param i_lparPasswd The password of the userid to log into the LPAR with
    #
    def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd,
                 i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_lparip=None,
                 i_lparuser=None, i_lparPasswd=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_lparip, i_lparuser, i_lparPasswd)
        self.cv_LPAR = OpTestLpar(i_lparip, i_lparuser, i_lparPasswd, i_bmcIP)
        self.cv_SYSTEM = OpTestSystem(i_bmcIP, i_bmcUser, i_bmcPasswd,
                 i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir, i_lparip,
                 i_lparuser, i_lparPasswd)
        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):
        # Get OS level
        l_oslevel = self.cv_LPAR.lpar_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_LPAR.lpar_get_kernel_version()

        # Checking for ipmitool command and lm_sensors package
        self.cv_LPAR.lpar_check_command("ipmitool")

        l_pkg = self.cv_LPAR.lpar_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_LPAR.lpar_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_DEVICE_INTERFACE,
                                                      BMC_CONST.IPMI_DEV_INTF)
        self.cv_LPAR.lpar_load_module_based_on_config(l_kernel, BMC_CONST.CONFIG_IPMI_POWERNV,
                                                      BMC_CONST.IPMI_POWERNV)
        self.cv_LPAR.lpar_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_lpar_login(l_con)
        self.cv_IPMI.ipmi_lpar_set_unique_prompt(l_con)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console("uname -a")

        # Test IPMI white listed commands those should be allowed through un-authenticated
        # in-band interface
        # 1.[App] Get Device ID
        print "Testing Get Device ID command"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_DEVICE_ID)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get Device ID command failed"
            raise OpTestError(l_msg)

        # 2.[App] Get Device GUID
        print "Testing Get Device GUID"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_DEVICE_GUID)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get Device GUID command failed"
            raise OpTestError(l_msg)

        # 3.[App] Get System GUID
        print "Testing Get system GUID"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_GUID)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get System GUID command failed"
            raise OpTestError(l_msg)

        # 4.[Storage] Get SEL info
        print "Testing Get SEL info"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_INFO)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get SEL info command failed"
            raise OpTestError(l_msg)

        # 5.[Storage] Get SEL time
        print "Testing Get SEL time"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_TIME_RAW)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get SEL time command failed"
            raise OpTestError(l_msg)

        # 6. [Storage] Reserve SEL
        print "Testing Reserve SEL"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_RESERVE_SEL)
        if l_res[-1] != "0":
            l_msg = "IPMI: Reserve SEL command failed"
            raise OpTestError(l_msg)

        # 7. [Storage] Set SEL time (required for RTC)
        print "Testing Set SEL time"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_TIME)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_SEL_TIME + " \'" + l_res[-1] + "\'; echo $?")
        if l_res[-1] != "0":
            l_msg = "IPMI: Set SEL time command failed"
            raise OpTestError(l_msg)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SEL_TIME)

        # 8. [Transport] Get LAN parameters
        print "Testing Get LAN parameters"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_LAN_PARAMETERS)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get LAN parameters command failed"
            raise OpTestError(l_msg)

        # 9.[Chassis] Get System Boot Options
        print "Testing Get System Boot Options"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_BOOT_OPTIONS)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get System Boot Options command failed"
            raise OpTestError(l_msg)

        # 10.[Chassis] Set System Boot Options
        print "Testing Set System Boot Options"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_SYTEM_BOOT_OPTIONS)
        if l_res[-1] != "0":
            l_msg = "IPMI: Set System Boot Options command failed"
            raise OpTestError(l_msg)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_BOOT_OPTIONS)

        # 11. [App] Get BMC Global Enables
        print "Testing Get BMC Global Enables"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BMC_GLOBAL_ENABLES_RAW)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get BMC Global Enables command failed"
            raise OpTestError(l_msg)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BMC_GLOBAL_ENABLES)

        # 12. [App] Set BMC Global Enables
        print "Testing Set BMC Global Enables"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_BMC_GLOBAL_ENABLES_SEL_OFF)
        if l_res[-1] != "0":
            l_msg = "IPMI: Set BMC Global Enables sel=off command failed"
            raise OpTestError(l_msg)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BMC_GLOBAL_ENABLES)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_BMC_GLOBAL_ENABLES_SEL_ON)

        # 13.[App] Get System Interface Capabilities
        print "Testing Get System Interface Capabilities"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_INTERFACE_CAPABILITIES_SSIF)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get System Interface Capabilities SSIF command failed"
            raise OpTestError(l_msg)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SYSTEM_INTERFACE_CAPABILITIES_KCS)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get System Interface Capabilities KCS command failed"
            raise OpTestError(l_msg)

        # 14.[App] Get Message Flags
        print "Testing Get Message Flags"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_MESSAGE_FLAGS)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get Message Flags command failed"
            raise OpTestError(l_msg)

        # 15. [App] Get BT Capabilities
        print "Testing Get BT Capabilities"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_BT_CAPABILITIES)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get BT Capabilities command failed"
            raise OpTestError(l_msg)

        # 16. [App] Clear Message Flags
        print "Testing Clear Message Flags"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_CLEAR_MESSAGE_FLAGS)
        if l_res[-1] != "0":
            l_msg = "IPMI: Clear Message Flags command failed"
            raise OpTestError(l_msg)

        # 17. [OEM] PNOR Access Status
        print "Testing the PNOR Access Status"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_DENY)
        if l_res[-1] != "0":
            l_msg = "IPMI: PNOR Access Status:deny command failed"
            raise OpTestError(l_msg)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_GRANT)
        if l_res[-1] != "0":
            l_msg = "IPMI: PNOR Access Status:grant command failed"
            raise OpTestError(l_msg)

        # 18. [Storage] Add SEL Entry
        print "Testing Add SEL Entry"
        print "Clearing the SEL list"
        self.cv_IPMI.ipmi_sdr_clear()
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_ADD_SEL_ENTRY)
        if l_res[-1] != "0":
            l_msg = "IPMI: Add SEL Entry command failed"
            raise OpTestError(l_msg)
        l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LIST_LAST_SEL_EVENT)
        print "Checking for Reserved entry creation in SEL"
        if "Reserved" not in l_res:
            l_msg = "IPMI: Add SEL Entry command, doesn't create an SEL event"
            raise OpTestError(l_msg)

        # 19. [App] Set Power State
        print "Testing Set Power State"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_ACPI_POWER_STATE)
        if l_res[-1] != "0":
            l_msg = "IPMI: Set Power State command failed"
            raise OpTestError(l_msg)

        # 20. [App] Set watchdog
        print "Testing Set watchdog"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_SET_WATCHDOG)
        if l_res[-1] != "0":
            l_msg = "IPMI: Set watchdog command failed"
            raise OpTestError(l_msg)
        self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_MC_WATCHDOG_GET)

        # 21. [Sensor/Event] Get Sensor Type
        print "Testing Get Sensor Type"
        l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_SDR_GET_WATCHDOG)
        matchObj = re.search( "Watchdog \((0x\d{1,})\)", l_res)
        if matchObj:
            print "Got sensor Id for watchdog: %s" % matchObj.group(1)
        else:
            l_msg = "Failed to get sensor id for watchdog sensor"
            raise OpTestError(l_msg)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SENSOR_TYPE_FOR_WATCHDOG + " " + matchObj.group(1) + " ;echo $?")
        if l_res[-1] != "0":
            l_msg = "IPMI: Get Sensor Type command failed"
            raise OpTestError(l_msg)

        # 22.[Sensor/Event] Get Sensor Reading
        print "Testing Get Sensor Reading"
        l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_SDR_GET_WATCHDOG)
        matchObj = re.search( "Watchdog \((0x\d{1,})\)", l_res)
        if matchObj:
            print "Got sensor Id for watchdog: %s" % matchObj.group(1)
        else:
            l_msg = "Failed to get sensor id for watchdog sensor"
            raise OpTestError(l_msg)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_SENSOR_READING + " " + matchObj.group(1) + " ;echo $?")
        if l_res[-1] != "0":
            l_msg = "IPMI: Get Sensor Reading command failed"
            raise OpTestError(l_msg)

        # 23.[Sensor/Event] Platform Event (0x02)
        print "Testing Platform Event"
        self.cv_IPMI.ipmi_sdr_clear()
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PLATFORM_EVENT)
        if l_res[-1] != "0":
            l_msg = "IPMI: Platform Event command failed"
            raise OpTestError(l_msg)
        l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LIST_LAST_SEL_EVENT)
        if "Reserved" not in l_res:
            l_msg = "IPMI: Platform Event command failed to log SEL event"
            raise OpTestError(l_msg)

        # 24. [OEM] PNOR Access Response (0x08)
        print "Testing PNOR Access Response"
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_GRANT)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_RESPONSE)
        if l_res[-1] != "0":
            l_msg = "IPMI: PNOR Access Response command failed"
            raise OpTestError(l_msg)
        self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_STATUS_DENY)
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_PNOR_ACCESS_RESPONSE)
        if l_res[-1] != "0":
            l_msg = "IPMI: PNOR Access Response command failed"
            raise OpTestError(l_msg)

        # 25.[Chassis] Chassis Control
        print "Testing chassis power on"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_CHASSIS_POWER_ON)
        if l_res[-1] != "0":
            l_msg = "IPMI: chassis power on command failed"
            raise OpTestError(l_msg)

        # 26.[App] 0x38 Get Channel Authentication Cap
        print "Testing Get Channel Authentication Capabilities"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_CHANNEL_AUTH_CAP)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get Channel Authentication Capabilities command failed"
            raise OpTestError(l_msg)

        # 27.[App] Reset Watchdog (0x22)
        print "Testing reset watchdog"
        self.cv_IPMI.ipmi_sdr_clear()
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_RESET_WATCHDOG)
        if l_res[-1] != "0":
            l_msg = "IPMI: Reset Watchdog command failed"
            raise OpTestError(l_msg)

        time.sleep(10)
        # Reset watchdog should create a SEL event log
        l_res = self.cv_IPMI.ipmitool_execute_command(BMC_CONST.IPMI_LIST_LAST_SEL_EVENT)
        if "Watchdog" not in l_res:
            l_msg = "IPMI: Reset Watchdog command, doesn't create an SEL event"
            raise OpTestError(l_msg)

        # 28. [App] Get ACPI Power State (0x06)
        print "Testing Get ACPI Power State"
        l_res = self.cv_IPMI.run_lpar_cmd_on_ipmi_console(BMC_CONST.LPAR_GET_ACPI_POWER_STATE)
        if l_res[-1] != "0":
            l_msg = "IPMI: Get ACPI Power State command failed"
            raise OpTestError(l_msg)
Esempio n. 2
0
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_lparIP The IP address of the LPAR
    # @param i_lparuser The userid to log into the LPAR
    # @param i_lparPasswd The password of the userid to log into the LPAR with
    #
    def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd,
                 i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_lparip=None,
                 i_lparuser=None, i_lparPasswd=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_LPAR = OpTestLpar(i_lparip, i_lparuser, i_lparPasswd,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_LPAR.lpar_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_LPAR.lpar_get_kernel_version()

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

        l_val = self.cv_LPAR.lpar_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_LPAR.lpar_load_ibmpowernv(l_oslevel)

        # Checking for sensors command and lm_sensors package
        self.cv_LPAR.lpar_check_command("sensors")

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

        # Restart the lm_sensor service
        self.cv_LPAR.lpar_start_lm_sensor_svc(l_oslevel)

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

        # Checking sensors command functionality with different options
        output = self.cv_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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
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_lparIP The IP address of the LPAR
    # @param i_lparuser The userid to log into the LPAR
    # @param i_lparPasswd The password of the userid to log into the LPAR with
    #
    def __init__(self, i_bmcIP, i_bmcUser, i_bmcPasswd,
                 i_bmcUserIpmi, i_bmcPasswdIpmi, i_ffdcDir=None, i_lparip=None,
                 i_lparuser=None, i_lparPasswd=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_LPAR = OpTestLpar(i_lparip, i_lparuser, i_lparPasswd, 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_LPAR.lpar_get_OS_Level()

        # Get kernel version
        l_kernel = self.cv_LPAR.lpar_get_kernel_version()

        # Checking for ipmitool command and lm_sensors package
        self.cv_LPAR.lpar_check_command("ipmitool")

        l_pkg = self.cv_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_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_LPAR.lpar_run_command(l_cmd)
        if l_res.__contains__("Chassis identify interval: 1 seconds"):
            print "ipmitool Chassis identify interval is working"
        else:
            l_msg = "ipmitool Chassis identify interval is not working,exiting...."
            raise OpTestError(l_msg)

        l_cmd = "ipmitool chassis identify force; echo $?"
        l_res = self.cv_LPAR.lpar_run_command(l_cmd)
        if l_res.__contains__("Chassis identify interval: indefinite"):
            print "ipmitool Chassis identify interval is working"
        else:
            l_msg = "ipmitool Chassis identify interval is not working"
            raise OpTestError(l_msg)


        l_cmd = "ipmitool sensor list; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool sensor list is not working,exiting...."
            raise OpTestError(l_msg)


        l_cmd = "ipmitool mc info; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool mc info is not working,exiting...."
            raise OpTestError(l_msg)

        l_cmd = "ipmitool mc selftest; echo $?"
        l_res = self.cv_LPAR.lpar_run_command(l_cmd)
        if l_res.__contains__("Selftest: passed"):
            print "ipmitool mc selftest is passed"
        else:
            l_msg = "ipmitool mc selftest is failing"
            raise OpTestError(l_msg)

        l_cmd = "ipmitool mc getenables; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool mc getenables is not working,exiting...."
            raise OpTestError(l_msg)

        l_cmd = "ipmitool mc watchdog get; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool mc watchdog get is not working,exiting...."
            raise OpTestError(l_msg)



        l_cmd = "ipmitool sel info; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool sel info is not working,exiting...."
            raise OpTestError(l_msg)

        l_cmd = "ipmitool sel list; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool sel list is not working,exiting...."
            raise OpTestError(l_msg)


        l_cmd = "ipmitool sel list last 3 | grep \"PCI resource configuration\" | awk \'{ print $1 }\'"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        l_cmd = "ipmitool sel get 0x" + response[1] + "; echo $?"
        output = self.cv_LPAR.lpar_run_command(l_cmd)
        response = output.splitlines()
        if int(response[-1]):
            l_msg = "ipmitool sel get is not working,exiting...."
            raise OpTestError(l_msg)
        
        return BMC_CONST.FW_SUCCESS