Clear leftover network settings.

Resolves openbmc/openbmc-test-automation#1802

Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
Change-Id: Id633266f1b80961e61fe27d67a86bac842d73d0a
diff --git a/redfish/managers/test_bmc_network_conf.robot b/redfish/managers/test_bmc_network_conf.robot
index b17d03e..1a6cd01 100644
--- a/redfish/managers/test_bmc_network_conf.robot
+++ b/redfish/managers/test_bmc_network_conf.robot
@@ -117,6 +117,8 @@
     # ip             subnet_mask          gateway          valid_status_codes
     ${broadcast_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
 
+    [Teardown]  Clear IP Settings On Fail  ${broadcast_ip}
+
 Configure Multicast IP
     [Documentation]  Configure multicast IP address.
     [Tags]  Configure_Multicast_IP
@@ -125,6 +127,8 @@
     # ip             subnet_mask          gateway          valid_status_codes
     ${multicast_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
 
+    [Teardown]  Clear IP Settings On Fail  ${multicast_ip}
+
 Configure Loopback IP
     [Documentation]  Configure loopback IP address.
     [Tags]  Configure_Loopback_IP
@@ -133,6 +137,8 @@
     # ip            subnet_mask          gateway          valid_status_codes
     ${loopback_ip}  ${test_subnet_mask}  ${test_gateway}  ${HTTP_BAD_REQUEST}
 
+    [Teardown]  Clear IP Settings On Fail  ${loopback_ip}
+
 Add Valid IPv4 Address And Check Persistency
     [Documentation]  Add IPv4 address and check peristency.
     [Tags]  Add_Valid_IPv4_Addres_And_Check_Persistency
@@ -461,3 +467,15 @@
 
     FFDC On Test Case Fail
     Redfish.Logout
+
+Clear IP Settings On Fail
+    [Documentation]  Clear IP settings on fail.
+    [Arguments]  ${ip}
+
+    # Description of argument(s):
+    # ip  IP address to be deleted.
+
+    Run Keyword If  '${TEST STATUS}' == 'FAIL'
+    ...  Delete IP Address  ${ip}
+
+    Test Teardown Execution