1*** Settings *** 2Documentation BMC and host redfish utility keywords. 3 4Resource resource.robot 5Resource bmc_redfish_resource.robot 6 7 8*** Keywords *** 9 10Redfish Power Operation 11 [Documentation] Do Redfish host power operation. 12 [Arguments] ${reset_type} 13 # Description of arguments: 14 # reset_type Type of power operation. 15 # (e.g. On/ForceOff/GracefulRestart/GracefulShutdown) 16 17 # Example: 18 # "Actions": { 19 # "#ComputerSystem.Reset": { 20 # "ResetType@Redfish.AllowableValues": [ 21 # "On", 22 # "ForceOff", 23 # "GracefulRestart", 24 # "GracefulShutdown" 25 # ], 26 # "target": "/redfish/v1/Systems/system/Actions/ComputerSystem.Reset" 27 # } 28 # } 29 30 Redfish.Login 31 ${target}= redfish_utils.Get Target Actions /redfish/v1/Systems/system/ ComputerSystem.Reset 32 ${payload}= Create Dictionary ResetType=${reset_type} 33 ${resp}= Redfish.Post ${target} body=&{payload} 34 Redfish.Logout 35 36 37Redfish BMC Reset Operation 38 [Documentation] Do Redfish BMC reset operation. 39 40 # Example: 41 # "Actions": { 42 # "#Manager.Reset": { 43 # "ResetType@Redfish.AllowableValues": [ 44 # "GracefulRestart" 45 # ], 46 # "target": "/redfish/v1/Managers/bmc/Actions/Manager.Reset" 47 # } 48 49 Redfish.Login 50 ${target}= redfish_utils.Get Target Actions /redfish/v1/Managers/bmc/ Manager.Reset 51 ${payload}= Create Dictionary ResetType=GracefulRestart 52 ${resp}= Redfish.Post ${target} body=&{payload} 53 # The logout may very well fail because the system was just asked to 54 # reset itself. 55 Run Keyword And Ignore Error Redfish.Logout 56 57 58Delete All Redfish Sessions 59 [Documentation] Delete all active redfish sessions. 60 61 Redfish.Login 62 ${saved_session_info}= Get Redfish Session Info 63 64 ${resp_list}= Redfish_Utils.Get Member List 65 ... /redfish/v1/SessionService/Sessions 66 67 # Remove the current login session from the list. 68 Remove Values From List ${resp_list} ${saved_session_info["location"]} 69 70 :FOR ${session} IN @{resp_list} 71 \ Redfish.Delete ${session} 72 73 Redfish.Logout 74 75 76Get Valid FRUs 77 [Documentation] Return a dictionary containing all of the valid FRU records for the given fru_type. 78 [Arguments] ${fru_type} 79 80 # NOTE: A valid FRU record will have a "State" key of "Enabled" and a "Health" key of "OK". 81 82 # Description of argument(s): 83 # fru_type The type of fru (e.g. "Processors", "Memory", etc.). 84 85 ${fru_records}= Redfish_Utils.Enumerate Request 86 ... /redfish/v1/Systems/system/${fru_type} return_json=0 87 ${fru_records}= Filter Struct ${fru_records} [('State', 'Enabled'), ('Health', 'OK')] 88 89 [Return] ${fru_records} 90 91 92Get Num Valid FRUs 93 [Documentation] Return the number of valid FRU records for the given fru_type. 94 [Arguments] ${fru_type} 95 96 # Description of argument(s): 97 # fru_type The type of fru (e.g. "Processors", "Memory", etc.). 98 99 ${fru_records}= Get Valid FRUs ${fru_type} 100 ${num_valid_frus}= Get length ${fru_records} 101 102 [Return] ${num_valid_frus} 103