xref: /openbmc/openbmc-test-automation/lib/bmc_redfish_utils.robot (revision f9babff8d4d88bf1ffd052dc2e60fe728c95f35b)
10047de86SSridevi Ramesh*** Settings ***
2b10eacafSGeorge KeishingDocumentation   BMC and host redfish utility keywords.
30047de86SSridevi Ramesh
42db7bcaeSGeorge KeishingResource        resource.robot
50047de86SSridevi RameshResource        bmc_redfish_resource.robot
60047de86SSridevi Ramesh
70047de86SSridevi Ramesh
80047de86SSridevi Ramesh*** Keywords ***
90047de86SSridevi Ramesh
100047de86SSridevi RameshRedfish Power Operation
11b10eacafSGeorge Keishing    [Documentation]  Do Redfish host power operation.
120047de86SSridevi Ramesh    [Arguments]      ${reset_type}
13b910d89bSSushil Singh
140047de86SSridevi Ramesh    # Description of arguments:
150047de86SSridevi Ramesh    # reset_type     Type of power operation.
160047de86SSridevi Ramesh    #                (e.g. On/ForceOff/GracefulRestart/GracefulShutdown)
170047de86SSridevi Ramesh
180047de86SSridevi Ramesh    # Example:
190047de86SSridevi Ramesh    # "Actions": {
200047de86SSridevi Ramesh    # "#ComputerSystem.Reset": {
210047de86SSridevi Ramesh    #  "ResetType@Redfish.AllowableValues": [
220047de86SSridevi Ramesh    #    "On",
230047de86SSridevi Ramesh    #    "ForceOff",
24eeb526ceSGeorge Keishing    #    "ForceOn",
25eeb526ceSGeorge Keishing    #    "ForceRestart",
260047de86SSridevi Ramesh    #    "GracefulRestart",
270047de86SSridevi Ramesh    #    "GracefulShutdown"
28eeb526ceSGeorge Keishing    #    "PowerCycle",
29eeb526ceSGeorge Keishing    #    "Nmi"
300047de86SSridevi Ramesh    #  ],
312deec3cfSGeorge Keishing    #  "target": "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset"
322deec3cfSGeorge Keishing    #  }
332deec3cfSGeorge Keishing    # }
340047de86SSridevi Ramesh
35c2b176e2SGeorge Keishing    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/system/  ComputerSystem.Reset
360047de86SSridevi Ramesh    ${payload}=  Create Dictionary  ResetType=${reset_type}
37213feb34SMichael Walsh    ${resp}=  Redfish.Post  ${target}  body=&{payload}
380047de86SSridevi Ramesh
390047de86SSridevi Ramesh
40b10eacafSGeorge KeishingRedfish BMC Reset Operation
41b10eacafSGeorge Keishing    [Documentation]  Do Redfish BMC reset operation.
42b910d89bSSushil Singh    [Arguments]  ${reset_type}=GracefulRestart
430047de86SSridevi Ramesh
44b10eacafSGeorge Keishing    # Example:
45b10eacafSGeorge Keishing    # "Actions": {
46b10eacafSGeorge Keishing    # "#Manager.Reset": {
47b10eacafSGeorge Keishing    #  "ResetType@Redfish.AllowableValues": [
48b910d89bSSushil Singh    #    "GracefulRestart",
49b910d89bSSushil Singh    #    "ForceRestart"
50b10eacafSGeorge Keishing    #  ],
514d430283Sganesanb    #  "target": "/redfish/v1/Managers/${MANAGER_ID}/Actions/Manager.Reset"
52b10eacafSGeorge Keishing    # }
53b10eacafSGeorge Keishing
544d430283Sganesanb    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Managers/${MANAGER_ID}/  Manager.Reset
55b910d89bSSushil Singh    ${payload}=  Create Dictionary  ResetType=${reset_type}
5607fb41f7SGeorge Keishing    Redfish.Post  ${target}  body=&{payload}
57caa718bfSGeorge Keishing
58caa718bfSGeorge Keishing
590296f1d2SAnvesh Kumar RayankulaReset BIOS Via Redfish
600296f1d2SAnvesh Kumar Rayankula    [Documentation]  Do BIOS reset through Redfish.
610296f1d2SAnvesh Kumar Rayankula
620296f1d2SAnvesh Kumar Rayankula    ${target}=  redfish_utils.Get Target Actions  /redfish/v1/Systems/system/Bios/  Bios.ResetBios
630296f1d2SAnvesh Kumar Rayankula    Redfish.Post  ${target}  valid_status_codes=[${HTTP_OK}]
640296f1d2SAnvesh Kumar Rayankula
650296f1d2SAnvesh Kumar Rayankula
6687e984c8SSushil SinghRedfish Delete Session
6787e984c8SSushil Singh    [Documentation]  Redfish delete session.
6887e984c8SSushil Singh    [Arguments]  ${session_info}
6987e984c8SSushil Singh
7087e984c8SSushil Singh    # Description of argument(s):
7187e984c8SSushil Singh    # session_info      Session information are stored in dictionary.
7287e984c8SSushil Singh
7387e984c8SSushil Singh    # ${session_info} = {
7487e984c8SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
7587e984c8SSushil Singh    #     'ClientID': 'XXXXXX',
7687e984c8SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
7787e984c8SSushil Singh    #     'SessionResp': session response from redfish login
7887e984c8SSushil Singh    # }
7987e984c8SSushil Singh
8087e984c8SSushil Singh    # SessionIDs   : Session IDs
8187e984c8SSushil Singh    # ClientID     : Client ID
8287e984c8SSushil Singh    # SessionToken : Session token
8387e984c8SSushil Singh    # SessionResp  : Response of creating an redfish login session
8487e984c8SSushil Singh
8587e984c8SSushil Singh    Redfish.Delete  /redfish/v1/SessionService/Sessions/${session_info["SessionIDs"]}
8687e984c8SSushil Singh
8787e984c8SSushil Singh
8887e984c8SSushil SinghRedfish Delete List Of Session
8987e984c8SSushil Singh    [Documentation]  Redfish delete session from list of session records, individual session information
9087e984c8SSushil Singh    ...              are stored in dictionary.
9187e984c8SSushil Singh    [Arguments]  ${session_info_list}
9287e984c8SSushil Singh
9387e984c8SSushil Singh    # Description of argument(s):
9487e984c8SSushil Singh    # session_info_list    List contains individual session record are stored in dictionary.
9587e984c8SSushil Singh
9687e984c8SSushil Singh    # ${session_info_list} = [{
9787e984c8SSushil Singh    #     'SessionIDs': 'XXXXXXXXX',
9887e984c8SSushil Singh    #     'ClientID': 'XXXXXX',
9987e984c8SSushil Singh    #     'SessionToken': 'XXXXXXXXX',
10087e984c8SSushil Singh    #     'SessionResp': session response from redfish login
10187e984c8SSushil Singh    # }]
10287e984c8SSushil Singh
10387e984c8SSushil Singh    # SessionIDs   : Session IDs
10487e984c8SSushil Singh    # ClientID     : Client ID
10587e984c8SSushil Singh    # SessionToken : Session token
10687e984c8SSushil Singh    # SessionResp  : Response of creating an redfish login session
10787e984c8SSushil Singh
10887e984c8SSushil Singh    FOR  ${session_record}  IN  @{session_info_list}
10987e984c8SSushil Singh      Redfish.Delete  /redfish/v1/SessionService/Sessions/${session_record["SessionIDs"]}
11087e984c8SSushil Singh    END
11187e984c8SSushil Singh
11287e984c8SSushil Singh
113caa718bfSGeorge KeishingDelete All Redfish Sessions
114caa718bfSGeorge Keishing    [Documentation]  Delete all active redfish sessions.
115caa718bfSGeorge Keishing
116ed737653SSagar Anand    ${saved_session_info}=  Redfish_Utils.Get Redfish Session Info
117caa718bfSGeorge Keishing
118caa718bfSGeorge Keishing    ${resp_list}=  Redfish_Utils.Get Member List
119caa718bfSGeorge Keishing    ...  /redfish/v1/SessionService/Sessions
120caa718bfSGeorge Keishing
121caa718bfSGeorge Keishing    # Remove the current login session from the list.
122caa718bfSGeorge Keishing    Remove Values From List  ${resp_list}  ${saved_session_info["location"]}
123caa718bfSGeorge Keishing
1243612f3aaSGeorge Keishing    # Remove session with client_id populated from the list.
1253612f3aaSGeorge Keishing    ${client_id_list}=  Get Session With Client Id  ${resp_list}
1263612f3aaSGeorge Keishing    Log To Console  Client sessions skip list: ${client_id_list}
1273612f3aaSGeorge Keishing    FOR  ${client_session}  IN  @{client_id_list}
1283612f3aaSGeorge Keishing        Remove Values From List  ${resp_list}  ${client_session}
1293612f3aaSGeorge Keishing    END
1303612f3aaSGeorge Keishing
13120ccfc71SMarissa Garza    FOR  ${session}  IN  @{resp_list}
13274c1c856SGeorge Keishing        Run Keyword And Ignore Error  Redfish.Delete  ${session}
13320ccfc71SMarissa Garza    END
134cf163321SMichael Walsh
13587e984c8SSushil Singh
1363612f3aaSGeorge KeishingGet Session With Client Id
137*f9babff8SGeorge Keishing    [Documentation]  Iterate through the active sessions and return sessions
138*f9babff8SGeorge Keishing    ...              populated with Context.
1393612f3aaSGeorge Keishing    [Arguments]  ${session_list}
1403612f3aaSGeorge Keishing
1413612f3aaSGeorge Keishing    # Description of argument(s):
1423612f3aaSGeorge Keishing    # session_list   Active session list from SessionService.
1433612f3aaSGeorge Keishing
144*f9babff8SGeorge Keishing    # "@odata.type": "#Session.v1_5_0.Session",
145*f9babff8SGeorge Keishing    # "ClientOriginIPAddress": "xx.xx.xx.xx",
146*f9babff8SGeorge Keishing    # "Context": "MYID-01"
1473612f3aaSGeorge Keishing
1483612f3aaSGeorge Keishing    ${client_id_sessions}=  Create List
1493612f3aaSGeorge Keishing    FOR  ${session}  IN  @{session_list}
1503612f3aaSGeorge Keishing        ${resp}=  Redfish.Get  ${session}   valid_status_codes=[200,404]
151*f9babff8SGeorge Keishing        # This prevents dictionary KeyError exception when the Context
152*f9babff8SGeorge Keishing        # attribute is not populated in generic session response.
153*f9babff8SGeorge Keishing        ${context_var}=  Get Variable Value  ${resp.dict["Context"]}  ${EMPTY}
154*f9babff8SGeorge Keishing        Run Keyword If  '${context_var}' != '${EMPTY}'
1553612f3aaSGeorge Keishing        ...    Append To List  ${client_id_sessions}  ${session}
1563612f3aaSGeorge Keishing    END
1573612f3aaSGeorge Keishing
1583612f3aaSGeorge Keishing    [Return]  ${client_id_sessions}
1593612f3aaSGeorge Keishing
1603612f3aaSGeorge Keishing
161cf163321SMichael WalshGet Valid FRUs
162cf163321SMichael Walsh    [Documentation]  Return a dictionary containing all of the valid FRU records for the given fru_type.
163cf163321SMichael Walsh    [Arguments]  ${fru_type}
164cf163321SMichael Walsh
165cf163321SMichael Walsh    # NOTE: A valid FRU record will have a "State" key of "Enabled" and a "Health" key of "OK".
166cf163321SMichael Walsh
167cf163321SMichael Walsh    # Description of argument(s):
168cf163321SMichael Walsh    # fru_type  The type of fru (e.g. "Processors", "Memory", etc.).
169cf163321SMichael Walsh
170cf163321SMichael Walsh    ${fru_records}=  Redfish_Utils.Enumerate Request
171cf163321SMichael Walsh    ...  /redfish/v1/Systems/system/${fru_type}  return_json=0
172e256a4f6SMichael Walsh    ${fru_records}=  Filter Struct  ${fru_records}  [('State', 'Enabled'), ('Health', 'OK')]
173cf163321SMichael Walsh
174cf163321SMichael Walsh    [Return]  ${fru_records}
175cf163321SMichael Walsh
176cf163321SMichael Walsh
177cf163321SMichael WalshGet Num Valid FRUs
178cf163321SMichael Walsh    [Documentation]  Return the number of valid FRU records for the given fru_type.
179cf163321SMichael Walsh    [Arguments]  ${fru_type}
180cf163321SMichael Walsh
181cf163321SMichael Walsh    # Description of argument(s):
182cf163321SMichael Walsh    # fru_type  The type of fru (e.g. "Processors", "Memory", etc.).
183cf163321SMichael Walsh
184cf163321SMichael Walsh    ${fru_records}=  Get Valid FRUs  ${fru_type}
185cf163321SMichael Walsh    ${num_valid_frus}=  Get length  ${fru_records}
186cf163321SMichael Walsh
187cf163321SMichael Walsh    [Return]  ${num_valid_frus}
188d76b1423SMarissa Garza
189d76b1423SMarissa Garza
190d76b1423SMarissa GarzaVerify Valid Records
191d76b1423SMarissa Garza    [Documentation]  Verify all records retrieved with the given arguments are valid.
192d76b1423SMarissa Garza    [Arguments]  ${record_type}  ${redfish_uri}  ${reading_type}
193d76b1423SMarissa Garza
194d76b1423SMarissa Garza    # Description of Argument(s):
195d76b1423SMarissa Garza    # record_type    The sensor record type (e.g. "PowerSupplies")
196d76b1423SMarissa Garza    # redfish_uri    The power supply URI (e.g. /redfish/v1/Chassis/chassis/Power)
197d76b1423SMarissa Garza    # reading_type   The power watt readings (e.g. "PowerInputWatts")
198d76b1423SMarissa Garza
199d76b1423SMarissa Garza    # A valid record will have "State" key "Enabled" and "Health" key "OK".
200d76b1423SMarissa Garza    ${records}=  Redfish.Get Attribute  ${redfish_uri}  ${record_type}
201d76b1423SMarissa Garza
202d76b1423SMarissa Garza    Rprint Vars  records
203d76b1423SMarissa Garza
204d76b1423SMarissa Garza    # Example output:
205d76b1423SMarissa Garza    # records:
206d76b1423SMarissa Garza    #   [0]:
207d76b1423SMarissa Garza    #     [@odata.id]:                 /redfish/v1/Chassis/chassis/Power#/PowerControl/0
208d76b1423SMarissa Garza    #     [@odata.type]:               #Power.v1_0_0.PowerControl
209d76b1423SMarissa Garza    #     [MemberId]:                  0
210d76b1423SMarissa Garza    #     [Name]:                      Chassis Power Control
211d76b1423SMarissa Garza    #     [PowerConsumedWatts]:        264.0
212d76b1423SMarissa Garza    #     [PowerLimit]:
213d76b1423SMarissa Garza    #       [LimitInWatts]:            None
214d76b1423SMarissa Garza    #     [PowerMetrics]:
215d76b1423SMarissa Garza    #       [AverageConsumedWatts]:    325
216d76b1423SMarissa Garza    #       [IntervalInMin]:           3
217d76b1423SMarissa Garza    #       [MaxConsumedWatts]:        538
218d76b1423SMarissa Garza    #     [Status]:
219d76b1423SMarissa Garza    #       [Health]:                  OK
220d76b1423SMarissa Garza    #       [State]:                   Enabled
221d76b1423SMarissa Garza
222d76b1423SMarissa Garza    ${invalid_records}=  Filter Struct  ${records}
223d76b1423SMarissa Garza    ...  [('Health', '^OK$'), ('State', '^Enabled$'), ('${reading_type}', '')]  regex=1  invert=1
224d76b1423SMarissa Garza    Valid Length  invalid_records  max_length=0
225fdee1b05SMarissa Garza
226fdee1b05SMarissa Garza    [Return]  ${records}
227ff2c0bc4SVijay
228ff2c0bc4SVijay
229ff2c0bc4SVijayRedfish Create User
230ff2c0bc4SVijay    [Documentation]  Redfish create user.
231ff2c0bc4SVijay    [Arguments]   ${user_name}  ${password}  ${role_id}  ${enabled}  ${force}=${False}
232ff2c0bc4SVijay
233ff2c0bc4SVijay    # Description of argument(s):
234ff2c0bc4SVijay    # user_name           The user name to be created.
235ff2c0bc4SVijay    # password            The password to be assigned.
236ff2c0bc4SVijay    # role_id             The role ID of the user to be created.
237ff2c0bc4SVijay    #                     (e.g. "Administrator", "Operator", etc.).
238ff2c0bc4SVijay    # enabled             Indicates whether the username being created.
239ff2c0bc4SVijay    #                     should be enabled (${True}, ${False}).
240ff2c0bc4SVijay    # force               Delete user account and re-create if force is True.
241ff2c0bc4SVijay
242ff2c0bc4SVijay    ${curr_role}=  Run Keyword And Ignore Error  Get User Role  ${user_name}
243ff2c0bc4SVijay    # Ex: ${curr_role} = ('PASS', 'Administrator')
244ff2c0bc4SVijay
245ff2c0bc4SVijay    ${user_exists}=  Run Keyword And Return Status  Should Be Equal As Strings  ${curr_role}[0]  PASS
246ff2c0bc4SVijay
247ff2c0bc4SVijay    # Delete user account when force is True.
248ff2c0bc4SVijay    Run Keyword If  ${force} == ${True}  Redfish.Delete  ${REDFISH_ACCOUNTS_URI}${user_name}
249ff2c0bc4SVijay    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
250ff2c0bc4SVijay
251ff2c0bc4SVijay    # Create specified user when force is True or User does not exist.
252ff2c0bc4SVijay    ${payload}=  Create Dictionary
253ff2c0bc4SVijay    ...  UserName=${user_name}  Password=${password}  RoleId=${role_id}  Enabled=${enabled}
254ff2c0bc4SVijay
255ff2c0bc4SVijay    Run Keyword If  ${force} == ${True} or ${user_exists} == ${False}
256ff2c0bc4SVijay    ...  Redfish.Post  ${REDFISH_ACCOUNTS_URI}  body=&{payload}
257ff2c0bc4SVijay    ...  valid_status_codes=[${HTTP_CREATED}]
258ff2c0bc4SVijay
259ff2c0bc4SVijay
260ff2c0bc4SVijayGet User Role
261ff2c0bc4SVijay    [Documentation]  Get User Role.
262ff2c0bc4SVijay    [Arguments]  ${user_name}
263ff2c0bc4SVijay
264ff2c0bc4SVijay    # Description of argument(s):
265ff2c0bc4SVijay    # user_name    User name to get it's role.
266ff2c0bc4SVijay
267ff2c0bc4SVijay    ${role_config}=  Redfish_Utils.Get Attribute
268ff2c0bc4SVijay    ...  ${REDFISH_ACCOUNTS_URI}${user_name}  RoleId
269ff2c0bc4SVijay
270ff2c0bc4SVijay    [Return]  ${role_config}
271ff2c0bc4SVijay
272ff2c0bc4SVijay
273ff2c0bc4SVijayCreate Users With Different Roles
274ff2c0bc4SVijay    [Documentation]  Create users with different roles.
275ff2c0bc4SVijay    [Arguments]  ${users}  ${force}=${False}
276ff2c0bc4SVijay
277ff2c0bc4SVijay    # Description of argument(s):
278ff2c0bc4SVijay    # users    Dictionary of roles and user credentails to be created.
279ff2c0bc4SVijay    #          Ex:  {'Administrator': '[admin_user, TestPwd123]', 'Operator': '[operator_user, TestPwd123]'}
280ff2c0bc4SVijay    # force    Delete given user account if already exists when force is True.
281ff2c0bc4SVijay
282ff2c0bc4SVijay    FOR  ${role}  IN  @{users}
283ff2c0bc4SVijay      Redfish Create User  ${users['${role}'][0]}  ${users['${role}']}[1]  ${role}  ${True}  ${force}
284ff2c0bc4SVijay    END
285ff2c0bc4SVijay
28639373158SVijay
28739373158SVijayDelete BMC Users Via Redfish
28839373158SVijay    [Documentation]  Delete BMC users via redfish.
28939373158SVijay    [Arguments]  ${users}
29039373158SVijay
29139373158SVijay    # Description of argument(s):
29239373158SVijay    # users    Dictionary of roles and user credentials to be deleted.
29339373158SVijay
29439373158SVijay    FOR  ${role}  IN  @{users}
29539373158SVijay        Redfish.Delete  /redfish/v1/AccountService/Accounts/${users['${role}'][0]}
29639373158SVijay        ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}]
29739373158SVijay    END
29839373158SVijay
2997ed1ae88SAnves Kumar rayankula
3007ed1ae88SAnves Kumar rayankulaExpire And Update New Password Via Redfish
3017ed1ae88SAnves Kumar rayankula    [Documentation]  Expire and change password and verify using password.
3027ed1ae88SAnves Kumar rayankula    [Arguments]  ${username}  ${password}  ${new_password}
3037ed1ae88SAnves Kumar rayankula
3047ed1ae88SAnves Kumar rayankula    # Description of argument(s):
3057ed1ae88SAnves Kumar rayankula    # username        The username to be used to login to the BMC.
3067ed1ae88SAnves Kumar rayankula    # password        The password to be used to login to the BMC.
3077ed1ae88SAnves Kumar rayankula    # new_password    The new password to be used to update password.
3087ed1ae88SAnves Kumar rayankula
3097ed1ae88SAnves Kumar rayankula    # Expire admin password using ssh.
31039848ba6SSushil Singh    Open Connection And Log In  ${OPENBMC_USERNAME}  ${OPENBMC_PASSWORD}
3117ed1ae88SAnves Kumar rayankula    ${output}  ${stderr}  ${rc}=  BMC Execute Command  passwd --expire ${username}
31245aa881dSBrian Ma    Should Contain Any  ${output}  password expiry information changed
31345aa881dSBrian Ma    ...  password changed
3147ed1ae88SAnves Kumar rayankula
3157ed1ae88SAnves Kumar rayankula    # Verify user password expired using Redfish
3167ed1ae88SAnves Kumar rayankula    Verify User Password Expired Using Redfish  ${username}  ${password}
3177ed1ae88SAnves Kumar rayankula
3187ed1ae88SAnves Kumar rayankula    # Change user password.
31945aa881dSBrian Ma    Redfish.Patch  /redfish/v1/AccountService/Accounts/${username}
3207ed1ae88SAnves Kumar rayankula    ...  body={'Password': '${new_password}'}
3217ed1ae88SAnves Kumar rayankula    Redfish.Logout
3227ed1ae88SAnves Kumar rayankula
3237ed1ae88SAnves Kumar rayankula
3247ed1ae88SAnves Kumar rayankulaVerify User Password Expired Using Redfish
3257ed1ae88SAnves Kumar rayankula    [Documentation]  Checking whether user password expired or not using redfish.
326473cf7dcSSushil Singh    [Arguments]  ${username}  ${password}  ${expected_result}=${True}
3277ed1ae88SAnves Kumar rayankula
3287ed1ae88SAnves Kumar rayankula    # Description of argument(s):
3297ed1ae88SAnves Kumar rayankula    # username        The username to be used to login to the BMC.
3307ed1ae88SAnves Kumar rayankula    # password        The password to be used to login to the BMC.
3317ed1ae88SAnves Kumar rayankula
3327ed1ae88SAnves Kumar rayankula    Redfish.Login  ${username}  ${password}
3337ed1ae88SAnves Kumar rayankula    ${resp}=  Redfish.Get  /redfish/v1/AccountService/Accounts/${username}
3347ed1ae88SAnves Kumar rayankula    Should Be Equal  ${resp.dict["PasswordChangeRequired"]}  ${expected_result}
3357ed1ae88SAnves Kumar rayankula
336b3d1c7aaSPrashanth Katti
337b3d1c7aaSPrashanth KattiIs BMC LastResetTime Changed
338b3d1c7aaSPrashanth Katti    [Documentation]  Return fail if BMC last reset time is not changed.
339b3d1c7aaSPrashanth Katti    [Arguments]  ${reset_time}
340b3d1c7aaSPrashanth Katti
341b3d1c7aaSPrashanth Katti    # Description of argument(s):
342b3d1c7aaSPrashanth Katti    # reset_time  Last BMC reset time.
343b3d1c7aaSPrashanth Katti
344b3d1c7aaSPrashanth Katti    ${last_reset_time}=  Get BMC Last Reset Time
345b3d1c7aaSPrashanth Katti    Should Not Be Equal  ${last_reset_time}  ${reset_time}
346b3d1c7aaSPrashanth Katti
347b3d1c7aaSPrashanth Katti
348b3d1c7aaSPrashanth KattiRedfish BMC Reboot
349b3d1c7aaSPrashanth Katti    [Documentation]  Use Redfish API reboot BMC and wait for BMC ready.
350b3d1c7aaSPrashanth Katti
351b3d1c7aaSPrashanth Katti    #  Get BMC last reset time for compare
352b3d1c7aaSPrashanth Katti    ${last_reset_time}=  Get BMC Last Reset Time
353b3d1c7aaSPrashanth Katti
354b3d1c7aaSPrashanth Katti    # Reboot BMC by Redfish API
355b3d1c7aaSPrashanth Katti    Redfish BMC Reset Operation
356b3d1c7aaSPrashanth Katti
357b3d1c7aaSPrashanth Katti    # Wait for BMC real reboot and Redfish API ready
358b3d1c7aaSPrashanth Katti    Wait Until Keyword Succeeds  3 min  10 sec  Is BMC LastResetTime Changed  ${last_reset_time}
359b3d1c7aaSPrashanth Katti
360b3d1c7aaSPrashanth Katti
361b3d1c7aaSPrashanth KattiGet BMC Last Reset Time
362b3d1c7aaSPrashanth Katti    [Documentation]  Return BMC LastResetTime.
363b3d1c7aaSPrashanth Katti
3644d430283Sganesanb    ${last_reset_time}=  Redfish.Get Attribute  /redfish/v1/Managers/${MANAGER_ID}  LastResetTime
365b3d1c7aaSPrashanth Katti
366b3d1c7aaSPrashanth Katti    [Return]  ${last_reset_time}
367