openbmctool network testing- IP configuration

Resolve openbmc/openbmc-test-automation#1896

Change-Id: I2d9eb56dac7e16757e5cae335d7e5aa16a6a52c9
Signed-off-by: Naman Navin Hegde <nhegde89@in.ibm.com>
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
index b044612..9b3605f 100644
--- a/lib/bmc_network_utils.robot
+++ b/lib/bmc_network_utils.robot
@@ -257,3 +257,61 @@
     ${data}=  Create Dictionary  HostName=${hostname}
     Redfish.patch  ${REDFISH_NW_PROTOCOL_URI}  body=&{data}
 
+
+Verify IP On BMC
+    [Documentation]  Verify IP on BMC.
+    [Arguments]  ${ip}
+
+    # Description of argument(s):
+    # ip  IP address to be verified (e.g. "10.7.7.7").
+
+    # Get IP address details on BMC using IP command.
+    @{ip_data}=  Get BMC IP Info
+    Should Contain Match  ${ip_data}  ${ip}/*
+    ...  msg=IP address does not exist.
+
+
+Verify Gateway On BMC
+    [Documentation]  Verify gateway on BMC.
+    [Arguments]  ${gateway_ip}=0.0.0.0
+
+    # Description of argument(s):
+    # gateway_ip  Gateway IP address.
+
+    ${route_info}=  Get BMC Route Info
+
+    # If gateway IP is empty or 0.0.0.0 it will not have route entry.
+
+    Run Keyword If  '${gateway_ip}' == '0.0.0.0'
+    ...      Pass Execution  Gateway IP is "0.0.0.0".
+    ...  ELSE
+    ...      Should Contain  ${route_info}  ${gateway_ip}
+    ...      msg=Gateway IP address not matching.
+
+
+Get BMC DNS Info
+    [Documentation]  Get system DNS info.
+
+
+    # Sample output of "resolv.conf":
+    # ### Generated manually via dbus settings ###
+    # nameserver 8.8.8.8
+
+    ${cmd_output}  ${stderr}  ${rc}=  BMC Execute Command
+    ...  cat /etc/resolv.conf
+
+    [Return]  ${cmd_output}
+
+
+CLI Get Nameservers
+    [Documentation]  Get the nameserver IPs from /etc/resolv.conf and return as a list.
+
+    # Example of /etc/resolv.conf data:
+    # nameserver x.x.x.x
+    # nameserver y.y.y.y
+
+    ${stdout}  ${stderr}  ${rc}=  BMC Execute Command  egrep nameserver /etc/resolv.conf | cut -f2- -d ' '
+    ${nameservers}=  Split String  ${stdout}
+
+    [Return]  ${nameservers}
+