Redfish NTP: Handled code to add ntp address and enable ntp if bmc time was 1970
Changes:
- In suite setup, add code to handle if bmc date was in 1970 ntp will be enabled
and ntp address will be added.
- If bmc date was not in 1970, it will continue for test execution.
- Added ${NTP_ADDRESSES} variable in lib/resource.robot to get ntp addresses as an list.
Tested:
- Ran All The Scripts Successfully
Change-Id: Ifcfdc9bf87c46150a628a537fee05de083200c6e
Signed-off-by: ganesanb <ganesanb@ami.com>
diff --git a/lib/resource.robot b/lib/resource.robot
index 4624d7e..7bbda8c 100755
--- a/lib/resource.robot
+++ b/lib/resource.robot
@@ -159,6 +159,14 @@
# FFDC_DEFAULT == 1; use Default FFDC methods
${FFDC_DEFAULT} ${1}
+# NTP Server Address
+# NTP Address needs to be given as an list.
+# For example,
+# 1 NTP Address - 14.139.60.103
+# 2 NTP Address - 14.139.60.103 14.139.60.106
+@{NTP_SERVER_ADDRESSES} ${EMPTY}
+
+
*** Keywords ***
Get Inventory Schema
[Documentation] Get inventory schema.
diff --git a/redfish/managers/test_managers_bmc_time.robot b/redfish/managers/test_managers_bmc_time.robot
index 6be2fa7..eea7496 100644
--- a/redfish/managers/test_managers_bmc_time.robot
+++ b/redfish/managers/test_managers_bmc_time.robot
@@ -23,6 +23,7 @@
${ntp_server_1} 9.9.9.9
${ntp_server_2} 2.2.3.3
&{original_ntp} &{EMPTY}
+${year_without_ntp} 1970
*** Test Cases ***
@@ -251,6 +252,10 @@
Printn
Redfish.Login
Get NTP Initial Status
+ ${old_date_time}= CLI Get BMC DateTime
+ ${year_status}= Run Keyword And Return Status Should Not Contain ${old_date_time} ${year_without_ntp}
+ Run Keyword If ${year_status} == False
+ ... Enable NTP And Add NTP Address
Set Time To Manual Mode
@@ -333,3 +338,19 @@
... Should Contain ${sync_status} active (running)
Run Keyword If ${expected_sync_status}==${False}
... Should Contain ${sync_status} inactive (dead)
+
+Enable NTP And Add NTP Address
+ [Documentation] Enable NTP Protocol and Add NTP Address.
+
+ Set NTP state ${TRUE}
+
+ Redfish.Patch ${REDFISH_NW_PROTOCOL_URI} body={'NTP':{'NTPServers': ${NTP_SERVER_ADDRESSES}}}
+ ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
+
+ Wait Until Keyword Succeeds 1 min 10 sec Check Date And Time Was Changed
+
+Check Date And Time Was Changed
+ [Documentation] Verify date was current date and time.
+
+ ${new_date_time}= CLI Get BMC DateTime
+ Should Not Contain ${new_date_time} ${year_without_ntp}