| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 1 | *** Settings *** | 
 | 2 | Documentation    Test BMC manager time functionality. | 
 | 3 | Resource                     ../../lib/resource.robot | 
 | 4 | Resource                     ../../lib/bmc_redfish_resource.robot | 
 | 5 | Resource                     ../../lib/common_utils.robot | 
 | 6 | Resource                     ../../lib/openbmc_ffdc.robot | 
 | 7 | Resource                     ../../lib/utils.robot | 
| Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 8 | Resource                     ../../lib/rest_client.robot | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 9 | Library                      ../../lib/gen_robot_valid.py | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 10 |  | 
| Michael Walsh | 09083a8 | 2019-08-01 12:46:16 -0500 | [diff] [blame] | 11 | Test Setup                   Printn | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 12 | Test Teardown                Test Teardown Execution | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 13 | Suite Setup                  Suite Setup Execution | 
| George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 14 | Suite Teardown               Suite Teardown Execution | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 15 |  | 
 | 16 | *** Variables *** | 
 | 17 | ${max_time_diff_in_seconds}  6 | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 18 | # The "offset" consists of the value "26" specified for hours.  Redfish will | 
 | 19 | # convert that to the next day + 2 hours. | 
 | 20 | ${date_time_with_offset}     2019-04-25T26:24:46+00:00 | 
 | 21 | ${expected_date_time}        2019-04-26T02:24:46+00:00 | 
| Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 22 | ${invalid_datetime}          "2019-04-251T12:24:46+00:00" | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 23 | ${ntp_server_1}              9.9.9.9 | 
 | 24 | ${ntp_server_2}              2.2.3.3 | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 25 | &{original_ntp}              &{EMPTY} | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 26 |  | 
 | 27 | *** Test Cases *** | 
 | 28 |  | 
 | 29 | Verify Redfish BMC Time | 
 | 30 |     [Documentation]  Verify that date/time obtained via redfish matches | 
 | 31 |     ...  date/time obtained via BMC command line. | 
 | 32 |     [Tags]  Verify_Redfish_BMC_Time | 
 | 33 |  | 
 | 34 |     ${redfish_date_time}=  Redfish Get DateTime | 
 | 35 |     ${cli_date_time}=  CLI Get BMC DateTime | 
 | 36 |     ${time_diff}=  Subtract Date From Date  ${cli_date_time} | 
 | 37 |     ...  ${redfish_date_time} | 
 | 38 |     ${time_diff}=  Evaluate  abs(${time_diff}) | 
 | 39 |     Rprint Vars  redfish_date_time  cli_date_time  time_diff | 
 | 40 |     Should Be True  ${time_diff} < ${max_time_diff_in_seconds} | 
 | 41 |     ...  The difference between Redfish time and CLI time exceeds the allowed time difference. | 
 | 42 |  | 
 | 43 |  | 
| Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 44 | Verify Set Time Using Redfish | 
 | 45 |     [Documentation]  Verify set time using redfish API. | 
 | 46 |     [Tags]  Verify_Set_Time_Using_Redfish | 
 | 47 |  | 
| Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 48 |     Set Time To Manual Mode | 
| Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 49 |  | 
| Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 50 |     ${old_bmc_time}=  CLI Get BMC DateTime | 
 | 51 |     # Add 3 days to current date. | 
 | 52 |     ${new_bmc_time}=  Add Time to Date  ${old_bmc_time}  3 Days | 
 | 53 |     Redfish Set DateTime  ${new_bmc_time} | 
 | 54 |     ${cli_bmc_time}=  CLI Get BMC DateTime | 
 | 55 |     ${time_diff}=  Subtract Date From Date  ${cli_bmc_time} | 
 | 56 |     ...  ${new_bmc_time} | 
 | 57 |     ${time_diff}=  Evaluate  abs(${time_diff}) | 
 | 58 |     Rprint Vars   old_bmc_time  new_bmc_time  cli_bmc_time  time_diff  max_time_diff_in_seconds | 
 | 59 |     Should Be True  ${time_diff} < ${max_time_diff_in_seconds} | 
 | 60 |     ...  The difference between Redfish time and CLI time exceeds the allowed time difference. | 
 | 61 |     # Setting back to old bmc time. | 
 | 62 |     Redfish Set DateTime  ${old_bmc_time} | 
 | 63 |  | 
 | 64 |  | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 65 | Verify Set DateTime With Offset Using Redfish | 
 | 66 |     [Documentation]  Verify set DateTime with offset using redfish API. | 
 | 67 |     [Tags]  Verify_Set_DateTime_With_Offset_Using_Redfish | 
 | 68 |     [Teardown]  Run Keywords  Redfish Set DateTime  AND  FFDC On Test Case Fail | 
 | 69 |  | 
 | 70 |     Redfish Set DateTime  ${date_time_with_offset} | 
 | 71 |     ${cli_bmc_time}=  CLI Get BMC DateTime | 
 | 72 |  | 
 | 73 |     ${date_time_diff}=  Subtract Date From Date  ${cli_bmc_time} | 
 | 74 |     ...  ${expected_date_time}  exclude_millis=yes | 
 | 75 |     ${date_time_diff}=  Convert to Integer  ${date_time_diff} | 
| Michael Walsh | 09083a8 | 2019-08-01 12:46:16 -0500 | [diff] [blame] | 76 |     Rprint Vars  date_time_with_offset  expected_date_time  cli_bmc_time | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 77 |     ...  date_time_diff  max_time_diff_in_seconds | 
| Michael Walsh | 09083a8 | 2019-08-01 12:46:16 -0500 | [diff] [blame] | 78 |     Valid Range  date_time_diff  0  ${max_time_diff_in_seconds} | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 79 |  | 
 | 80 |  | 
| Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 81 | Verify Set DateTime With Invalid Data Using Redfish | 
 | 82 |     [Documentation]  Verify error while setting invalid DateTime using Redfish. | 
 | 83 |     [Tags]  Verify_Set_DateTime_With_Invalid_Data_Using_Redfish | 
 | 84 |  | 
 | 85 |     Redfish Set DateTime  ${invalid_datetime}  valid_status_codes=[${HTTP_BAD_REQUEST}] | 
 | 86 |  | 
 | 87 |  | 
| Sivas SRR | 4d64599 | 2019-06-20 05:34:50 -0500 | [diff] [blame] | 88 | Verify DateTime Persists After Reboot | 
 | 89 |     [Documentation]  Verify date persists after BMC reboot. | 
 | 90 |     [Tags]  Verify_DateTime_Persists_After_Reboot | 
 | 91 |  | 
 | 92 |     # Synchronize BMC date/time to local system date/time. | 
 | 93 |     ${local_system_time}=  Get Current Date | 
 | 94 |     Redfish Set DateTime  ${local_system_time} | 
 | 95 |     Redfish OBMC Reboot (off) | 
 | 96 |     Redfish.Login | 
 | 97 |     ${bmc_time}=  CLI Get BMC DateTime | 
 | 98 |     ${local_system_time}=  Get Current Date | 
 | 99 |     ${time_diff}=  Subtract Date From Date  ${bmc_time} | 
 | 100 |     ...  ${local_system_time} | 
 | 101 |     ${time_diff}=  Evaluate  abs(${time_diff}) | 
 | 102 |     Rprint Vars   local_system_time  bmc_time  time_diff  max_time_diff_in_seconds | 
 | 103 |     Should Be True  ${time_diff} < ${max_time_diff_in_seconds} | 
 | 104 |     ...  The difference between Redfish time and CLI time exceeds the allowed time difference. | 
 | 105 |  | 
 | 106 |  | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 107 | Verify NTP Server Set | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 108 |     [Documentation]  Patch NTP servers and verify NTP servers is set. | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 109 |     [Tags]  Verify_NTP_Server_Set | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 110 |     [Setup]  Set NTP state  ${True} | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 111 |  | 
