blob: 83175dcb25177c8d8f4be426386e59f2cf1a6343 [file] [log] [blame]
Chris Austenb29d2e82016-06-07 12:25:35 -05001*** Settings ***
George Keishing4d6c1da2016-07-15 05:51:22 -05002Documentation This module is for IPMI client for copying ipmitool to
Sivas SRRa2dab3c2016-07-25 05:08:18 -05003... openbmc box and execute ipmitool IPMI standard
4... command. IPMI raw command will use dbus-send command
Chris Austenb29d2e82016-06-07 12:25:35 -05005Resource ../lib/resource.txt
George Keishing4d6c1da2016-07-15 05:51:22 -05006Resource ../lib/connection_client.robot
Sivas SRRa2dab3c2016-07-25 05:08:18 -05007Library String
8
9*** Variables ***
George Keishingd7f11f72017-01-04 10:58:19 -060010${dbusHostIpmicmd1}= dbus-send --system ${OPENBMC_BASE_URI}HostIpmi/1
11${dbusHostIpmiCmdReceivedMsg}= ${OPENBMC_BASE_DBUS}.HostIpmi.ReceivedMessage
Gunnar Mills59204d22016-12-06 11:05:19 -060012${netfnByte}= ${EMPTY}
George Keishingd7f11f72017-01-04 10:58:19 -060013${cmdByte}= ${EMPTY}
Gunnar Mills59204d22016-12-06 11:05:19 -060014${arrayByte}= array:byte:
15${IPMI_EXT_CMD}= ipmitool -I lanplus -C 1 -P
16${HOST}= -H
17${RAW}= raw
Chris Austenb29d2e82016-06-07 12:25:35 -050018
19*** Keywords ***
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050020
Chris Austenb29d2e82016-06-07 12:25:35 -050021Run IPMI Command
Gunnar Mills38032802016-12-12 13:43:40 -060022 [Arguments] ${args}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050023 ${resp}= Run Keyword If '${IPMI_COMMAND}'=='External'
24 ... Run External IPMI RAW Command ${args}
25 ... ELSE IF '${IPMI_COMMAND}'=='Dbus'
26 ... Run Dbus IPMI RAW Command ${args}
27 ... ELSE Fail
28 ... msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060029 [Return] ${resp}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050030
31Run IPMI Standard Command
Gunnar Mills38032802016-12-12 13:43:40 -060032 [Arguments] ${args}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050033 ${resp}= Run Keyword If '${IPMI_COMMAND}'=='External'
34 ... Run External IPMI Standard Command ${args}
35 ... ELSE IF '${IPMI_COMMAND}'=='Dbus'
36 ... Run Dbus IPMI Standard Command ${args}
37 ... ELSE Fail
38 ... msg=Invalid IPMI Command type provided : ${IPMI_COMMAND}
39
Gunnar Millsc9ea9362016-12-13 16:21:13 -060040 [Return] ${resp}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050041
42Run Dbus IPMI RAW Command
Gunnar Mills38032802016-12-12 13:43:40 -060043 [Arguments] ${args}
Gunnar Mills59204d22016-12-06 11:05:19 -060044 ${valueinBytes}= Byte Conversion ${args}
45 ${cmd}= Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
46 ${cmd}= Catenate ${cmd} ${valueinBytes}
Sivas SRRa2dab3c2016-07-25 05:08:18 -050047 ${output} ${stderr}= Execute Command ${cmd} return_stderr=True
48 Should Be Empty ${stderr}
Chris Austenb29d2e82016-06-07 12:25:35 -050049 set test variable ${OUTPUT} "${output}"
50
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050051Run Dbus IPMI Standard Command
Gunnar Mills38032802016-12-12 13:43:40 -060052 [Arguments] ${args}
George Keishing4d6c1da2016-07-15 05:51:22 -050053 Copy ipmitool
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050054 ${stdout} ${stderr} ${output}= Execute Command
55 ... /tmp/ipmitool -I dbus ${args} return_stdout=True
56 ... return_stderr= True return_rc=True
Chris Austenb29d2e82016-06-07 12:25:35 -050057 Should Be Equal ${output} ${0} msg=${stderr}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060058 [Return] ${stdout}
Chris Austenb29d2e82016-06-07 12:25:35 -050059
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050060Run External IPMI RAW Command
Gunnar Mills38032802016-12-12 13:43:40 -060061 [Arguments] ${args}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050062 ${ipmi_raw_cmd}= Catenate SEPARATOR=
63 ... ${IPMI_EXT_CMD}${SPACE}${IPMI_PASSWORD}${SPACE}
64 ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${RAW}${SPACE}${args}
65 ${rc} ${output}= Run and Return RC and Output ${ipmi_raw_cmd}
66 Should Be Equal ${rc} ${0} msg=${output}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060067 [Return] ${output}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050068
69Run External IPMI Standard Command
Gunnar Mills38032802016-12-12 13:43:40 -060070 [Arguments] ${args}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050071 ${ipmi_cmd}= Catenate SEPARATOR=
72 ... ${IPMI_EXT_CMD}${SPACE}${IPMI_PASSWORD}${SPACE}
73 ... ${HOST}${SPACE}${OPENBMC_HOST}${SPACE}${args}
74 ${rc} ${output}= Run and Return RC and Output ${ipmi_cmd}
75 Should Be Equal ${rc} ${0} msg=${output}
Gunnar Millsc9ea9362016-12-13 16:21:13 -060076 [Return] ${output}
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050077
78
Sivas SRRa2dab3c2016-07-25 05:08:18 -050079Byte Conversion
80 [Documentation] Byte Conversion method receives IPMI RAW commands as
81 ... argument in string format.
82 ... Sample argument is as follows
83 ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
84 ... 0x00"
85 ... IPMI RAW command format is as follows
86 ... <netfn Byte> <cmd Byte> <Data Bytes..>
87 ... This method converts IPMI command format into
88 ... dbus command format as follows
89 ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
90 ... <array:byte:data>
91 ... Sample dbus Host IPMI Received Message argument
92 ... byte:0x00 byte:0x04 byte:0x00 byte:0x30
93 ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
Gunnar Mills38032802016-12-12 13:43:40 -060094 [Arguments] ${args}
Gunnar Mills59204d22016-12-06 11:05:19 -060095 ${argLength}= Get Length ${args}
Sivas SRRa2dab3c2016-07-25 05:08:18 -050096 Set Global Variable ${arrayByte} array:byte:
Gunnar Mills59204d22016-12-06 11:05:19 -060097 @{listargs}= Split String ${args}
98 ${index}= Set Variable ${0}
Sivas SRRa2dab3c2016-07-25 05:08:18 -050099 :FOR ${word} in @{listargs}
100 \ Run Keyword if ${index} == 0 Set NetFn Byte ${word}
101 \ Run Keyword if ${index} == 1 Set Cmd Byte ${word}
102 \ Run Keyword if ${index} > 1 Set Array Byte ${word}
Gunnar Mills59204d22016-12-06 11:05:19 -0600103 \ ${index}= Set Variable ${index + 1}
104 ${length}= Get Length ${arrayByte}
105 ${length}= Evaluate ${length} - 1
106 ${arrayByteLocal}= Get Substring ${arrayByte} 0 ${length}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500107 Set Global Variable ${arrayByte} ${arrayByteLocal}
Gunnar Mills59204d22016-12-06 11:05:19 -0600108 ${valueinBytesWithArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
109 ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${cmdByte}
110 ${valueinBytesWithArray}= Catenate ${valueinBytesWithArray} ${arrayByte}
111 ${valueinBytesWithoutArray}= Catenate byte:0x00 ${netfnByte} byte:0x00
112 ${valueinBytesWithoutArray}= Catenate ${valueinBytesWithoutArray} ${cmdByte}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500113# To Check scenario for smaller IPMI raw commands with only 2 arguments
114# instead of usual 12 arguments.
115# Sample small IPMI raw command: Run IPMI command 0x06 0x36
116# If IPMI raw argument length is only 9 then return value in bytes without
117# array population.
118# Equivalent dbus-send argument for smaller IPMI raw command:
119# byte:0x00 byte:0x06 byte:0x00 byte:0x36
120 Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray}
Gunnar Millsc9ea9362016-12-13 16:21:13 -0600121 [Return] ${valueinBytesWithArray}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500122
123
124Set NetFn Byte
Gunnar Mills38032802016-12-12 13:43:40 -0600125 [Arguments] ${word}
Gunnar Mills59204d22016-12-06 11:05:19 -0600126 ${netfnByteLocal}= Catenate byte:${word}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500127 Set Global Variable ${netfnByte} ${netfnByteLocal}
128
129Set Cmd Byte
Gunnar Mills38032802016-12-12 13:43:40 -0600130 [Arguments] ${word}
Gunnar Mills59204d22016-12-06 11:05:19 -0600131 ${cmdByteLocal}= Catenate byte:${word}
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500132 Set Global Variable ${cmdByte} ${cmdByteLocal}
133
134Set Array Byte
Gunnar Mills38032802016-12-12 13:43:40 -0600135 [Arguments] ${word}
Gunnar Mills59204d22016-12-06 11:05:19 -0600136 ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByte} ${word}
137 ${arrayByteLocal}= Catenate SEPARATOR= ${arrayByteLocal} ,
Sivas SRRa2dab3c2016-07-25 05:08:18 -0500138 Set Global Variable ${arrayByte} ${arrayByteLocal}
139
Chris Austenb29d2e82016-06-07 12:25:35 -0500140Copy ipmitool
141 OperatingSystem.File Should Exist tools/ipmitool msg=The ipmitool program could not be found in the tools directory. It is not part of the automation code by default. You must manually copy or link the correct openbmc version of the tool in to the tools directory in order to run this test suite.
142
143 Import Library SCPLibrary WITH NAME scp
144 scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD}
145 scp.Put File tools/ipmitool /tmp
146 SSHLibrary.Open Connection ${OPENBMC_HOST}
147 Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
148 Execute Command chmod +x /tmp/ipmitool