1*** Settings ***
2Documentation    Utilities for redfish BIOS attribute operations.
3
4Resource         ../../../lib/resource.robot
5Resource         ../../../lib/bmc_redfish_resource.robot
6Resource         ../../../lib/common_utils.robot
7
8
9*** Keywords ***
10
11Set BIOS Attribute Value And Verify
12
13    [Documentation]  Set BIOS attribute handle with attribute value and verify.
14    [Arguments]      ${attr_handle}  ${attr_val}
15
16    ${type_int}=    Evaluate  isinstance($attr_val, int)
17    ${value}=  Set Variable If  '${type_int}' == '${True}'  ${attr_val}  '${attr_val}'
18
19    Redfish.Patch  ${BIOS_ATTR_SETTINGS_URI}  body={"Attributes":{"${attr_handle}": ${value}}}
20    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
21
22    ${output}=  Redfish.Get Attribute  ${BIOS_ATTR_URI}  Attributes
23    Should Be Equal  ${output['${attr_handle}']}  ${attr_val}
24
25
26Set Optional BIOS Attribute Values And Verify
27
28    [Documentation]  For the given BIOS attribute handle update with optional
29    ...              attribute values and verify.
30    [Arguments]  ${attr_handle}  @{attr_val_list}
31
32    # Description of argument(s):
33    # ${attr_handle}    BIOS Attribute handle (e.g. 'vmi_if0_ipv4_method').
34    # @{attr_val_list}  List of the attribute values for the given attribute handle.
35    #                   (e.g. ['IPv4Static', 'IPv4DHCP']).
36
37    FOR  ${attr}  IN  @{attr_val_list}
38        ${new_attr}=  Evaluate  $attr.replace('"', '')
39        Set BIOS Attribute Value And Verify  ${attr_handle}  ${new_attr}
40    END
41