Modified TestTeardown and added new keyword to check ip via redfish.

Added validation to check configured hostname via redfish.

Removed "Delete IP Address" on testcase and added in teardown for
testcase "Add Valid IPv4 Address And Check Persistency"

added keyword " Verify IP On Redfish URI" to check ip address via redfish.

Tested: Run robot redfish/managers/test_bmc_network_conf.robot

Signed-off-by: Nagarjun B  <nagarjunb@ami.com>
Change-Id: Ia2bca444b14e230c4229afadcb77c30c6fda8c7b
diff --git a/redfish/managers/test_bmc_network_conf.robot b/redfish/managers/test_bmc_network_conf.robot
index 60b678d..48cee49 100644
--- a/redfish/managers/test_bmc_network_conf.robot
+++ b/redfish/managers/test_bmc_network_conf.robot
@@ -117,6 +117,10 @@
     Configure Hostname  ${test_hostname}
     Validate Hostname On BMC  ${test_hostname}
 
+    # Verify configured hostname via redfish.
+    ${new_hostname}=  Redfish_Utils.Get Attribute  ${REDFISH_NW_PROTOCOL_URI}  HostName
+    Should Be Equal  ${new_hostname}  ${test_hostname}
+
 
 Add Valid IPv4 Address And Verify
     [Documentation]  Add IPv4 Address via Redfish and verify.
@@ -169,8 +173,10 @@
     ${loopback_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
 
 Add Valid IPv4 Address And Check Persistency
-    [Documentation]  Add IPv4 address and check peristency.
+    [Documentation]  Add IPv4 address and check persistency.
     [Tags]  Add_Valid_IPv4_Address_And_Check_Persistency
+    [Teardown]  Run Keywords
+    ...  Delete IP Address  ${test_ipv4_addr}  AND  Test Teardown Execution
 
     Add IP Address  ${test_ipv4_addr}  ${test_subnet_mask}  ${test_gateway}
 
@@ -178,7 +184,8 @@
     OBMC Reboot (off)
     Redfish.Login
     Verify IP On BMC  ${test_ipv4_addr}
-    Delete IP Address  ${test_ipv4_addr}
+    Verify IP On Redfish URI  ${test_ipv4_addr}
+
 
 Add Fourth Octet Threshold IP And Verify
     [Documentation]  Add fourth octet threshold IP and verify.
@@ -537,6 +544,7 @@
     Redfish.Login
     FOR  ${ip}  IN  @{test_ipv4_addresses}
       Verify IP And Netmask On BMC  ${ip}  ${test_subnet_mask}
+      Verify IP On Redfish URI  ${ip}
     END
 
 
@@ -857,3 +865,20 @@
     Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
     Ping Host  ${OPENBMC_HOST}
 
+
+Verify IP On Redfish URI
+    [Documentation]  Verify given IP on redfish URI.
+    [Arguments]  ${ip_address}
+
+    # Description of argument(s):
+    # ip_address   Configured IP address which need to verified.
+
+    ${network_configurations}=  Get Network Configuration
+
+    FOR  ${network_configuration}  IN  @{network_configurations}
+        ${ip_found}=  Set Variable If  '${network_configuration['Address']}' == '${ip_address}'  ${True}
+        ...  ${False}
+        Exit For Loop If  ${ip_found}
+    END
+    Run Keyword If  '${ip_found}' == '${False}'
+    ...  Fail  msg=Configured IP address not found on EthernetInterface URI.