ipmi_client.robot to use new create_ipmi_ext_command_string
- Changed the 'external' IPMI functions to use new
create_ipmi_ext_command_string and to forego the use of the old
IPMI_EXT_CMD global variable.
- Changed 'Run External IPMI Raw Command' to simply call
'Run External IPMI Standard Command'.
Also:
- Coding standards:
- 2 blank lines betweeen keywords
- Consistency: Changed many keyword argument names "args" to "command".
- Added "Description of argument(s):"
- Indented if/else body code
Change-Id: If2c1d6c3e2fbf438e17dc1e125937f76a5bde2b3
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index cadae5e..cedc9e5 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -16,7 +16,6 @@
${netfnByte}= ${EMPTY}
${cmdByte}= ${EMPTY}
${arrayByte}= array:byte:
-${IPMI_EXT_CMD} ${EMPTY}
${IPMI_USER_OPTIONS} ${EMPTY}
${IPMI_INBAND_CMD}= ipmitool -C ${IPMI_CIPHER_LEVEL}
${HOST}= -H
@@ -25,121 +24,154 @@
*** Keywords ***
Run IPMI Command
- [Documentation] Run the given IPMI command.
- [Arguments] ${args}
+ [Documentation] Run the raw IPMI command.
+ [Arguments] ${command} ${fail_on_err}=${1} &{options}
+
+ # Description of argument(s):
+ # command The IPMI command string to be executed
+ # (e.g. "power status").
+ # fail_on_err Fail if the IPMI command execution fails.
+ # options Additional ipmitool command options (e.g.
+ # -C=3, -I=lanplus, etc.). Currently, only
+ # used for external IPMI commands.
+
${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
- ... Run External IPMI Raw Command ${args}
+ ... Run External IPMI Raw Command ${command} ${fail_on_err} &{options}
... ELSE IF '${IPMI_COMMAND}' == 'Inband'
- ... Run Inband IPMI Raw Command ${args}
+ ... Run Inband IPMI Raw Command ${command}
... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
- ... Run Dbus IPMI RAW Command ${args}
- ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
+ ... Run Dbus IPMI RAW Command ${command}
+ ... ELSE Fail msg=Invalid IPMI Command type provided: ${IPMI_COMMAND}
[Return] ${resp}
+
Run IPMI Standard Command
[Documentation] Run the standard IPMI command.
- [Arguments] ${args} ${fail_on_err}=${1}
+ [Arguments] ${command} ${fail_on_err}=${1} &{options}
# Description of argument(s):
- # args IPMI command to be executed.
- # fail_on_err Fail if keyword the IPMI command fails
+ # command The IPMI command string to be executed
+ # (e.g. "0x06 0x36").
+ # fail_on_err Fail if the IPMI command execution fails.
+ # options Additional ipmitool command options (e.g.
+ # -C=3, -I=lanplus, etc.). Currently, only
+ # used for external IPMI commands.
${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
- ... Run External IPMI Standard Command ${args} ${fail_on_err}
+ ... Run External IPMI Standard Command ${command} ${fail_on_err} &{options}
... ELSE IF '${IPMI_COMMAND}' == 'Inband'
- ... Run Inband IPMI Standard Command ${args} ${fail_on_err}
+ ... Run Inband IPMI Standard Command ${command} ${fail_on_err}
... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
- ... Run Dbus IPMI Standard Command ${args}
+ ... Run Dbus IPMI Standard Command ${command}
... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
[Return] ${resp}
+
Run Dbus IPMI RAW Command
[Documentation] Run the raw IPMI command through dbus.
- [Arguments] ${args}
- ${valueinBytes}= Byte Conversion ${args}
+ [Arguments] ${command}
+ ${valueinBytes}= Byte Conversion ${command}
${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
${cmd}= Catenate ${cmd} ${valueinBytes}
${output} ${stderr}= Execute Command ${cmd} return_stderr=True
Should Be Empty ${stderr}
set test variable ${OUTPUT} "${output}"
+
Run Dbus IPMI Standard Command
[Documentation] Run the standard IPMI command through dbus.
- [Arguments] ${args}
+ [Arguments] ${command}
Copy ipmitool
${stdout} ${stderr} ${output}= Execute Command
- ... /tmp/ipmitool -I dbus ${args} return_stdout=True
+ ... /tmp/ipmitool -I dbus ${command} return_stdout=True
... return_stderr= True return_rc=True
Should Be Equal ${output} ${0} msg=${stderr}
[Return] ${stdout}
+
Run Inband IPMI Raw Command
[Documentation] Run the raw IPMI command in-band.
- [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
+ [Arguments] ${command} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
... ${os_password}=${OS_PASSWORD}
- # Description of arguments:
- # ${args} parameters to IPMI command.
- # ${os_host} IP address of the OS Host.
- # ${os_username} OS Host Login user name.
- # ${os_password} OS Host Login passwrd.
+ # Description of argument(s):
+ # command The IPMI command string to be executed
+ # (e.g. "0x06 0x36").
+ # os_host The host name or IP address of the OS Host.
+ # os_username The OS host user name.
+ # os_password The OS host passwrd.
Login To OS Host ${os_host} ${os_username} ${os_password}
Check If IPMI Tool Exist
- ${inband_raw_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${args}
- ${stdout} ${stderr}= Execute Command ${inband_raw_cmd} return_stderr=True
+ ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${RAW} ${command}
+ Qprint Issuing ${ipmi_cmd}
+ ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True
Should Be Empty ${stderr} msg=${stdout}
[Return] ${stdout}
+
Run Inband IPMI Standard Command
[Documentation] Run the standard IPMI command in-band.
- [Arguments] ${args} ${fail_on_err}=${1} ${os_host}=${OS_HOST}
+ [Arguments] ${command} ${fail_on_err}=${1} ${os_host}=${OS_HOST}
... ${os_username}=${OS_USERNAME} ${os_password}=${OS_PASSWORD}
- # Description of arguments:
- # ${args} parameters to IPMI command.
- # ${os_host} IP address of the OS Host.
- # ${os_username} OS Host Login user name.
- # ${os_password} OS Host Login passwrd.
+ # Description of argument(s):
+ # command The IPMI command string to be executed
+ # (e.g. "power status").
+ # os_host The host name or IP address of the OS Host.
+ # os_username The OS host user name.
+ # os_password The OS host passwrd.
Login To OS Host ${os_host} ${os_username} ${os_password}
Check If IPMI Tool Exist
- ${inband_std_cmd}= Catenate ${IPMI_INBAND_CMD} ${args}
- ${stdout} ${stderr}= Execute Command ${inband_std_cmd} return_stderr=True
+ ${ipmi_cmd}= Catenate ${IPMI_INBAND_CMD} ${command}
+ Qprint Issuing ${ipmi_cmd}
+ ${stdout} ${stderr}= Execute Command ${ipmi_cmd} return_stderr=True
Return From Keyword If ${fail_on_err} == ${0} ${stderr}
Should Be Empty ${stderr} msg=${stdout}
[Return] ${stdout}
-Run External IPMI Raw Command
- [Documentation] Run the raw IPMI command externally.
- [Arguments] ${args}
-
- ${ipmi_raw_cmd}= Catenate SEPARATOR=
- ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}
- ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${RAW}${SPACE}${args}
- ${rc} ${output}= Run and Return RC and Output ${ipmi_raw_cmd}
- Should Be Equal ${rc} ${0} msg=${output}
- [Return] ${output}
Run External IPMI Standard Command
- [Documentation] Run the standard IPMI command in-band.
- [Arguments] ${args} ${fail_on_err}=${1}
+ [Documentation] Run the external IPMI standard command.
+ [Arguments] ${command} ${fail_on_err}=${1} &{options}
# Description of argument(s):
- # args IPMI command to be executed.
- # fail_on_err Fail if keyword the IPMI command fails
+ # command The IPMI command string to be executed
+ # (e.g. "power status"). Note that if
+ # ${IPMI_USER_OPTIONS} has a value (e.g.
+ # "-vvv"), it will be pre-pended to this
+ # command string.
+ # fail_on_err Fail if the IPMI command execution fails.
+ # options Additional ipmitool command options (e.g.
+ # -C=3, -I=lanplus, etc.).
- ${ipmi_cmd}= Catenate SEPARATOR=
- ... ${IPMI_EXT_CMD} ${IPMI_USER_OPTIONS} -P${SPACE}${IPMI_PASSWORD}
- ... ${SPACE}${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${args}
+ ${command_string}= Process IPMI User Options ${command}
+ ${ipmi_cmd}= Create IPMI Ext Command String ${command_string} &{options}
+ Qprint Issuing ${ipmi_cmd}
${rc} ${output}= Run And Return RC and Output ${ipmi_cmd}
Return From Keyword If ${fail_on_err} == ${0} ${output}
Should Be Equal ${rc} ${0} msg=${output}
[Return] ${output}
+
+Run External IPMI Raw Command
+ [Documentation] Run the external IPMI raw command.
+ [Arguments] ${command} ${fail_on_err}=${1} &{options}
+
+ # This keyword is a wrapper for 'Run External IPMI Standard Command'. See
+ # that keyword's prolog for argument details. This keyword will pre-pend
+ # the word "raw" plus a space to command prior to calling 'Run External
+ # IPMI Standard Command'.
+
+ ${output}= Run External IPMI Standard Command
+ ... raw ${command} ${fail_on_err} &{options}
+ [Return] ${output}
+
+
Check If IPMI Tool Exist
[Documentation] Check if IPMI Tool installed or not.
${output}= Execute Command which ipmitool
@@ -149,15 +181,15 @@
Activate SOL Via IPMI
[Documentation] Start SOL using IPMI and route output to a file.
[Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST}
+
# Description of argument(s):
- # file_path The file path on the local machine (vs OBMC) to collect SOL
- # output. By default SOL output is collected at
- # /tmp/sol_<BMC_IP> else user input location.
+ # file_path The file path on the local machine (vs.
+ # OBMC) to collect SOL output. By default
+ # SOL output is collected at
+ # /tmp/sol_<BMC_IP> else user input location.
- ${ipmi_cmd}= Catenate SEPARATOR=
- ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}${HOST}
- ... ${SPACE}${OPENBMC_HOST}${SPACE}sol activate usesolkeepalive
-
+ ${ipmi_cmd}= Create IPMI Ext Command String sol activate usesolkeepalive
+ Qprint Issuing ${ipmi_cmd}
Start Process ${ipmi_cmd} shell=True stdout=${file_path}
... alias=sol_proc
@@ -165,15 +197,15 @@
Deactivate SOL Via IPMI
[Documentation] Stop SOL using IPMI and return SOL output.
[Arguments] ${file_path}=/tmp/sol_${OPENBMC_HOST}
+
# Description of argument(s):
- # file_path The file path on the local machine to copy SOL output
- # collected by above "Activate SOL Via IPMI" keyword.
- # By default it copies log from /tmp/sol_<BMC_IP>.
+ # file_path The file path on the local machine to copy
+ # SOL output collected by above "Activate
+ # SOL Via IPMI" keyword. By default it
+ # copies log from /tmp/sol_<BMC_IP>.
- ${ipmi_cmd}= Catenate SEPARATOR=
- ... ${IPMI_EXT_CMD} -P${SPACE}${IPMI_PASSWORD}${SPACE}
- ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}sol deactivate
-
+ ${ipmi_cmd}= Create IPMI Ext Command String sol deactivate
+ Qprint Issuing ${ipmi_cmd}
${rc} ${output}= Run and Return RC and Output ${ipmi_cmd}
Run Keyword If ${rc} > 0 Run Keywords
... Run Keyword And Ignore Error Terminate Process sol_proc
@@ -222,13 +254,13 @@
${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte}
${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte}
-# To Check scenario for smaller IPMI raw commands with only 2 arguments
-# instead of usual 12 arguments.
-# Sample small IPMI raw command: Run IPMI command 0x06 0x36
-# If IPMI raw argument length is only 9 then return value in bytes without
-# array population.
-# Equivalent dbus-send argument for smaller IPMI raw command:
-# byte:0x00 byte:0x06 byte:0x00 byte:0x36
+ # To Check scenario for smaller IPMI raw commands with only 2 arguments
+ # instead of usual 12 arguments.
+ # Sample small IPMI raw command: Run IPMI command 0x06 0x36
+ # If IPMI raw argument length is only 9 then return value in bytes without
+ # array population.
+ # Equivalent dbus-send argument for smaller IPMI raw command:
+ # byte:0x00 byte:0x06 byte:0x00 byte:0x36
Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray}
[Return] ${valueinBytesWithArray}
@@ -239,12 +271,14 @@
${netfnByteLocal}= Catenate byte:${word}
Set Global Variable ${netfnByte} ${netfnByteLocal}
+
Set Cmd Byte
[Documentation] Set the command byte.
[Arguments] ${word}
${cmdByteLocal}= Catenate byte:${word}
Set Global Variable ${cmdByte} ${cmdByteLocal}
+
Set Array Byte
[Documentation] Set the array byte.
[Arguments] ${word}
@@ -252,6 +286,7 @@
${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} ,
Set Global Variable ${arrayByte} ${arrayByteLocal}
+
Copy ipmitool
[Documentation] Copy the ipmitool to the BMC.
${ipmitool_error}= Catenate The ipmitool program could not be found in the tools directory.
@@ -267,11 +302,14 @@
Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
Execute Command chmod +x /tmp/ipmitool
+
Initiate Host Boot Via External IPMI
[Documentation] Initiate host power on using external IPMI.
[Arguments] ${wait}=${1}
+
# Description of argument(s):
- # wait Indicates that this keyword should wait for host running state.
+ # wait Indicates that this keyword should wait
+ # for host running state.
${output}= Run External IPMI Standard Command chassis power on
Should Not Contain ${output} Error
@@ -279,11 +317,14 @@
Run Keyword If '${wait}' == '${0}' Return From Keyword
Wait Until Keyword Succeeds 10 min 10 sec Is Host Running
+
Initiate Host PowerOff Via External IPMI
[Documentation] Initiate host power off using external IPMI.
[Arguments] ${wait}=${1}
+
# Description of argument(s):
- # wait Indicates that this keyword should wait for host off state.
+ # wait Indicates that this keyword should wait
+ # for host off state.
${output}= Run External IPMI Standard Command chassis power off
Should Not Contain ${output} Error
@@ -291,6 +332,7 @@
Run Keyword If '${wait}' == '${0}' Return From Keyword
Wait Until Keyword Succeeds 3 min 10 sec Is Host Off
+
Get Host State Via External IPMI
[Documentation] Returns host state using external IPMI.
@@ -306,7 +348,8 @@
[Arguments] ${nw_info}
# Description of argument(s):
- # nw_info A dictionary containing the network information to apply.
+ # nw_info A dictionary containing the network
+ # information to apply.
Run Inband IPMI Standard Command
... lan set 1 ipaddr ${nw_info['IP Address']}