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 # ], 51b10eacafSGeorge Keishing # "target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset" 52b10eacafSGeorge Keishing # } 53b10eacafSGeorge Keishing 54c2b176e2SGeorge Keishing ${target}= redfish_utils.Get Target Actions /redfish/v1/Managers/bmc/ 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 116*ed737653SSagar 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 1373612f3aaSGeorge Keishing [Documentation] Iterate through the active sessions and return sessions populated with client id. 1383612f3aaSGeorge Keishing [Arguments] ${session_list} 1393612f3aaSGeorge Keishing 1403612f3aaSGeorge Keishing # Description of argument(s): 1413612f3aaSGeorge Keishing # session_list Active session list from SessionService. 1423612f3aaSGeorge Keishing 1433612f3aaSGeorge Keishing # "Oem": { 1443612f3aaSGeorge Keishing # "OpenBMC": { 1453612f3aaSGeorge Keishing # "@odata.type": "#OemSession.v1_0_0.Session", 1463612f3aaSGeorge Keishing # "ClientID": "MYID=Vd57f62*2811504" 1473612f3aaSGeorge Keishing # } 1483612f3aaSGeorge Keishing 1493612f3aaSGeorge Keishing ${client_id_sessions}= Create List 1503612f3aaSGeorge Keishing FOR ${session} IN @{session_list} 1513612f3aaSGeorge Keishing ${resp}= Redfish.Get ${session} valid_status_codes=[200,404] 1523612f3aaSGeorge Keishing Run Keyword If '${resp.dict["Oem"]["OpenBMC"]["ClientID"]}' != '${EMPTY}' 1533612f3aaSGeorge Keishing ... Append To List ${client_id_sessions} ${session} 1543612f3aaSGeorge Keishing END 1553612f3aaSGeorge Keishing 1563612f3aaSGeorge Keishing [Return] ${client_id_sessions} 1573612f3aaSGeorge Keishing 1583612f3aaSGeorge Keishing 159cf163321SMichael WalshGet Valid FRUs 160cf163321SMichael Walsh [Documentation] Return a dictionary containing all of the valid FRU records for the given fru_type. 161cf163321SMichael Walsh [Arguments] ${fru_type} 162cf163321SMichael Walsh 163cf163321SMichael Walsh # NOTE: A valid FRU record will have a "State" key of "Enabled" and a "Health" key of "OK". 164cf163321SMichael Walsh 165cf163321SMichael Walsh # Description of argument(s): 166cf163321SMichael Walsh # fru_type The type of fru (e.g. "Processors", "Memory", etc.). 167cf163321SMichael Walsh 168cf163321SMichael Walsh ${fru_records}= Redfish_Utils.Enumerate Request 169cf163321SMichael Walsh ... /redfish/v1/Systems/system/${fru_type} return_json=0 170e256a4f6SMichael Walsh ${fru_records}= Filter Struct ${fru_records} [('State', 'Enabled'), ('Health', 'OK')] 171cf163321SMichael Walsh 172cf163321SMichael Walsh [Return] ${fru_records} 173cf163321SMichael Walsh 174cf163321SMichael Walsh 175cf163321SMichael WalshGet Num Valid FRUs 176cf163321SMichael Walsh [Documentation] Return the number of valid FRU records for the given fru_type. 177cf163321SMichael Walsh [Arguments] ${fru_type} 178cf163321SMichael Walsh 179cf163321SMichael Walsh # Description of argument(s): 180cf163321SMichael Walsh # fru_type The type of fru (e.g. "Processors", "Memory", etc.). 181cf163321SMichael Walsh 182cf163321SMichael Walsh ${fru_records}= Get Valid FRUs ${fru_type} 183cf163321SMichael Walsh ${num_valid_frus}= Get length ${fru_records} 184cf163321SMichael Walsh 185cf163321SMichael Walsh [Return] ${num_valid_frus} 186d76b1423SMarissa Garza 187d76b1423SMarissa Garza 188d76b1423SMarissa GarzaVerify Valid Records 189d76b1423SMarissa Garza [Documentation] Verify all records retrieved with the given arguments are valid. 190d76b1423SMarissa Garza [Arguments] ${record_type} ${redfish_uri} ${reading_type} 191d76b1423SMarissa Garza 192d76b1423SMarissa Garza # Description of Argument(s): 193d76b1423SMarissa Garza # record_type The sensor record type (e.g. "PowerSupplies") 194d76b1423SMarissa Garza # redfish_uri The power supply URI (e.g. /redfish/v1/Chassis/chassis/Power) 195d76b1423SMarissa Garza # reading_type The power watt readings (e.g. "PowerInputWatts") 196d76b1423SMarissa Garza 197d76b1423SMarissa Garza # A valid record will have "State" key "Enabled" and "Health" key "OK". 198d76b1423SMarissa Garza ${records}= Redfish.Get Attribute ${redfish_uri} ${record_type} 199d76b1423SMarissa Garza 200d76b1423SMarissa Garza Rprint Vars records 201d76b1423SMarissa Garza 202d76b1423SMarissa Garza # Example output: 203d76b1423SMarissa Garza # records: 204d76b1423SMarissa Garza # [0]: 205d76b1423SMarissa Garza # [@odata.id]: /redfish/v1/Chassis/chassis/Power#/PowerControl/0 206d76b1423SMarissa Garza # [@odata.type]: #Power.v1_0_0.PowerControl 207d76b1423SMarissa Garza # [MemberId]: 0 208d76b1423SMarissa Garza # [Name]: Chassis Power Control 209d76b1423SMarissa Garza # [PowerConsumedWatts]: 264.0 210d76b1423SMarissa Garza # [PowerLimit]: 211d76b1423SMarissa Garza # [LimitInWatts]: None 212d76b1423SMarissa Garza # [PowerMetrics]: 213d76b1423SMarissa Garza # [AverageConsumedWatts]: 325 214d76b1423SMarissa Garza # [IntervalInMin]: 3 215d76b1423SMarissa Garza # [MaxConsumedWatts]: 538 216d76b1423SMarissa Garza # [Status]: 217d76b1423SMarissa Garza # [Health]: OK 218d76b1423SMarissa Garza # [State]: Enabled 219d76b1423SMarissa Garza 220d76b1423SMarissa Garza ${invalid_records}= Filter Struct ${records} 221d76b1423SMarissa Garza ... [('Health', '^OK$'), ('State', '^Enabled$'), ('${reading_type}', '')] regex=1 invert=1 222d76b1423SMarissa Garza Valid Length invalid_records max_length=0 223fdee1b05SMarissa Garza 224fdee1b05SMarissa Garza [Return] ${records} 225ff2c0bc4SVijay 226ff2c0bc4SVijay 227ff2c0bc4SVijayRedfish Create User 228ff2c0bc4SVijay [Documentation] Redfish create user. 229ff2c0bc4SVijay [Arguments] ${user_name} ${password} ${role_id} ${enabled} ${force}=${False} 230ff2c0bc4SVijay 231ff2c0bc4SVijay # Description of argument(s): 232ff2c0bc4SVijay # user_name The user name to be created. 233ff2c0bc4SVijay # password The password to be assigned. 234ff2c0bc4SVijay # role_id The role ID of the user to be created. 235ff2c0bc4SVijay # (e.g. "Administrator", "Operator", etc.). 236ff2c0bc4SVijay # enabled Indicates whether the username being created. 237ff2c0bc4SVijay # should be enabled (${True}, ${False}). 238ff2c0bc4SVijay # force Delete user account and re-create if force is True. 239ff2c0bc4SVijay 240ff2c0bc4SVijay ${curr_role}= Run Keyword And Ignore Error Get User Role ${user_name} 241ff2c0bc4SVijay # Ex: ${curr_role} = ('PASS', 'Administrator') 242ff2c0bc4SVijay 243ff2c0bc4SVijay ${user_exists}= Run Keyword And Return Status Should Be Equal As Strings ${curr_role}[0] PASS 244ff2c0bc4SVijay 245ff2c0bc4SVijay # Delete user account when force is True. 246ff2c0bc4SVijay Run Keyword If ${force} == ${True} Redfish.Delete ${REDFISH_ACCOUNTS_URI}${user_name} 247ff2c0bc4SVijay ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] 248ff2c0bc4SVijay 249ff2c0bc4SVijay # Create specified user when force is True or User does not exist. 250ff2c0bc4SVijay ${payload}= Create Dictionary 251ff2c0bc4SVijay ... UserName=${user_name} Password=${password} RoleId=${role_id} Enabled=${enabled} 252ff2c0bc4SVijay 253ff2c0bc4SVijay Run Keyword If ${force} == ${True} or ${user_exists} == ${False} 254ff2c0bc4SVijay ... Redfish.Post ${REDFISH_ACCOUNTS_URI} body=&{payload} 255ff2c0bc4SVijay ... valid_status_codes=[${HTTP_CREATED}] 256ff2c0bc4SVijay 257ff2c0bc4SVijay 258ff2c0bc4SVijayGet User Role 259ff2c0bc4SVijay [Documentation] Get User Role. 260ff2c0bc4SVijay [Arguments] ${user_name} 261ff2c0bc4SVijay 262ff2c0bc4SVijay # Description of argument(s): 263ff2c0bc4SVijay # user_name User name to get it's role. 264ff2c0bc4SVijay 265ff2c0bc4SVijay ${role_config}= Redfish_Utils.Get Attribute 266ff2c0bc4SVijay ... ${REDFISH_ACCOUNTS_URI}${user_name} RoleId 267ff2c0bc4SVijay 268ff2c0bc4SVijay [Return] ${role_config} 269ff2c0bc4SVijay 270ff2c0bc4SVijay 271ff2c0bc4SVijayCreate Users With Different Roles 272ff2c0bc4SVijay [Documentation] Create users with different roles. 273ff2c0bc4SVijay [Arguments] ${users} ${force}=${False} 274ff2c0bc4SVijay 275ff2c0bc4SVijay # Description of argument(s): 276ff2c0bc4SVijay # users Dictionary of roles and user credentails to be created. 277ff2c0bc4SVijay # Ex: {'Administrator': '[admin_user, TestPwd123]', 'Operator': '[operator_user, TestPwd123]'} 278ff2c0bc4SVijay # force Delete given user account if already exists when force is True. 279ff2c0bc4SVijay 280ff2c0bc4SVijay FOR ${role} IN @{users} 281ff2c0bc4SVijay Redfish Create User ${users['${role}'][0]} ${users['${role}']}[1] ${role} ${True} ${force} 282ff2c0bc4SVijay END 283ff2c0bc4SVijay 28439373158SVijay 28539373158SVijayDelete BMC Users Via Redfish 28639373158SVijay [Documentation] Delete BMC users via redfish. 28739373158SVijay [Arguments] ${users} 28839373158SVijay 28939373158SVijay # Description of argument(s): 29039373158SVijay # users Dictionary of roles and user credentials to be deleted. 29139373158SVijay 29239373158SVijay FOR ${role} IN @{users} 29339373158SVijay Redfish.Delete /redfish/v1/AccountService/Accounts/${users['${role}'][0]} 29439373158SVijay ... valid_status_codes=[${HTTP_OK}, ${HTTP_NOT_FOUND}] 29539373158SVijay END 29639373158SVijay 2977ed1ae88SAnves Kumar rayankula 2987ed1ae88SAnves Kumar rayankulaExpire And Update New Password Via Redfish 2997ed1ae88SAnves Kumar rayankula [Documentation] Expire and change password and verify using password. 3007ed1ae88SAnves Kumar rayankula [Arguments] ${username} ${password} ${new_password} 3017ed1ae88SAnves Kumar rayankula 3027ed1ae88SAnves Kumar rayankula # Description of argument(s): 3037ed1ae88SAnves Kumar rayankula # username The username to be used to login to the BMC. 3047ed1ae88SAnves Kumar rayankula # password The password to be used to login to the BMC. 3057ed1ae88SAnves Kumar rayankula # new_password The new password to be used to update password. 3067ed1ae88SAnves Kumar rayankula 3077ed1ae88SAnves Kumar rayankula # Expire admin password using ssh. 30839848ba6SSushil Singh Open Connection And Log In ${OPENBMC_USERNAME} ${OPENBMC_PASSWORD} 3097ed1ae88SAnves Kumar rayankula ${output} ${stderr} ${rc}= BMC Execute Command passwd --expire ${username} 31045aa881dSBrian Ma Should Contain Any ${output} password expiry information changed 31145aa881dSBrian Ma ... password changed 3127ed1ae88SAnves Kumar rayankula 3137ed1ae88SAnves Kumar rayankula # Verify user password expired using Redfish 3147ed1ae88SAnves Kumar rayankula Verify User Password Expired Using Redfish ${username} ${password} 3157ed1ae88SAnves Kumar rayankula 3167ed1ae88SAnves Kumar rayankula # Change user password. 31745aa881dSBrian Ma Redfish.Patch /redfish/v1/AccountService/Accounts/${username} 3187ed1ae88SAnves Kumar rayankula ... body={'Password': '${new_password}'} 3197ed1ae88SAnves Kumar rayankula Redfish.Logout 3207ed1ae88SAnves Kumar rayankula 3217ed1ae88SAnves Kumar rayankula 3227ed1ae88SAnves Kumar rayankulaVerify User Password Expired Using Redfish 3237ed1ae88SAnves Kumar rayankula [Documentation] Checking whether user password expired or not using redfish. 3247ed1ae88SAnves Kumar rayankula 3257ed1ae88SAnves Kumar rayankula # Description of argument(s): 3267ed1ae88SAnves Kumar rayankula # username The username to be used to login to the BMC. 3277ed1ae88SAnves Kumar rayankula # password The password to be used to login to the BMC. 3287ed1ae88SAnves Kumar rayankula 3297ed1ae88SAnves Kumar rayankula [Arguments] ${username} ${password} ${expected_result}=${True} 3307ed1ae88SAnves Kumar rayankula Redfish.Login ${username} ${password} 3317ed1ae88SAnves Kumar rayankula ${resp}= Redfish.Get /redfish/v1/AccountService/Accounts/${username} 3327ed1ae88SAnves Kumar rayankula Should Be Equal ${resp.dict["PasswordChangeRequired"]} ${expected_result} 3337ed1ae88SAnves Kumar rayankula 334