Separating network protocol and Manual date time Testcases

   Changes:
      - Separated test suites based on manual date, time, and NTP.

   Tested:
     - Ran and tested on BMC Environment.

Change-Id: I5edca932207df0c5060f7e59a4be0adb179e7b1d
Signed-off-by: Anvesh-Kumar_Rayankula <anvesh.kumar.rayankula@ibm.com>
diff --git a/redfish/managers/test_managers_bmc_time.robot b/redfish/managers/test_managers_bmc_time.robot
index 9671542..ff32078 100644
--- a/redfish/managers/test_managers_bmc_time.robot
+++ b/redfish/managers/test_managers_bmc_time.robot
@@ -1,12 +1,7 @@
 *** Settings ***
 Documentation    Test BMC manager time functionality.
-Resource                     ../../lib/resource.robot
-Resource                     ../../lib/bmc_redfish_resource.robot
-Resource                     ../../lib/common_utils.robot
 Resource                     ../../lib/openbmc_ffdc.robot
-Resource                     ../../lib/utils.robot
-Resource                     ../../lib/rest_client.robot
-Library                      ../../lib/gen_robot_valid.py
+Resource                     ../../lib/bmc_date_and_time_utils.robot
 
 Test Setup                   Printn
 Test Teardown                Test Teardown Execution
@@ -23,10 +18,6 @@
 ${date_time_with_offset}     2019-04-25T26:24:46+00:00
 ${expected_date_time}        2019-04-26T02:24:46+00:00
 ${invalid_datetime}          "2019-04-251T12:24:46+00:00"
-${ntp_server_1}              9.9.9.9
-${ntp_server_2}              2.2.3.3
-&{original_ntp}              &{EMPTY}
-${year_without_ntp}          1970
 
 *** Test Cases ***
 
@@ -108,63 +99,6 @@
     ...  The difference between Redfish time and CLI time exceeds the allowed time difference.
 
 
