blob: 6e50e8bf73e2203923f522bba7c334e150456846 [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
12${netfnByte} = ${EMPTY}
13${cmdByte} = ${EMPTY}
14${arrayByte} = array:byte:
Chris Austenb29d2e82016-06-07 12:25:35 -050015
16*** Keywords ***
Chris Austenb29d2e82016-06-07 12:25:35 -050017Run IPMI Command
18 [arguments] ${args}
Sivas SRRa2dab3c2016-07-25 05:08:18 -050019 ${valueinBytes} = Byte Conversion ${args}
20 ${cmd} = Catenate ${dbushostipmicmd1} ${dbusHostIpmiCmdReceivedMsg}
21 ${cmd} = Catenate ${cmd} ${valueinBytes}
22 ${output} ${stderr}= Execute Command ${cmd} return_stderr=True
23 Should Be Empty ${stderr}
Chris Austenb29d2e82016-06-07 12:25:35 -050024 set test variable ${OUTPUT} "${output}"
25
26Run IPMI Standard Command
27 [arguments] ${args}
George Keishing4d6c1da2016-07-15 05:51:22 -050028 Copy ipmitool
Chris Austenb29d2e82016-06-07 12:25:35 -050029 ${stdout} ${stderr} ${output}= Execute Command /tmp/ipmitool -I dbus ${args} return_stdout=True return_stderr= True return_rc=True
30 Should Be Equal ${output} ${0} msg=${stderr}
31 [return] ${stdout}
32
Sivas SRRa2dab3c2016-07-25 05:08:18 -050033Byte Conversion
34 [Documentation] Byte Conversion method receives IPMI RAW commands as
35 ... argument in string format.
36 ... Sample argument is as follows
37 ... "0x04 0x30 9 0x01 0x00 0x35 0x00 0x00 0x00 0x00 0x00
38 ... 0x00"
39 ... IPMI RAW command format is as follows
40 ... <netfn Byte> <cmd Byte> <Data Bytes..>
41 ... This method converts IPMI command format into
42 ... dbus command format as follows
43 ... <byte:seq-id> <byte:netfn> <byte:lun> <byte:cmd>
44 ... <array:byte:data>
45 ... Sample dbus Host IPMI Received Message argument
46 ... byte:0x00 byte:0x04 byte:0x00 byte:0x30
47 ... array:byte:9,0x01,0x00,0x35,0x00,0x00,0x00,0x00,0x00,0x00
48 [arguments] ${args}
49 ${argLength} = Get Length ${args}
50 Set Global Variable ${arrayByte} array:byte:
51 @{listargs} = Split String ${args}
52 ${index} = Set Variable ${0}
53 :FOR ${word} in @{listargs}
54 \ Run Keyword if ${index} == 0 Set NetFn Byte ${word}
55 \ Run Keyword if ${index} == 1 Set Cmd Byte ${word}
56 \ Run Keyword if ${index} > 1 Set Array Byte ${word}
57 \ ${index} = Set Variable ${index + 1}
58 ${length} = Get Length ${arrayByte}
59 ${length} = Evaluate ${length} - 1
60 ${arrayByteLocal} = Get Substring ${arrayByte} 0 ${length}
61 Set Global Variable ${arrayByte} ${arrayByteLocal}
62 ${valueinBytesWithArray} = Catenate byte:0x00 ${netfnByte} byte:0x00
63 ${valueinBytesWithArray} = Catenate ${valueinBytesWithArray} ${cmdByte}
64 ${valueinBytesWithArray} = Catenate ${valueinBytesWithArray} ${arrayByte}
65 ${valueinBytesWithoutArray} = Catenate byte:0x00 ${netfnByte} byte:0x00
66 ${valueinBytesWithoutArray} = Catenate ${valueinBytesWithoutArray} ${cmdByte}
67# To Check scenario for smaller IPMI raw commands with only 2 arguments
68# instead of usual 12 arguments.
69# Sample small IPMI raw command: Run IPMI command 0x06 0x36
70# If IPMI raw argument length is only 9 then return value in bytes without
71# array population.
72# Equivalent dbus-send argument for smaller IPMI raw command:
73# byte:0x00 byte:0x06 byte:0x00 byte:0x36
74 Run Keyword if ${argLength} == 9 Return from Keyword ${valueinBytesWithoutArray}
75 [return] ${valueinBytesWithArray}
76
77
78Set NetFn Byte
79 [arguments] ${word}
80 ${netfnByteLocal} = Catenate byte:${word}
81 Set Global Variable ${netfnByte} ${netfnByteLocal}
82
83Set Cmd Byte
84 [arguments] ${word}
85 ${cmdByteLocal} = Catenate byte:${word}
86 Set Global Variable ${cmdByte} ${cmdByteLocal}
87
88Set Array Byte
89 [arguments] ${word}
90 ${arrayByteLocal} = Catenate SEPARATOR= ${arrayByte} ${word}
91 ${arrayByteLocal} = Catenate SEPARATOR= ${arrayByteLocal} ,
92 Set Global Variable ${arrayByte} ${arrayByteLocal}
93
Chris Austenb29d2e82016-06-07 12:25:35 -050094Copy ipmitool
95 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.
96
97 Import Library SCPLibrary WITH NAME scp
98 scp.Open connection ${OPENBMC_HOST} username=${OPENBMC_USERNAME} password=${OPENBMC_PASSWORD}
99 scp.Put File tools/ipmitool /tmp
100 SSHLibrary.Open Connection ${OPENBMC_HOST}
101 Login ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD}
102 Execute Command chmod +x /tmp/ipmitool