| George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 112 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI} | 
 | 113 |     ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}} | 
| George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 114 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 115 |  | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 116 |     # NTP network take few seconds to reload. | 
 | 117 |     Wait Until Keyword Succeeds  30 sec  10 sec  Verify NTP Servers Are Populated | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 118 |  | 
 | 119 | Verify NTP Server Value Not Duplicated | 
 | 120 |     [Documentation]  Verify NTP servers value not same for both primary and secondary server. | 
 | 121 |     [Tags]  Verify_NTP_Server_Value_Not_Duplicated | 
 | 122 |  | 
| George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 123 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI} | 
 | 124 |     ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}} | 
| George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 125 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 126 |     ${network_protocol}=  Redfish.Get Properties  ${REDFISH_NW_PROTOCOL_URI} | 
 | 127 |     Should Contain X Times  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_1}  1 | 
| George Keishing | 1af70ef | 2019-06-11 09:31:10 -0500 | [diff] [blame] | 128 |     ...  msg=NTP primary and secondary server values should not be same. | 
| Sivas SRR | 62d22d0 | 2019-06-08 12:13:31 -0500 | [diff] [blame] | 129 |  | 
 | 130 |  | 
| Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 131 | Verify NTP Server Setting Persist After BMC Reboot | 
 | 132 |     [Documentation]  Verify NTP server setting persist after BMC reboot. | 
 | 133 |     [Tags]  Verify_NTP_Server_Setting_Persist_After_BMC_Reboot | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 134 |     [Setup]  Set NTP state  ${True} | 
| Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 135 |  | 
| George Keishing | 093c1bd | 2020-02-10 09:47:34 -0600 | [diff] [blame] | 136 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI} | 
 | 137 |     ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}} | 
| George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 138 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 139 |     Redfish OBMC Reboot (off) | 
 | 140 |     Redfish.Login | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 141 |  | 
 | 142 |     # NTP network take few seconds to reload. | 
 | 143 |     Wait Until Keyword Succeeds  30 sec  10 sec  Verify NTP Servers Are Populated | 
| Sivas SRR | aac72b0 | 2019-06-11 08:56:10 -0500 | [diff] [blame] | 144 |  | 
 | 145 |  | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 146 | Verify Enable NTP | 
 | 147 |     [Documentation]  Verify NTP protocol mode can be enabled. | 
 | 148 |     [Teardown]  Restore NTP Mode | 
 | 149 |     [Tags]  Verify_Enable_NTP | 
 | 150 |  | 
 | 151 |     ${original_ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP | 
 | 152 |     Set Suite Variable  ${original_ntp} | 
| Michael Walsh | 39c0051 | 2019-07-17 10:54:06 -0500 | [diff] [blame] | 153 |     Rprint Vars  original_ntp | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 154 |     # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True". | 
| George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 155 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${True}}} | 
 | 156 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| aravinth0510 | f031ca1 | 2022-06-16 12:47:33 +0000 | [diff] [blame] | 157 |     Wait Until Keyword Succeeds  30 sec  5 sec | 
 | 158 |     ...  Verify System Time Sync Status  ${True} | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 159 |     ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP | 
| Michael Walsh | 39c0051 | 2019-07-17 10:54:06 -0500 | [diff] [blame] | 160 |     Rprint Vars  ntp | 
| Michael Walsh | e7edb22 | 2019-08-19 17:39:38 -0500 | [diff] [blame] | 161 |     Valid Value  ntp["ProtocolEnabled"]  valid_values=[True] | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 162 |  | 
 | 163 |  | 
| Anusha Dathatri | 4ad9f43 | 2020-06-29 05:18:29 -0500 | [diff] [blame] | 164 | Verify Immediate Consumption Of BMC Date | 
 | 165 |     [Documentation]  Verify immediate change in BMC date time. | 
 | 166 |     [Tags]  Verify_Immediate_Consumption_Of_BMC_Date | 
 | 167 |     [Setup]  Run Keywords  Set Time To Manual Mode  AND | 