-Verify NTP Server Set
-    [Documentation]  Patch NTP servers and verify NTP servers is set.
-    [Tags]  Verify_NTP_Server_Set
-    [Setup]  Set NTP state  ${True}
-
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
-    ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-
-    # NTP network take few seconds to reload.
-    Wait Until Keyword Succeeds  30 sec  10 sec  Verify NTP Servers Are Populated
-
-Verify NTP Server Value Not Duplicated
-    [Documentation]  Verify NTP servers value not same for both primary and secondary server.
-    [Tags]  Verify_NTP_Server_Value_Not_Duplicated
-
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
-    ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_1}']}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-    ${network_protocol}=  Redfish.Get Properties  ${REDFISH_NW_PROTOCOL_URI}
-    Should Contain X Times  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_1}  1
-    ...  msg=NTP primary and secondary server values should not be same.
-
-
-Verify NTP Server Setting Persist After BMC Reboot
-    [Documentation]  Verify NTP server setting persist after BMC reboot.
-    [Tags]  Verify_NTP_Server_Setting_Persist_After_BMC_Reboot
-    [Setup]  Set NTP state  ${True}
-
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
-    ...  body={'NTP':{'NTPServers': ['${ntp_server_1}', '${ntp_server_2}']}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-    Redfish OBMC Reboot (off)
-    Redfish.Login
-
-    # NTP network take few seconds to reload.
-    Wait Until Keyword Succeeds  30 sec  10 sec  Verify NTP Servers Are Populated
-
-
-Verify Enable NTP
-    [Documentation]  Verify NTP protocol mode can be enabled.
-    [Teardown]  Restore NTP Mode
-    [Tags]  Verify_Enable_NTP
-
-    ${original_ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
-    Set Suite Variable  ${original_ntp}
-    Rprint Vars  original_ntp
-    # The following patch command should set the ["NTP"]["ProtocolEnabled"] property to "True".
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${True}}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-    Wait Until Keyword Succeeds  1 min  5 sec
-    ...  Verify System Time Sync Status  ${True}
-    ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
-    Rprint Vars  ntp
-    Valid Value  ntp["ProtocolEnabled"]  valid_values=[True]
-
-
 Verify Immediate Consumption Of BMC Date
     [Documentation]  Verify immediate change in BMC date time.
     [Tags]  Verify_Immediate_Consumption_Of_BMC_Date
@@ -179,18 +113,6 @@
     off
 
 
-Verify Set DateTime With NTP Enabled
-    [Documentation]  Verify whether set managers dateTime is restricted with NTP enabled.
-    [Tags]  Verify_Set_DateTime_With_NTP_Enabled
-
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${True}}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-    ${ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
-    Valid Value  ntp["ProtocolEnabled"]  valid_values=[True]
-    ${local_system_time}=  Get Current Date
-    Redfish Set DateTime  ${local_system_time}
-    ...  valid_status_codes=[${HTTP_BAD_REQUEST}, ${HTTP_INTERNAL_SERVER_ERROR}]
-
 
 *** Keywords ***
 
@@ -201,54 +123,6 @@
     FFDC On Test Case Fail
 
 
-Redfish Get DateTime
-    [Documentation]  Returns BMC Datetime value from Redfish.
-
-    ${date_time}=  Redfish.Get Attribute  ${REDFISH_BASE_URI}Managers/${MANAGER_ID}  DateTime
-    RETURN  ${date_time}
-
-
-Redfish Set DateTime
-    [Documentation]  Set DateTime using Redfish.
-    [Arguments]  ${date_time}=${EMPTY}  &{kwargs}
-    # Description of argument(s):
-    # date_time                     New time to set for BMC (eg.
-    #                               "2019-06-30 09:21:28"). If this value is
-    #                               empty, it will be set to the UTC current
-    #                               date time of the local system.
-    # kwargs                        Additional parameters to be passed directly to
-    #                               th Redfish.Patch function.  A good use for
-    #                               this is when testing a bad date-time, the
-    #                               caller can specify
-    #                               valid_status_codes=[${HTTP_BAD_REQUEST}].
-
-    # Assign default value of UTC current date time if date_time is empty.
-    ${date_time}=  Run Keyword If
-    ...  '${date_time}' == '${EMPTY}'  Get Current Date  time_zone=UTC
-    ...  ELSE
-    ...  Set Variable  ${date_time}
-    Wait Until Keyword Succeeds  1min  5sec
-    ...  Redfish.Patch  ${REDFISH_BASE_URI}Managers/${MANAGER_ID}  body={'DateTime': '${date_time}'}  &{kwargs}
-
-
-Set Time To Manual Mode
-    [Documentation]  Set date time to manual mode via Redfish.
-
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${False}}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-
-
-Restore NTP Mode
-    [Documentation]  Restore the original NTP mode.
-
-
-    Return From Keyword If  &{original_ntp} == &{EMPTY}
-    Print Timen  Restore NTP Mode.
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
-    ...  body={'NTP':{'ProtocolEnabled': ${original_ntp["ProtocolEnabled"]}}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-
-
 Suite Setup Execution
     [Documentation]  Do the suite level setup.
 
@@ -265,95 +139,6 @@
 Suite Teardown Execution
     [Documentation]  Do the suite level teardown.
 
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}
-    ...  body={'NTP':{'NTPServers': ['${EMPTY}', '${EMPTY}']}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
     Set Time To Manual Mode
     Restore NTP Status
     Redfish.Logout
-
-
-Set NTP state
-    [Documentation]  Set NTP service inactive.
-    [Arguments]  ${state}
-
-    Redfish.Patch  ${REDFISH_NW_PROTOCOL_URI}  body={'NTP':{'ProtocolEnabled': ${state}}}
-    ...  valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
-
-
-Get NTP Initial Status
-    [Documentation]  Get NTP service Status.
-
-    ${original_ntp}=  Redfish.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  NTP
-    Set Suite Variable  ${original_ntp}
-
-
-Restore NTP Status
-    [Documentation]  Restore NTP Status.
-
-    Run Keyword If  '${original_ntp["ProtocolEnabled"]}' == 'True'
-    ...    Set NTP state  ${TRUE}
-    ...  ELSE  Set NTP state  ${FALSE}
-
-
-Set BMC Date And Verify
-    [Documentation]  Set BMC Date Time at a given host state and verify.
-    [Arguments]  ${host_state}
-    # Description of argument(s):
-    # host_state  Host state at which date time will be updated for verification
-    #             (eg. on, off).
-
-    Run Keyword If  '${host_state}' == 'on'
-    ...    Redfish Power On  stack_mode=skip
-    ...  ELSE
-    ...    Redfish Power off  stack_mode=skip
-    ${current_date}=  Get Current Date  time_zone=UTC
-    ${new_value}=  Subtract Time From Date  ${current_date}  1 day
-    Redfish Set DateTime  ${new_value}  valid_status_codes=[${HTTP_OK}]
-    ${current_value}=  Redfish Get DateTime
-    ${time_diff}=  Subtract Date From Date  ${current_value}  ${new_value}
-    Should Be True  '${time_diff}'<='3'
-
-Verify NTP Servers Are Populated
-    [Documentation]  Redfish GET request /redfish/v1/Managers/${MANAGER_ID}/NetworkProtocol response
-    ...              and verify if NTP servers are populated.
-
-    ${network_protocol}=  Redfish.Get Properties  ${REDFISH_NW_PROTOCOL_URI}
-    Should Contain  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_1}
-    ...  msg=NTP server value ${ntp_server_1} not stored.
-    Should Contain  ${network_protocol["NTP"]["NTPServers"]}  ${ntp_server_2}
-    ...  msg=NTP server value ${ntp_server_2} not stored.
-
-
-Verify System Time Sync Status
-    [Documentation]  Verify the status of service systemd-timesyncd matches the NTP protocol enabled state.
-    [Arguments]  ${expected_sync_status}=${True}
-
-    # Description of argument(s):
-    # expected_sync_status  expected status at which NTP protocol enabled will be updated for verification
-    #                       (eg. True, False).
-
-    ${resp}=  BMC Execute Command
-    ...  systemctl status systemd-timesyncd
-    ...  ignore_err=${1}
-    ${sync_status}=  Get Lines Matching Regexp  ${resp[0]}  .*Active.*
-    Run Keyword If  ${expected_sync_status}==${True}
-    ...  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}