1*** Settings ***
2Documentation    Verify that Redfish software inventory can be collected.
3
4Resource         ../../lib/resource.robot
5Resource         ../../lib/bmc_redfish_resource.robot
6Resource         ../../lib/openbmc_ffdc.robot
7Library          ../../lib/gen_robot_valid.py
8
9Test Setup       Test Setup Execution
10Test Teardown    Test Teardown Execution
11
12*** Test Cases ***
13
14Verify Redfish Update Service Enabled
15    [Documentation]  Verify "ServiceEnabled" is enabled.
16    [Tags]  Verify_Update_Service_Enabled
17
18    # Example:
19    # "HttpPushUri": "/redfish/v1/UpdateService",
20    # "Id": "UpdateService",
21    # "Name": "Update Service",
22    # "ServiceEnabled": true
23
24    ${resp}=  Redfish.Get  /redfish/v1/UpdateService
25    Should Be Equal As Strings  ${resp.dict["ServiceEnabled"]}  ${True}
26
27
28Verify Redfish Software Inventory Collection
29    [Documentation]  Verify software inventory collection member and object entries.
30    [Tags]  Verify_Redfish_Software_Inventory_Collection
31
32    # Example:
33    # {
34    #    "@odata.type": "#SoftwareInventoryCollection.SoftwareInventoryCollection",
35    #    "Members": [
36    #      {
37    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/a3522998"
38    #      },
39    #      {
40    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/a7c79f71"
41    #      },
42    #      {
43    #        "@odata.id": "/redfish/v1/UpdateService/FirmwareInventory/ace821ef"
44    #      }
45    #   ],
46    #   "Members@odata.count": 3,
47    #   "Name": "Software Inventory Collection"
48    # }
49
50    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
51
52    Should Be True  ${resp.dict["Members@odata.count"]} >= ${1}
53    Length Should Be  ${resp.dict["Members"]}  ${resp.dict["Members@odata.count"]}
54
55
56Redfish Software Inventory Status Check
57    [Documentation]  Get firmware inventory entries and do health check status.
58    [Tags]  Redfish_Software_Inventory_Status_Check
59
60    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
61
62    # Entries "Members@odata.count": 3,
63    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
64    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a7c79f71'}
65    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
66
67    :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
68    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
69    # Example:
70    # "Status": {
71    #     "Health": "OK",
72    #     "HealthRollup": "OK",
73    #     "State": "Enabled"
74    # },
75    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["Health"]}  OK
76    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["HealthRollup"]}  OK
77    \  Should Be Equal As Strings  ${resp_resource.dict["Status"]["State"]}  Enabled
78
79
80Verify BMC Version Matches With FirmwareInventory
81    [Documentation]  Verify BMC version from FirmwareInventory same as in manager.
82    [Tags]  Verify_BMC_Version_Matches_With_FirmwareInventory
83
84    ${bmc_manager}=  Redfish.Get  /redfish/v1/Managers/bmc
85    ${manager_bmc_version}=  Get BMC Version
86    # Check for manager version and cat /etc/os-release.
87    Should Be Equal As Strings
88    ...  ${bmc_manager.dict["FirmwareVersion"]}  ${manager_bmc_version.strip('"')}
89
90    ${resp}=  Redfish.Get  /redfish/v1/UpdateService/FirmwareInventory
91
92    # Entries "Members@odata.count": 3,
93    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a3522998'}
94    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/a7c79f71'}
95    # {'@odata.id': '/redfish/v1/UpdateService/FirmwareInventory/ace821ef'}
96
97    ${actual_count}=  Evaluate  ${resp.dict["Members@odata.count"]}-1
98    :FOR  ${entry}  IN RANGE  0  ${resp.dict["Members@odata.count"]}
99    \  ${resp_resource}=  Redfish.Get  ${resp.dict["Members"][${entry}]["@odata.id"]}
100    # 3rd comparison of BMC version and verify FirmwareInventory bmc version.
101    # Example:
102    # "Version": 2.7.0-dev-19-g9b44ea7
103    \  Exit For Loop If  '${resp_resource.dict["Version"]}' == '${manager_bmc_version.strip('"')}'
104    \  Run Keyword If  '${entry}' == '${actual_count}'  Fail
105    ...  BMC version not there in Firmware Inventory
106
107
108Verify UpdateService Supports TransferProtocol TFTP
109    [Documentation]  Verify update service supported values have TFTP protocol.
110    [Tags]  Verify_UpdateService_Supports_TransferProtocol_TFTP
111
112    # Example:
113    #   "Actions": {
114    #     "#UpdateService.SimpleUpdate": {
115    #       "TransferProtocol@Redfish.AllowableValues": [
116    #         "TFTP"
117    #       ],
118    #       "target": "/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate"
119    #     }
120    #  },
121
122    ${allowable_values}=  Redfish.Get Attribute  /redfish/v1/UpdateService  Actions
123
124    Rvalid Value  allowable_values["#UpdateService.SimpleUpdate"]["TransferProtocol@Redfish.AllowableValues"][0]  valid_values=['TFTP']
125    Rvalid Value  allowable_values["#UpdateService.SimpleUpdate"]["target"]  valid_values=['/redfish/v1/UpdateService/Actions/UpdateService.SimpleUpdate']
126
127
128Verify Redfish BIOS Version
129    [Documentation]  Get host firmware version from system inventory.
130    [Tags]  Verify_Redfish_BIOS_Version
131
132    ${bios_version}=  Redfish.Get Attribute  /redfish/v1/Systems/system/  BiosVersion
133    ${pnor_version}=  Get PNOR Version
134    Should Be Equal  ${pnor_version}  ${bios_version}
135
136
137*** Keywords ***
138
139Test Setup Execution
140    [Documentation]  Do test case setup tasks.
141
142    Redfish.Login
143
144
145Test Teardown Execution
146    [Documentation]  Do the post test teardown.
147
148    FFDC On Test Case Fail
149    Redfish.Logout
150