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} 130047de86SSridevi Ramesh # Description of arguments: 140047de86SSridevi Ramesh # reset_type Type of power operation. 150047de86SSridevi Ramesh # (e.g. On/ForceOff/GracefulRestart/GracefulShutdown) 160047de86SSridevi Ramesh 170047de86SSridevi Ramesh # Example: 180047de86SSridevi Ramesh # "Actions": { 190047de86SSridevi Ramesh # "#ComputerSystem.Reset": { 200047de86SSridevi Ramesh # "ResetType@Redfish.AllowableValues": [ 210047de86SSridevi Ramesh # "On", 220047de86SSridevi Ramesh # "ForceOff", 230047de86SSridevi Ramesh # "GracefulRestart", 240047de86SSridevi Ramesh # "GracefulShutdown" 250047de86SSridevi Ramesh # ], 262deec3cfSGeorge Keishing # "target": "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset" 272deec3cfSGeorge Keishing # } 282deec3cfSGeorge Keishing # } 290047de86SSridevi Ramesh 30213feb34SMichael Walsh Redfish.Login 31c2b176e2SGeorge Keishing ${target}= redfish_utils.Get Target Actions /redfish/v1/Systems/system/ ComputerSystem.Reset 320047de86SSridevi Ramesh ${payload}= Create Dictionary ResetType=${reset_type} 33213feb34SMichael Walsh ${resp}= Redfish.Post ${target} body=&{payload} 34213feb34SMichael Walsh Redfish.Logout 350047de86SSridevi Ramesh 360047de86SSridevi Ramesh 37b10eacafSGeorge KeishingRedfish BMC Reset Operation 38b10eacafSGeorge Keishing [Documentation] Do Redfish BMC reset operation. 390047de86SSridevi Ramesh 40b10eacafSGeorge Keishing # Example: 41b10eacafSGeorge Keishing # "Actions": { 42b10eacafSGeorge Keishing # "#Manager.Reset": { 43b10eacafSGeorge Keishing # "ResetType@Redfish.AllowableValues": [ 44b10eacafSGeorge Keishing # "GracefulRestart" 45b10eacafSGeorge Keishing # ], 46b10eacafSGeorge Keishing # "target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset" 47b10eacafSGeorge Keishing # } 48b10eacafSGeorge Keishing 49213feb34SMichael Walsh Redfish.Login 50c2b176e2SGeorge Keishing ${target}= redfish_utils.Get Target Actions /redfish/v1/Managers/bmc/ Manager.Reset 51b10eacafSGeorge Keishing ${payload}= Create Dictionary ResetType=GracefulRestart 52213feb34SMichael Walsh ${resp}= Redfish.Post ${target} body=&{payload} 53213feb34SMichael Walsh # The logout may very well fail because the system was just asked to 54213feb34SMichael Walsh # reset itself. 55213feb34SMichael Walsh Run Keyword And Ignore Error Redfish.Logout 56caa718bfSGeorge Keishing 57caa718bfSGeorge Keishing 58caa718bfSGeorge KeishingDelete All Redfish Sessions 59caa718bfSGeorge Keishing [Documentation] Delete all active redfish sessions. 60caa718bfSGeorge Keishing 61caa718bfSGeorge Keishing Redfish.Login 62caa718bfSGeorge Keishing ${saved_session_info}= Get Redfish Session Info 63caa718bfSGeorge Keishing 64caa718bfSGeorge Keishing ${resp_list}= Redfish_Utils.Get Member List 65caa718bfSGeorge Keishing ... /redfish/v1/SessionService/Sessions 66caa718bfSGeorge Keishing 67caa718bfSGeorge Keishing # Remove the current login session from the list. 68caa718bfSGeorge Keishing Remove Values From List ${resp_list} ${saved_session_info["location"]} 69caa718bfSGeorge Keishing 70caa718bfSGeorge Keishing :FOR ${session} IN @{resp_list} 71caa718bfSGeorge Keishing \ Redfish.Delete ${session} 72caa718bfSGeorge Keishing 73caa718bfSGeorge Keishing Redfish.Logout 74cf163321SMichael Walsh 75cf163321SMichael Walsh 76cf163321SMichael WalshGet Valid FRUs 77cf163321SMichael Walsh [Documentation] Return a dictionary containing all of the valid FRU records for the given fru_type. 78cf163321SMichael Walsh [Arguments] ${fru_type} 79cf163321SMichael Walsh 80cf163321SMichael Walsh # NOTE: A valid FRU record will have a "State" key of "Enabled" and a "Health" key of "OK". 81cf163321SMichael Walsh 82cf163321SMichael Walsh # Description of argument(s): 83cf163321SMichael Walsh # fru_type The type of fru (e.g. "Processors", "Memory", etc.). 84cf163321SMichael Walsh 85cf163321SMichael Walsh ${fru_records}= Redfish_Utils.Enumerate Request 86cf163321SMichael Walsh ... /redfish/v1/Systems/system/${fru_type} return_json=0 87e256a4f6SMichael Walsh ${fru_records}= Filter Struct ${fru_records} [('State', 'Enabled'), ('Health', 'OK')] 88cf163321SMichael Walsh 89cf163321SMichael Walsh [Return] ${fru_records} 90cf163321SMichael Walsh 91cf163321SMichael Walsh 92cf163321SMichael WalshGet Num Valid FRUs 93cf163321SMichael Walsh [Documentation] Return the number of valid FRU records for the given fru_type. 94cf163321SMichael Walsh [Arguments] ${fru_type} 95cf163321SMichael Walsh 96cf163321SMichael Walsh # Description of argument(s): 97cf163321SMichael Walsh # fru_type The type of fru (e.g. "Processors", "Memory", etc.). 98cf163321SMichael Walsh 99cf163321SMichael Walsh ${fru_records}= Get Valid FRUs ${fru_type} 100cf163321SMichael Walsh ${num_valid_frus}= Get length ${fru_records} 101cf163321SMichael Walsh 102cf163321SMichael Walsh [Return] ${num_valid_frus} 103d76b1423SMarissa Garza 104d76b1423SMarissa Garza 105d76b1423SMarissa GarzaVerify Valid Records 106d76b1423SMarissa Garza [Documentation] Verify all records retrieved with the given arguments are valid. 107d76b1423SMarissa Garza [Arguments] ${record_type} ${redfish_uri} ${reading_type} 108d76b1423SMarissa Garza 109d76b1423SMarissa Garza # Description of Argument(s): 110d76b1423SMarissa Garza # record_type The sensor record type (e.g. "PowerSupplies") 111d76b1423SMarissa Garza # redfish_uri The power supply URI (e.g. /redfish/v1/Chassis/chassis/Power) 112d76b1423SMarissa Garza # reading_type The power watt readings (e.g. "PowerInputWatts") 113d76b1423SMarissa Garza 114d76b1423SMarissa Garza # A valid record will have "State" key "Enabled" and "Health" key "OK". 115d76b1423SMarissa Garza ${records}= Redfish.Get Attribute ${redfish_uri} ${record_type} 116d76b1423SMarissa Garza 117d76b1423SMarissa Garza Rprint Vars records 118d76b1423SMarissa Garza 119d76b1423SMarissa Garza # Example output: 120d76b1423SMarissa Garza # records: 121d76b1423SMarissa Garza # [0]: 122d76b1423SMarissa Garza # [@odata.id]: /redfish/v1/Chassis/chassis/Power#/PowerControl/0 123d76b1423SMarissa Garza # [@odata.type]: #Power.v1_0_0.PowerControl 124d76b1423SMarissa Garza # [MemberId]: 0 125d76b1423SMarissa Garza # [Name]: Chassis Power Control 126d76b1423SMarissa Garza # [PowerConsumedWatts]: 264.0 127d76b1423SMarissa Garza # [PowerLimit]: 128d76b1423SMarissa Garza # [LimitInWatts]: None 129d76b1423SMarissa Garza # [PowerMetrics]: 130d76b1423SMarissa Garza # [AverageConsumedWatts]: 325 131d76b1423SMarissa Garza # [IntervalInMin]: 3 132d76b1423SMarissa Garza # [MaxConsumedWatts]: 538 133d76b1423SMarissa Garza # [Status]: 134d76b1423SMarissa Garza # [Health]: OK 135d76b1423SMarissa Garza # [State]: Enabled 136d76b1423SMarissa Garza 137d76b1423SMarissa Garza ${invalid_records}= Filter Struct ${records} 138d76b1423SMarissa Garza ... [('Health', '^OK$'), ('State', '^Enabled$'), ('${reading_type}', '')] regex=1 invert=1 139d76b1423SMarissa Garza Valid Length invalid_records max_length=0 140*fdee1b05SMarissa Garza 141*fdee1b05SMarissa Garza [Return] ${records} 142