Automation fix for Network sub menu

Changes:
    - Modified "Delete DNS Servers And Verify" keyword
    - Modified "Add DNS Servers And Verify"
    - Removed "DNS Test Setup Execution" keyword from
      redfish/managers/test_bmc_network_conf.robot
      and added in lib/bmc_network_utils.robot

Tested:
    - Ran successfully
      gui/gui_test/settings_menu
      /test_network_sub_menu.robot
      gui/lib/gui_resource.robot
      lib/bmc_network_utils.robot
      redfish/managers/test_bmc_network_conf.robot

Change-Id: I6ffcb7aba29312fa1e4cc843453bca49cd44d0f1
Signed-off-by: Megha G N <Megha.G.N@ibm.com>
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
index d321543..f43aece 100644
--- a/lib/bmc_network_utils.robot
+++ b/lib/bmc_network_utils.robot
@@ -854,3 +854,62 @@
         ${subnetmask}=  Set Variable  ${resp['SubnetMask']}
         Return From Keyword  ${ip_addr}  ${gateway}  ${subnetmask}
     END
+
+
+DNS Test Setup Execution
+    [Documentation]  Do DNS test setup execution.
+
+    Redfish.Login
+
+    ${active_channel_config}=  Get Active Channel Config
+    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
+
+    ${original_nameservers}=  Redfish.Get Attribute
+    ...  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}  StaticNameServers
+
+    Rprint Vars  original_nameservers
+    # Set suite variables to trigger restoration during teardown.
+    Set Suite Variable  ${original_nameservers}
+
+
+Delete Static Name Servers
+    [Documentation]  Delete static name servers.
+
+    DNS Test Setup Execution
+    Configure Static Name Servers  static_name_servers=@{EMPTY}
+
+    # Check if all name servers deleted on BMC.
+    ${nameservers}=  CLI Get Nameservers
+    Should Not Contain  ${nameservers}  ${original_nameservers}
+
+    DNS Test Setup Execution
+
+    Should Be Empty  ${original_nameservers}
+
+
+Configure Static Name Servers
+    [Documentation]  Configure DNS server on BMC.
+    [Arguments]  ${static_name_servers}=${original_nameservers}
+     ...  ${valid_status_codes}=${HTTP_OK}
+
+    # Description of the argument(s):
+    # static_name_servers  A list of static name server IPs to be
+    #                      configured on the BMC.
+
+    ${active_channel_config}=  Get Active Channel Config
+    ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
+
+    ${type} =  Evaluate  type($static_name_servers).__name__
+    ${static_name_servers}=  Set Variable If  '${type}'=='str'
+    ...  '${static_name_servers}'  ${static_name_servers}
+
+    # Currently BMC is sending 500 response code instead of 400 for invalid scenarios.
+    Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
+    ...  body={'StaticNameServers': ${static_name_servers}}
+    ...  valid_status_codes=[${valid_status_codes}, ${HTTP_INTERNAL_SERVER_ERROR}]
+
+    # Patch operation takes 1 to 3 seconds to set new value.
+    Sleep  3s
+
+    # Check if newly added DNS server is configured on BMC.
+    CLI Get and Verify Name Servers  ${static_name_servers}  ${HTTP_OK}