1c288affeSganesanb*** Settings *** 2c288affeSganesanbDocumentation Implemented keywords to execute DBUS related commands on BMC. 3c288affeSganesanb 4c288affeSganesanbResource resource.robot 5c288affeSganesanbLibrary OperatingSystem 6c288affeSganesanbLibrary Collections 7c288affeSganesanb 8*409df05dSGeorge Keishing*** Variables *** 9c288affeSganesanb 10c288affeSganesanb${BUSCTL_TREE_COMMAND} busctl tree | less 11c288affeSganesanb${BUSCTL_INTROSPECT_COMMAND} busctl introspect 12c288affeSganesanb@{dbus_uri_list} 13c288affeSganesanb 14c288affeSganesanb*** Keywords *** 15c288affeSganesanb 16c288affeSganesanbGet DBUS URI List From BMC 17c288affeSganesanb [Documentation] Get the available DBUS URIs from device tree on BMC. 18c288affeSganesanb [Arguments] ${service_name} ${dbus_url} 19c288affeSganesanb 20c288affeSganesanb # Return the dbus uris corresponding to the service name provided. 21c288affeSganesanb # Description of argument(s): 22c288affeSganesanb # service_name Any service uri of the dbus. 23c288affeSganesanb # Eg : xyz.openbmc_project.FruDevice 24c288affeSganesanb # dbus_url Any dbus url of the dbus. 25c288affeSganesanb # Eg : /xyz/openbmc_project/FruDevice 26c288affeSganesanb 27c288affeSganesanb # Execute dbus tree command 28c288affeSganesanb ${bmc_response}= BMC Execute Command ${BUSCTL_TREE_COMMAND} 29c288affeSganesanb ${bmc_response}= Convert To List ${bmc_response} 30c288affeSganesanb ${bmc_response_output}= Get From List ${bmc_response} 0 31c288affeSganesanb ${bmc_response_output_list}= Split String ${bmc_response_output} \n\n 32c288affeSganesanb # Identify the offset of the service name in the response. 33c288affeSganesanb ${service_name_index_value}= get_subsequent_value_from_list ${bmc_response_output_list} ${service_name} 34c288affeSganesanb ${service_name_index_value}= Get From List ${service_name_index_value} 0 35c288affeSganesanb 36c288affeSganesanb # Get the service name and its corresponding URI's. 37c288affeSganesanb ${service_name_with_uri_list}= Get From List ${bmc_response_output_list} ${service_name_index_value} 38c288affeSganesanb ${service_name_with_uri_list}= Split String ${service_name_with_uri_list} \n 39c288affeSganesanb 40c288affeSganesanb # Find index of all the uris where the dbus URI matched. 41c288affeSganesanb ${uri_list_index}= get_subsequent_value_from_list ${service_name_with_uri_list} ${dbus_url} 42c288affeSganesanb FOR ${list_index} IN @{uri_list_index} 43c288affeSganesanb # For each index, get the URI and append to list 44c288affeSganesanb ${dbus_uri}= Get From List ${service_name_with_uri_list} ${list_index} 45c288affeSganesanb Append To List ${dbus_uri_list} ${dbus_uri} 46c288affeSganesanb END 47c288affeSganesanb 48*409df05dSGeorge Keishing RETURN ${dbus_uri_list[1:]} 49c288affeSganesanb 50c288affeSganesanb 51c288affeSganesanbFetch DBUS URI List Without Unicode 52c288affeSganesanb [Documentation] Gets the list of DBUS URI for the service and returns only sub URIs. 53c288affeSganesanb [Arguments] ${dbus_uri_list} 54c288affeSganesanb 55c288affeSganesanb # Return the dbus uris list without the unicodes. 56c288affeSganesanb # Description of argument(s): 57c288affeSganesanb # dbus_uri_list List of all the uris for the corresponding service name. 58c288affeSganesanb # Example: Converts " ├─/xyz/openbmc_project/FruDevice/device_0", 59c288affeSganesanb # ... to '/xyz/openbmc_project/FruDevice/device_0' 60c288affeSganesanb 61c288affeSganesanb @{dbus_list}= Create List 62c288affeSganesanb FOR ${item} IN @{dbus_uri_list} 63c288affeSganesanb ${item}= Set Variable ${item.strip()} 6407958e19Sganesanb ${item}= Remove Unicode From Uri ${item} 65c288affeSganesanb Append To List ${dbus_list} ${item} 66c288affeSganesanb END 67c288affeSganesanb 68*409df05dSGeorge Keishing RETURN ${dbus_list} 69c288affeSganesanb 70c288affeSganesanb 71c288affeSganesanbExecute DBUS Introspect Command 72c288affeSganesanb [Documentation] Execute the DBUS introspect command and return response. 73c288affeSganesanb [Arguments] ${dbus_command} 74c288affeSganesanb 75c288affeSganesanb # Execute the busctl instrospect command for the service name and dbus uri. 76c288affeSganesanb # Description of argument(s): 77c288affeSganesanb # dbus_command Command with service name and dbus uri for the fru device. 78c288affeSganesanb # Example : xyz.openbmc_project.FruDevice xyz/openbmc_project/FruDevice/device_0 79c288affeSganesanb 80c288affeSganesanb ${cmd}= Catenate ${BUSCTL_INTROSPECT_COMMAND} ${dbus_command} 81c288affeSganesanb ${resp}= BMC Execute Command ${cmd} 82c288affeSganesanb 83*409df05dSGeorge Keishing RETURN ${resp[0]} 84