| Anusha Dathatri | ad6a3df | 2020-07-22 05:20:18 -0500 | [diff] [blame] | 168 |     ...  Redfish Set DateTime  valid_status_codes=[${HTTP_OK}] | 
| Anusha Dathatri | 4ad9f43 | 2020-06-29 05:18:29 -0500 | [diff] [blame] | 169 |     [Teardown]  Run Keywords  FFDC On Test Case Fail  AND | 
 | 170 |     ...  Redfish Set DateTime  valid_status_codes=[${HTTP_OK}] | 
 | 171 |     [Template]  Set BMC Date And Verify | 
 | 172 |  | 
 | 173 |     # host_state | 
 | 174 |     on | 
 | 175 |     off | 
 | 176 |  | 
 | 177 |  | 
| aravinth0510 | f031ca1 | 2022-06-16 12:47:33 +0000 | [diff] [blame] | 178 | Verify Set DateTime With NTP Enabled | 
 | 179 |     [Documentation]  Verify whether set managers dateTime is restricted with NTP enabled. | 
 | 180 |     [Tags]  Verify_Set_DateTime_With_NTP_Enabled | 
 | 181 |  | 
 | 182 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${True}}} | 
 | 183 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
 | 184 |     ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP | 
 | 185 |     Valid Value  ntp["ProtocolEnabled"]  valid_values=[True] | 
 | 186 |     ${local_system_time}=  Get Current Date | 
 | 187 |     Redfish Set DateTime  ${local_system_time} | 
 | 188 |     ...  valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}] | 
 | 189 |  | 
 | 190 |  | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 191 | *** Keywords *** | 
 | 192 |  | 
| Sivas SRR | 4d64599 | 2019-06-20 05:34:50 -0500 | [diff] [blame] | 193 |  | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 194 | Test Teardown Execution | 
 | 195 |     [Documentation]  Do the post test teardown. | 
 | 196 |  | 
 | 197 |     FFDC On Test Case Fail | 
| Sivas SRR | 0e3bc6d | 2019-04-23 08:36:35 -0500 | [diff] [blame] | 198 |  | 
 | 199 |  | 
 | 200 | Redfish Get DateTime | 
 | 201 |     [Documentation]  Returns BMC Datetime value from Redfish. | 
 | 202 |  | 
 | 203 |     ${date_time}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Managers/bmc  DateTime | 
 | 204 |     [Return]  ${date_time} | 
| Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 205 |  | 
 | 206 |  | 
 | 207 | Redfish Set DateTime | 
 | 208 |     [Documentation]  Set DateTime using Redfish. | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 209 |     [Arguments]  ${date_time}=${EMPTY}  &{kwargs} | 
| Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 210 |     # Description of argument(s): | 
| Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 211 |     # date_time                     New time to set for BMC (eg. | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 212 |     #                               "2019-06-30 09:21:28"). If this value is | 
 | 213 |     #                               empty, it will be set to the UTC current | 
 | 214 |     #                               date time of the local system. | 
| George Keishing | 7bc01e9 | 2021-06-15 11:07:14 -0500 | [diff] [blame] | 215 |     # kwargs                        Additional parameters to be passed directly to | 
| Sivas SRR | 3f152ae | 2019-06-07 10:02:51 -0500 | [diff] [blame] | 216 |     #                               th Redfish.Patch function.  A good use for | 
 | 217 |     #                               this is when testing a bad date-time, the | 
 | 218 |     #                               caller can specify | 
 | 219 |     #                               valid_status_codes=[${HTTP_BAD_REQUEST}]. | 
| Sivas SRR | 8a53dad | 2019-05-16 08:56:14 -0500 | [diff] [blame] | 220 |  | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 221 |     # Assign default value of UTC current date time if date_time is empty. | 
 | 222 |     ${date_time}=  Run Keyword If | 
 | 223 |     ...  '${date_time}' == '${EMPTY}'  Get Current Date  time_zone=UTC | 
 | 224 |     ...  ELSE | 
 | 225 |     ...  Set Variable  ${date_time} | 
