1*** Settings ***
2Documentation    Utilities for redfish BIOS attribute operations.
3
4Resource         resource.robot
5Resource         bmc_redfish_resource.robot
6Resource         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}  ${verify}=${True}
15
16    # Description of argument(s):
17    # ${attr_handle}    BIOS Attribute handle (e.g. 'vmi_if0_ipv4_method').
18    # @{attr_val}       Attribute value for the given attribute handle.
19    # ${verify}         Verify the new value.
20
21
22    ${type_int}=    Evaluate  isinstance($attr_val, int)
23    ${value}=  Set Variable If  '${type_int}' == '${True}'  ${attr_val}  '${attr_val}'
24
25    Redfish.Patch  ${BIOS_ATTR_SETTINGS_URI}  body={"Attributes":{"${attr_handle}": ${value}}}
26    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
27
28    Run Keyword If  '${verify}' == '${True}'  Verify BIOS Attribute  ${attr_handle}  ${attr_val}
29
30
31Set Optional BIOS Attribute Values And Verify
32
33    [Documentation]  For the given BIOS attribute handle update with optional
34    ...              attribute values and verify.
35    [Arguments]  ${attr_handle}  @{attr_val_list}
36
37    # Description of argument(s):
38    # ${attr_handle}    BIOS Attribute handle (e.g. 'vmi_if0_ipv4_method').
39    # @{attr_val_list}  List of the attribute values for the given attribute handle.
40    #                   (e.g. ['IPv4Static', 'IPv4DHCP']).
41
42    FOR  ${attr}  IN  @{attr_val_list}
43        ${new_attr}=  Evaluate  $attr.replace('"', '')
44        Set BIOS Attribute Value And Verify  ${attr_handle}  ${new_attr}
45    END
46
47
48Verify BIOS Attribute
49
50    [Documentation]  Verify BIOS attribute value.
51    [Arguments]  ${attr_handle}  ${attr_val}
52
53    # Description of argument(s):
54    # ${attr_handle}    BIOS Attribute handle (e.g. 'vmi_if0_ipv4_method').
55    # ${attr_val}       The expected value for the given attribute handle.
56
57    ${output}=  Redfish.Get Attribute  ${BIOS_ATTR_URI}  Attributes
58    Should Be Equal  ${output['${attr_handle}']}  ${attr_val}
59