Inband IPMI via Host OS
This change addresses:
1. Opening connection to Host OS
2. Running inband IPMI commands from Host OS
Resolves openbmc/openbmc-test-automation/issues/389
Change-Id: I8035135066b4a2b769fa6273817c9a61ad09ab49
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
diff --git a/lib/ipmi_client.robot b/lib/ipmi_client.robot
index 65fec87..52bd897 100755
--- a/lib/ipmi_client.robot
+++ b/lib/ipmi_client.robot
@@ -4,6 +4,9 @@
... command. IPMI raw command will use dbus-send command
Resource ../lib/resource.txt
Resource ../lib/connection_client.robot
+Resource ../lib/utils.robot
+Resource ../lib/state_manager.robot
+
Library String
*** Variables ***
@@ -13,31 +16,34 @@
${cmdByte}= ${EMPTY}
${arrayByte}= array:byte:
${IPMI_EXT_CMD}= ipmitool -I lanplus -C 3 -P
+${IPMI_INBAND_CMD}= ipmitool -C 3
${HOST}= -H
${RAW}= raw
*** Keywords ***
Run IPMI Command
- [Arguments] ${args}
- ${resp}= Run Keyword If '${IPMI_COMMAND}'=='External'
- ... Run External IPMI RAW Command ${args}
- ... ELSE IF '${IPMI_COMMAND}'=='Dbus'
- ... Run Dbus IPMI RAW Command ${args}
- ... ELSE Fail
- ... msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
- [Return] ${resp}
+ [Arguments] ${args}
+ ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
+ ... Run External IPMI RAW Command ${args}
+ ... ELSE IF '${IPMI_COMMAND}' == 'Inband'
+ ... Run Inband IPMI RAW Command ${args}
+ ... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
+ ... Run Dbus IPMI RAW Command ${args}
+ ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
+ [Return] ${resp}
Run IPMI Standard Command
- [Arguments] ${args}
- ${resp}= Run Keyword If '${IPMI_COMMAND}'=='External'
- ... Run External IPMI Standard Command ${args}
- ... ELSE IF '${IPMI_COMMAND}'=='Dbus'
- ... Run Dbus IPMI Standard Command ${args}
- ... ELSE Fail
- ... msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
+ [Arguments] ${args}
+ ${resp}= Run Keyword If '${IPMI_COMMAND}' == 'External'
+ ... Run External IPMI Standard Command ${args}
+ ... ELSE IF '${IPMI_COMMAND}' == 'Inband'
+ ... Run Inband IPMI Standard Command ${args}
+ ... ELSE IF '${IPMI_COMMAND}' == 'Dbus'
+ ... Run Dbus IPMI Standard Command ${args}
+ ... ELSE Fail msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
- [Return] ${resp}
+ [Return] ${resp}
Run Dbus IPMI RAW Command
[Arguments] ${args}
@@ -57,6 +63,44 @@
Should Be Equal ${output} ${0} msg=${stderr}
[Return] ${stdout}
+Run Inband IPMI Raw Command
+ [Documentation] Run Inband IPMI raw command.
+ [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
+ ... ${os_password}=${OS_PASSWORD}
+
+ # Desription 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.
+
+ 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
+ Should Be Empty ${stderr} msg=${stdout}
+ [Return] ${stdout}
+
+Run Inband IPMI Standard Command
+ [Documentation] Run Inband IPMI standard command.
+ [Arguments] ${args} ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
+ ... ${os_password}=${OS_PASSWORD}
+
+ # Desription 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.
+
+ 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
+ Should Be Empty ${stderr} msg=${stdout}
+ [Return] ${stdout}
+
Run External IPMI RAW Command
[Arguments] ${args}
${ipmi_raw_cmd}= Catenate SEPARATOR=
@@ -75,6 +119,10 @@
Should Be Equal ${rc} ${0} msg=${output}
[Return] ${output}
+Check If IPMI Tool Exist
+ [Documentation] Check if IPMI Tool installed or not.
+ ${output}= Execute Command which ipmitool
+ Should Not Be Empty ${output} msg=ipmitool not installed.
Byte Conversion
[Documentation] Byte Conversion method receives IPMI RAW commands as
diff --git a/lib/utils.robot b/lib/utils.robot
index 21a073e..74c8d99 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -774,3 +774,21 @@
Execute Command On BMC
... /usr/sbin/mapper call /org/openbmc/watchdog/host0 org.openbmc.Watchdog start
Sleep ${sleep_time}
+
+Login To OS Host
+ [Documentation] Login to OS Host.
+ [Arguments] ${os_host}=${OS_HOST} ${os_username}=${OS_USERNAME}
+ ... ${os_password}=${OS_PASSWORD}
+ # Desription of arguments:
+ # ${os_host} IP address of the OS Host.
+ # ${os_username} OS Host Login user name.
+ # ${os_password} OS Host Login passwrd.
+
+ ${os_state}= Run Keyword And Return Status Ping Host ${os_host}
+ Run Keyword If '${os_state}' == 'False'
+ ... Run Keywords Initiate Host Reboot AND
+ ... Is Host Running AND
+ ... Wait for OS ${os_host} ${os_username} ${os_password}
+
+ Open Connection ${os_host}
+ Login ${os_username} ${os_password}