1*** Settings ***
2
3Documentation    Module to test IPMI asset tag functionality.
4Resource         ../lib/ipmi_client.robot
5Resource         ../lib/openbmc_ffdc.robot
6Resource         ../lib/bmc_network_utils.robot
7Variables        ../data/ipmi_raw_cmd_table.py
8Variables        ../data/ipmi_variable.py
9Library          ../lib/bmc_network_utils.py
10Library          ../lib/ipmi_utils.py
11
12Suite Setup      IPMI General Test Suite Setup
13Test Teardown    FFDC On Test Case Fail
14
15Force Tags       IPMI_General
16
17*** Test Cases ***
18
19Test Get Self Test Results via IPMI Raw Command
20    [Documentation]  Get self test results via IPMI raw command and verify the output.
21    [Tags]  Test_Get_Self_Test_Results_via_IPMI_Raw_Command
22
23    ${resp}=  Run IPMI Standard Command  raw ${IPMI_RAW_CMD['Self_Test_Results']['Get'][0]}
24
25    # 55h = No error. All Self Tests Passed.
26    # 56h = Self Test function not implemented in this controller.
27    Should Contain Any  ${resp}  55 00  56 00
28
29
30Test Get Device GUID Via IPMI Raw Command
31    [Documentation]  Get device GUID via IPMI raw command and verify it using Redfish.
32    [Tags]  Test_Get_Device_GUID_Via_IPMI_Raw_Command
33    [Teardown]  Run Keywords  Redfish.Logout  AND  FFDC On Test Case Fail
34    # Get GUIDS via IPMI.
35    # This should match the /redfish/v1/Managers/${MANAGER_ID}'s UUID data.
36    ${guids}=  Run IPMI Standard Command  raw ${IPMI_RAW_CMD['Device GUID']['Get'][0]}
37    # Reverse the order and remove space delims.
38    ${guids}=  Split String  ${guids}
39    Reverse List  ${guids}
40    ${guids}=  Evaluate  "".join(${guids})
41
42    Redfish.Login
43    ${uuid}=  Redfish.Get Attribute  /redfish/v1/Managers/${MANAGER_ID}  UUID
44    ${uuid}=  Remove String  ${uuid}  -
45
46    Rprint Vars  guids  uuid
47    Valid Value  uuid  ['${guids}']
48
49
50Verify Get Channel Info via IPMI
51    [Documentation]  Verify get channel info via IPMI.
52    [Tags]  Verify_Get_Channel_Info_via_IPMI
53
54    # Get channel info via ipmi command "ipmitool channel info [channel number]".
55    # Verify channel info with files "channel_access_volatile.json", "channel_access_nv.json"
56    # and "channel_config.json" in BMC.
57
58    # Example output from 'Get Channel Info':
59    # channel_info:
60    #   [channel_0x2_info]:
61    #     [channel_medium_type]:                        802.3 LAN
62    #     [channel_protocol_type]:                      IPMB-1.0
63    #     [session_support]:                            multi-session
64    #     [active_session_count]:                       0
65    #     [protocol_vendor_id]:                         7154
66    #   [volatile(active)_settings]:
67    #       [alerting]:                                 enabled
68    #       [per-message_auth]:                         enabled
69    #       [user_level_auth]:                          enabled
70    #       [access_mode]:                              always available
71    #   [Non-Volatile Settings]:
72    #       [alerting]:                                 enabled
73    #       [per-message_auth]:                         enabled
74    #       [user_level_auth]:                          enabled
75    #       [access_mode]:                              always available
76
77    ${channel_info_ipmi}=  Get Channel Info  ${CHANNEL_NUMBER}
78    ${active_channel_config}=  Get Active Channel Config
79    ${channel_volatile_data_config}=  Get Channel Access Config  /run/ipmi/channel_access_volatile.json
80    ${channel_nv_data_config}=  Get Channel Access Config  /var/lib/ipmi/channel_access_nv.json
81
82    Rprint Vars  channel_info_ipmi
83    Rprint Vars  active_channel_config
84    Rprint Vars  channel_volatile_data_config
85    Rprint Vars  channel_nv_data_config
86
87    Valid Value  medium_type_ipmi_conf_map['${channel_info_ipmi['channel_0x${CHANNEL_NUMBER}_info']['channel_medium_type']}']
88    ...  ['${active_channel_config['${CHANNEL_NUMBER}']['channel_info']['medium_type']}']
89
90    Valid Value  protocol_type_ipmi_conf_map['${channel_info_ipmi['channel_0x${CHANNEL_NUMBER}_info']['channel_protocol_type']}']
91    ...  ['${active_channel_config['${CHANNEL_NUMBER}']['channel_info']['protocol_type']}']
92
93    Valid Value  channel_info_ipmi['channel_0x${CHANNEL_NUMBER}_info']['session_support']
94    ...  ['${active_channel_config['${CHANNEL_NUMBER}']['channel_info']['session_supported']}']
95
96    Valid Value  channel_info_ipmi['channel_0x${CHANNEL_NUMBER}_info']['active_session_count']
97    ...  ['${active_channel_config['${CHANNEL_NUMBER}']['active_sessions']}']
98    # IPMI Spec: The IPMI Enterprise Number is: 7154 (decimal)
99    Valid Value  channel_info_ipmi['channel_0x${CHANNEL_NUMBER}_info']['protocol_vendor_id']  ['7154']
100
101    # Verify volatile(active)_settings
102    Valid Value  disabled_ipmi_conf_map['${channel_info_ipmi['volatile(active)_settings']['alerting']}']
103    ...  ['${channel_volatile_data_config['${CHANNEL_NUMBER}']['alerting_disabled']}']
104
105    Valid Value  disabled_ipmi_conf_map['${channel_info_ipmi['volatile(active)_settings']['per-message_auth']}']
106    ...  ['${channel_volatile_data_config['${CHANNEL_NUMBER}']['per_msg_auth_disabled']}']
107
108    Valid Value  disabled_ipmi_conf_map['${channel_info_ipmi['volatile(active)_settings']['user_level_auth']}']
109    ...  ['${channel_volatile_data_config['${CHANNEL_NUMBER}']['user_auth_disabled']}']
110
111    Valid Value  access_mode_ipmi_conf_map['${channel_info_ipmi['volatile(active)_settings']['access_mode']}']
112    ...  ['${channel_volatile_data_config['${CHANNEL_NUMBER}']['access_mode']}']
113
114    # Verify Non-Volatile Settings
115    Valid Value  disabled_ipmi_conf_map['${channel_info_ipmi['non-volatile_settings']['alerting']}']
116    ...  ['${channel_nv_data_config['${CHANNEL_NUMBER}']['alerting_disabled']}']
117
118    Valid Value  disabled_ipmi_conf_map['${channel_info_ipmi['non-volatile_settings']['per-message_auth']}']
119    ...  ['${channel_nv_data_config['${CHANNEL_NUMBER}']['per_msg_auth_disabled']}']
120
121    Valid Value  disabled_ipmi_conf_map['${channel_info_ipmi['non-volatile_settings']['user_level_auth']}']
122    ...  ['${channel_nv_data_config['${CHANNEL_NUMBER}']['user_auth_disabled']}']
123
124    Valid Value  access_mode_ipmi_conf_map['${channel_info_ipmi['non-volatile_settings']['access_mode']}']
125    ...  ['${channel_nv_data_config['${CHANNEL_NUMBER}']['access_mode']}']
126
127
128Test Get Channel Authentication Capabilities via IPMI
129    [Documentation]  Verify channel authentication capabilities via IPMI.
130    [Tags]  Test_Get_Channel_Authentication_Capabilities_via_IPMI
131    [Template]  Verify Channel Auth Capabilities
132
133    FOR  ${channel}  IN   @{active_channel_list}
134        FOR  ${privilege}  IN   4  3  2
135            # Input Channel     Privilege Level
136            ${channel}          ${privilege}
137        END
138    END
139
140
141Test Get Channel Authentication Capabilities IPMI Command For Invalid Channel
142    [Documentation]  Verify get channel authentication capabilities for invalid channel.
143    [Tags]  Test_Get_Channel_Authentication_Capabilities_IPMI_Command_For_Invalid_Channel
144    [Template]  Verify Channel Auth Capabilities For Invalid Channel
145
146    FOR  ${channel}  IN  @{inactive_channel_list}
147        # Input Channel
148        ${channel}
149    END
150
151
152Verify Get Channel Authentication Capabilities IPMI Raw Command With Invalid Data Length
153    [Documentation]  Verify get channel authentication capabilities IPMI raw command with invalid data length.
154    [Tags]  Verify_Get_Channel_Authentication_Capabilities_IPMI_Raw_Command_With_Invalid_Data_Length
155    [Template]  Verify Channel Auth Command For Invalid Data Length
156
157    # Bytes
158    low
159    high
160
161
162Verify Set Session Privilege Level via IPMI Raw Command
163    [Documentation]  Set session privilege with given privilege level and verify the response with
164    ...              expected level.
165    [Tags]  Verify_Set_Session_Privilege_Level_via_IPMI_Raw_Command
166    [Template]  Set Session Privilege Level And Verify
167
168    # privilege_level   expected_level
169    0x00                04
170    0x02                02
171    0x03                03
172    0x04                04
173
174
175Verify Set Invalid Session Privilege Level Via IPMI Raw Command
176    [Documentation]  Verify set invalid session privilege level via IPMI raw command.
177    [Tags]  Verify_Set_Invalid_Session_Privilege_Level_Via_IPMI_Raw_Command
178    [Template]  Set Invalid Session Privilege Level And Verify
179
180    # invalid_privilege_level
181    0x01
182    0x05
183    0x06
184    0x07
185    0x0F
186
187
188Verify Close Session Via IPMI
189    [Documentation]  Verify close session via IPMI.
190    [Tags]  Verify_Close_Session_Via_IPMI
191
192    # The "close session command" can be tested with any out-of-band IPMI command.
193    # When the session is about to close, it will execute the close session command at the end.
194
195    ${cmd}=  Catenate  mc info -vvv 2>&1 | grep "Closed Session"
196    ${cmd_output}=  Run External IPMI Standard Command  ${cmd}
197
198    Should Contain  ${cmd_output}  Closed Session
199
200
201Verify Chassis Identify via IPMI
202    [Documentation]  Set chassis identify using IPMI and verify.
203    [Tags]  Verify_Chassis_Identify_via_IPMI
204    [Setup]  Redfish.Login
205    [Teardown]  Redfish.logout
206
207    # Set to default "chassis identify" and verify that LED blinks for 15s.
208    Run IPMI Standard Command  chassis identify
209    Verify Identify LED State Via Redfish  Lit
210
211    Sleep  18s
212    Verify Identify LED State Via Redfish  Off
213
214    # Set "chassis identify" to 10s and verify that the LED blinks for 10s.
215    Run IPMI Standard Command  chassis identify 10
216    Verify Identify LED State Via Redfish  Lit
217
218    Sleep  12s
219    Verify Identify LED State Via Redfish  Off
220
221
222Verify Chassis Identify Off And Force Identify On via IPMI
223    [Documentation]  Set chassis identify to "off" and "force" using IPMI and verify.
224    [Tags]  Verify_Chassis_Identify_Off_And_Force_Identify_On_via_IPMI
225    [Setup]  Redfish.Login
226    [Teardown]  Redfish.logout
227
228    # Set the LED to "Force Identify On".
229    Run IPMI Standard Command  chassis identify force
230    Verify Identify LED State Via Redfish  Lit
231
232    # Set "chassis identify" to 0 and verify that the LED turns off.
233    Run IPMI Standard Command  chassis identify 0
234    Verify Identify LED State Via Redfish  Off
235
236
237*** Keywords ***
238
239IPMI General Test Suite Setup
240    [Documentation]  Get active and inactive/invalid channels from channel_config.json file
241    ...              in list type and set it as suite variable.
242
243    # Get active channel list and set as suite variable.
244    @{active_channel_list}=  Get Active Ethernet Channel List
245    Set Suite Variable  @{active_channel_list}
246
247    # Get Inactive/Invalid channel list and set as suite variable.
248    @{inactive_channel_list}=  Get Invalid Channel Number List
249    Set Suite Variable  @{inactive_channel_list}
250
251
252Set Session Privilege Level And Verify
253    [Documentation]   Set session privilege with given privilege level and verify the response with
254    ...               expected level.
255    [Arguments]  ${privilege_level}  ${expected_level}
256    # Description of argument(s):
257    # privilege_level    Requested Privilege Level.
258    # expected_level     New Privilege Level (or present level if ‘return present privilege level’
259    #                    was selected).
260
261    ${resp}=  Run External IPMI Raw Command
262    ...  0x06 0x3b ${privilege_level}
263    Should Contain  ${resp}  ${expected_level}
264
265
266Set Invalid Session Privilege Level And Verify
267    [Documentation]   Set invalid session privilege level and verify the response.
268    [Arguments]  ${privilege_level}
269    # Description of argument(s):
270    # privilege_level    Requested Privilege Level.
271
272    # Verify requested level exceeds Channel and/or User Privilege Limit.
273    ${msg}=  Run Keyword And Expect Error  *  Run External IPMI Raw Command
274    ...  0x06 0x3b ${privilege_level}
275
276    # 0x05 is OEM proprietary level.
277    IF  ${privilege_level} == 0x05
278        Should Contain  ${msg}  Unknown  rsp=0x81
279    ELSE
280        # According to IPMI spec privilege level except 0x00-0x05, others are
281        # reserved. So if we try to set those privilege we will get rsp as
282        # 0xcc(Invalid data filed in request)
283        Should Contain  ${msg}  Invalid data field in request  rsp=0xcc
284    END
285
286
287Verify Identify LED State Via Redfish
288    [Documentation]  Verify that Redfish identify LED system with given state.
289    [Arguments]  ${expected_state}
290    # Description of argument(s):
291    # expected_led_status  Expected value of Identify LED.
292
293    # Get the following URI(s) and iterate to find the attribute IndicatorLED.
294    # Example:
295    # /redfish/v1/Systems/system
296    # /redfish/v1/Systems/hypervisor
297
298    # Python module:  get_member_list(resource_path)
299    ${systems}=  Redfish_Utils.Get Member List  /redfish/v1/Systems
300    FOR  ${system}  IN  @{systems}
301        ${led_value}=  Redfish.Get Attribute  ${system}  IndicatorLED
302        # Get attribute return None if IndicatorLED does not exist in the URI.
303        Continue For Loop If  '${led_value}' == 'None'
304        Should Be True  '${led_value}' == '${expected_state}'
305    END
306
307
308Verify Channel Auth Capabilities
309    [Documentation]  Verify authentication capabilities for given channel and privilege.
310    [Arguments]  ${channel}  ${privilege_level}
311
312    # Description of argument(s):
313    # channel           Interface channel number.
314    # privilege_level   User Privilege level (e.g. 4-Administator, 3-Operator, 2-Readonly).
315
316    # Python module:  get_channel_auth_capabilities(channel_number, privilege_level)
317    ${channel_auth_cap}=  Get Channel Auth Capabilities  ${channel}  ${privilege_level}
318    Rprint Vars  channel_auth_cap
319
320    Valid Value  channel_auth_cap['channel_number']  ['${channel}']
321    Valid Value  channel_auth_cap['kg_status']  ['default (all zeroes)']
322    Valid Value  channel_auth_cap['per_message_authentication']  ['enabled']
323    Valid Value  channel_auth_cap['user_level_authentication']  ['enabled']
324    Valid Value  channel_auth_cap['non-null_user_names_exist']  ['yes']
325    Valid Value  channel_auth_cap['null_user_names_exist']  ['no']
326    Valid Value  channel_auth_cap['anonymous_login_enabled']  ['no']
327    Valid Value  channel_auth_cap['channel_supports_ipmi_v1.5']  ['no']
328    Valid Value  channel_auth_cap['channel_supports_ipmi_v2.0']  ['yes']
329
330
331Verify Channel Auth Capabilities For Invalid Channel
332    [Documentation]  Verify authentication capabilities of invalid channels.
333    [Arguments]  ${channel}
334
335    # Description of argument(s):
336    # channel   Interface channel number.
337
338    ${channel_in_hex}=  Convert To Hex  ${channel}  prefix=0x
339    ${cmd}=  Catenate  ${IPMI_RAW_CMD['Get Channel Auth Cap']['get'][0]} ${channel_in_hex} 0x04
340
341    Verify Invalid IPMI Command  ${cmd}  0xcc
342
343
344Verify Channel Auth Command For Invalid Data Length
345   [Documentation]  Verify channel authentication command for invalid data length.
346   [Arguments]  ${byte_length}
347
348   # Description of argument(s):
349   # byte_length   high or low.
350   #               e.g. high - add extra byte to request data like "0x06 0x38 0x01 0x04 0x01".
351   #               low - reduce bytes in actual request data like "0x06 0x38".
352
353   ${req_cmd}=  Run Keyword If  '${byte_length}' == 'low'
354   ...  Catenate  ${IPMI_RAW_CMD['Get Channel Auth Cap']['get'][0]}  ${CHANNEL_NUMBER}
355   ...  ELSE
356   ...  Catenate  ${IPMI_RAW_CMD['Get Channel Auth Cap']['get'][0]}  ${CHANNEL_NUMBER} 0x04 0x01
357
358   Verify Invalid IPMI Command  ${req_cmd}  0xc7
359