blob: 079804ccac63182c8d7b4198519c69f04ebc8d63 [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 ***
10${dbusHostIpmicmd1} = dbus-send --system /org/openbmc/HostIpmi/1
11${dbusHostIpmiCmdReceivedMsg} = org.openbmc.HostIpmi.ReceivedMessage
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050012${netfnByte} = ${EMPTY}
13${cmdByte} = ${EMPTY}
14${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
22 [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}
29 [return] ${resp}
30
31Run IPMI Standard Command
32 [arguments] ${args}
33 ${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
40 [return] ${resp}
41
42Run Dbus IPMI RAW Command
43 [arguments] ${args}
Sivas SRRa2dab3c2016-07-25 05:08:18 -050044 ${valueinBytes} = Byte Conversion ${args}
45 ${cmd} = Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
46 ${cmd} = Catenate ${cmd} ${valueinBytes}
47 ${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
Chris Austenb29d2e82016-06-07 12:25:35 -050052 [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}
58 [return] ${stdout}
59
Rahul Maheshwari7a212a02016-09-05 21:17:30 -050060Run External IPMI RAW Command
61 [arguments] ${args}
62 ${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}
67 [return] ${output}
68
69Run External IPMI Standard Command
70 [arguments] ${args}
71 ${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}
76 [return] ${output}
77
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
94 [arguments] ${args}
95 ${argLength} = Get Length ${args}
96 Set Global Variable ${arrayByte} array:byte:
97 @{listargs} = Split String ${args}
98 ${index} = Set Variable ${0}
99 :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}
103 \ ${index} = Set Variable ${index + 1}
104 ${length} = Get Length ${arrayByte}
105 ${length} = Evaluate ${length} - 1
106 ${arrayByteLocal} = Get Substring ${arrayByte} 0 ${length}
107 Set Global Variable ${arrayByte} ${arrayByteLocal}
108 ${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}
113# 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}
121 [return] ${valueinBytesWithArray}
122
123
124Set NetFn Byte
125 [arguments] ${word}
126 ${netfnByteLocal} = Catenate byte:${word}
127 Set Global Variable ${netfnByte} ${netfnByteLocal}
128
129Set Cmd Byte
130 [arguments] ${word}
131 ${cmdByteLocal} = Catenate byte:${word}
132 Set Global Variable ${cmdByte} ${cmdByteLocal}
133
134Set Array Byte
135 [arguments] ${word}
136 ${arrayByteLocal} = Catenate SEPARATOR= ${arrayByte} ${word}
137 ${arrayByteLocal} = Catenate SEPARATOR= ${arrayByteLocal} ,
138 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