| Anusha Dathatri | ad6a3df | 2020-07-22 05:20:18 -0500 | [diff] [blame] | 226 |     Wait Until Keyword Succeeds  1min  5sec | 
 | 227 |     ...  Redfish.Patch  ${REDFISH_BASE_URI}Managers/bmc  body={'DateTime': '${date_time}'}  &{kwargs} | 
| Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 228 |  | 
 | 229 |  | 
| Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 230 | Set Time To Manual Mode | 
| Anusha Dathatri | d1a7bf0 | 2021-09-15 03:04:45 -0500 | [diff] [blame] | 231 |     [Documentation]  Set date time to manual mode via Redfish. | 
| Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 232 |  | 
| Anusha Dathatri | d1a7bf0 | 2021-09-15 03:04:45 -0500 | [diff] [blame] | 233 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${False}}} | 
 | 234 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| Sushil Singh | 79b04aa | 2019-06-18 05:25:34 -0500 | [diff] [blame] | 235 |  | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 236 |  | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 237 | Restore NTP Mode | 
 | 238 |     [Documentation]  Restore the original NTP mode. | 
 | 239 |  | 
 | 240 |  | 
 | 241 |     Return From Keyword If  &{original_ntp} == &{EMPTY} | 
 | 242 |     Print Timen  Restore NTP Mode. | 
 | 243 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI} | 
| George Keishing | fa2840d | 2020-01-28 01:41:30 -0600 | [diff] [blame] | 244 |     ...  body={'NTP':{'ProtocolEnabled': ${original_ntp["ProtocolEnabled"]}}} | 
 | 245 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| Sivas SRR | 20fe032 | 2019-06-17 04:24:18 -0500 | [diff] [blame] | 246 |  | 
 | 247 |  | 
 | 248 | Suite Setup Execution | 
 | 249 |     [Documentation]  Do the suite level setup. | 
 | 250 |  | 
 | 251 |     Printn | 
 | 252 |     Redfish.Login | 
| Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 253 |     Get NTP Initial Status | 
| Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 254 |     Set Time To Manual Mode | 
| Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 255 |  | 
| George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 256 |  | 
 | 257 | Suite Teardown Execution | 
 | 258 |     [Documentation]  Do the suite level teardown. | 
| Sivas SRR | 9e00ff3 | 2019-07-18 10:38:44 -0500 | [diff] [blame] | 259 |  | 
| Sivas SRR | 64613ff | 2019-07-13 03:06:33 -0500 | [diff] [blame] | 260 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI} | 
| George Keishing | f05a103 | 2020-01-27 11:08:51 -0600 | [diff] [blame] | 261 |     ...  body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}} | 
 | 262 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
| Anusha Dathatri | 87e4e55 | 2020-05-28 07:02:42 -0500 | [diff] [blame] | 263 |     Set Time To Manual Mode | 
| Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 264 |     Restore NTP Status | 
| George Keishing | ade5f6e | 2019-07-12 11:42:42 -0500 | [diff] [blame] | 265 |     Redfish.Logout | 
| Tony Lee | 1082266 | 2020-05-12 14:53:35 +0800 | [diff] [blame] | 266 |  | 
 | 267 |  | 
 | 268 | Set NTP state | 
 | 269 |     [Documentation]  Set NTP service inactive. | 
 | 270 |     [Arguments]  ${state} | 
 | 271 |  | 
 | 272 |     Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${state}}} | 
 | 273 |     ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}] | 
 | 274 |  | 
 | 275 |  | 
 | 276 | Get NTP Initial Status | 
 | 277 |     [Documentation]  Get NTP service Status. | 
 | 278 |  | 
 | 279 |     ${original_ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP | 
 | 280 |     Set Suite Variable  ${original_ntp} | 
 | 281 |  | 
 | 282 |  | 
 | 283 | Restore NTP Status | 
 | 284 |     [Documentation]  Restore NTP Status. | 
 | 285 |  | 
 | 286 |     Run Keyword If  '${original_ntp["ProtocolEnabled"]}' == 'True' | 
 | 287 |     ...    Set NTP state  ${TRUE} | 
| Anusha Dathatri | 4ad9f43 | 2020-06-29 05:18:29 -0500 | [diff] [blame] | 288 |     ...  ELSE  Set NTP state  ${FALSE} | 
 | 289 |  | 
 | 290 |  | 
 | 291 | Set BMC Date And Verify | 
 | 292 |     [Documentation]  Set BMC Date Time at a given host state and verify. | 
 | 293 |     [Arguments]  ${host_state} | 
 | 294 |     # Description of argument(s): | 
 | 295 |     # host_state  Host state at which date time will be updated for verification | 
 | 296 |     #             (eg. on, off). | 
 | 297 |  | 
 | 298 |     Run Keyword If  '${host_state}' == 'on' | 
 | 299 |     ...    Redfish Power On  stack_mode=skip | 
 | 300 |     ...  ELSE | 
 | 301 |     ...    Redfish Power off  stack_mode=skip | 
 | 302 |     ${current_date}=  Get Current Date  time_zone=UTC | 
 | 303 |     ${new_value}=  Subtract Time From Date  ${current_date}  1 day | 
 | 304 |     Redfish Set DateTime  ${new_value}  valid_status_codes=[${HTTP_OK}] | 
 | 305 |     ${current_value}=  Redfish Get DateTime | 
 | 306 |     ${time_diff}=  Subtract Date From Date  ${current_value}  ${new_value} | 
 | 307 |     Should Be True  '${time_diff}'<='3' | 
| George Keishing | 5c7318d | 2022-07-07 12:46:00 -0500 | [diff] [blame] | 308 |  | 
 | 309 | Verify NTP Servers Are Populated | 
 | 310 |     [Documentation]  Redfish GET request /redfish/v1/Managers/bmc/NetworkProtocol response | 
 | 311 |     ...              and verify if NTP servers are populated. | 
 | 312 |  | 
 | 313 |     ${network_protocol}=  Redfish.Get Properties  ${REDFISH_NW_PROTOCOL_URI} | 
 | 314 |     Should Contain  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_1} | 
 | 315 |     ...  msg=NTP server value ${ntp_server_1} not stored. | 
 | 316 |     Should Contain  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_2} | 
 | 317 |     ...  msg=NTP server value ${ntp_server_2} not stored. | 
 | 318 |  | 
| aravinth0510 | f031ca1 | 2022-06-16 12:47:33 +0000 | [diff] [blame] | 319 |  | 
 | 320 | Verify System Time Sync Status | 
 | 321 |     [Documentation]  Verify the status of service systemd-timesyncd matches the NTP protocol enabled state. | 
 | 322 |     [Arguments]  ${expected_sync_status}=${True} | 
 | 323 |  | 
 | 324 |     # Description of argument(s): | 
 | 325 |     # expected_sync_status  expected status at which NTP protocol enabled will be updated for verification | 
 | 326 |     #                       (eg. True, False). | 
 | 327 |  | 
 | 328 |     ${resp}=  BMC Execute Command | 
 | 329 |     ...  systemctl status systemd-timesyncd | 
 | 330 |     ...  ignore_err=${1} | 
 | 331 |     ${sync_status}=  Get Lines Matching Regexp  ${resp[0]}  .*Active.* | 
 | 332 |     Run Keyword If  ${expected_sync_status}==${True} | 
 | 333 |     ...  Should Contain  ${sync_status}  active (running) | 
 | 334 |     Run Keyword If  ${expected_sync_status}==${False} | 
 | 335 |     ...  Should Contain  ${sync_status}  inactive (dead) |