[VOL-4494] Added keyword Clean Up All Nodes to kill stale lxc processes in Suite Teardown

Change-Id: I44f0d1a070f9db8f8b8e88b0c4dafa141aabdd7c
diff --git a/libraries/utils.robot b/libraries/utils.robot
index 8aa74c0..a6345a9 100755
--- a/libraries/utils.robot
+++ b/libraries/utils.robot
@@ -734,9 +734,11 @@
 Teardown Suite
     [Documentation]    Clean up device if desired
     Start Logging Setup or Teardown  Teardown-${SUITE NAME}
+    Run Keyword If    ${has_dataplane}    Clean Up Linux
     Run Keyword If    ${teardown_device}    Delete All Devices and Verify
     Run Keyword And Continue On Failure    Collect Logs
     Close All ONOS SSH Connections
+    Run Keyword If    ${has_dataplane}    Clean Up All Nodes
     Stop Logging Setup or Teardown    Teardown-${SUITE NAME}
 
 Delete Device and Verify
@@ -1543,3 +1545,15 @@
     ${result}=    Exec Pod In Kube    ${namespace}    ${podname}    ${commandget}
     Log    ${result}
     Should Be Empty    ${result}    Stale Resource Manager Data in Etcd!
+
+
+Clean Up All Nodes
+    [Documentation]    Login to each node and kill all stale lxc prcoesses
+    ${num_nodes}=    Get Length    ${nodes}
+    FOR    ${I}    IN RANGE    0    ${num_nodes}
+        ${node_ip}=    Evaluate    ${nodes}[${I}].get("ip")
+        ${node_user}=    Evaluate    ${nodes}[${I}].get("user")
+        ${node_pass}=    Evaluate    ${nodes}[${I}].get("pass")
+        Run Keyword And Continue On Failure    Start Remote Command    kill -9 `pidof lxc`
+        ...    ${node_ip}    ${node_user}    ${node_pass}
+    END
diff --git a/tests/functional/Voltha_AlarmTests.robot b/tests/functional/Voltha_AlarmTests.robot
index e4ab03a..48520c9 100755
--- a/tests/functional/Voltha_AlarmTests.robot
+++ b/tests/functional/Voltha_AlarmTests.robot
@@ -380,6 +380,7 @@
     Run Keyword If    ${teardown_device}    Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
     ...    device-remove ${of_id}
     Close All ONOS SSH Connections
+    Run Keyword If    ${has_dataplane}    Clean Up All Nodes
 
 # Onu Alarms
 
diff --git a/tests/functional/Voltha_ErrorScenarios.robot b/tests/functional/Voltha_ErrorScenarios.robot
index dd60016..f2e446a 100755
--- a/tests/functional/Voltha_ErrorScenarios.robot
+++ b/tests/functional/Voltha_ErrorScenarios.robot
@@ -332,3 +332,4 @@
     #Restore all ONUs
 #    Run Keyword If    ${has_dataplane}    RestoreONUs    ${num_onus}
     Close All ONOS SSH Connections
+    Run Keyword If    ${has_dataplane}    Clean Up All Nodes
diff --git a/tests/functional/Voltha_FailureScenarios.robot b/tests/functional/Voltha_FailureScenarios.robot
index ce81521..58bbbbf 100755
--- a/tests/functional/Voltha_FailureScenarios.robot
+++ b/tests/functional/Voltha_FailureScenarios.robot
@@ -815,3 +815,4 @@
 Teardown Suite
     [Documentation]    Clean up ONOS SSH connections
     Close All ONOS SSH Connections
+    Run Keyword If    ${has_dataplane}    Clean Up All Nodes
diff --git a/tests/functional/Voltha_MultiOLT_Tests.robot b/tests/functional/Voltha_MultiOLT_Tests.robot
index 767b5f7..0a97bc2 100755
--- a/tests/functional/Voltha_MultiOLT_Tests.robot
+++ b/tests/functional/Voltha_MultiOLT_Tests.robot
@@ -211,3 +211,4 @@
 Teardown Suite
     [Documentation]    Clean up ONOS SSH connections
     Close All ONOS SSH Connections
+    Run Keyword If    ${has_dataplane}    Clean Up All Nodes
diff --git a/tests/functional/Voltha_ScaleFunctionalTests.robot b/tests/functional/Voltha_ScaleFunctionalTests.robot
index 58e6a8e..709336e 100755
--- a/tests/functional/Voltha_ScaleFunctionalTests.robot
+++ b/tests/functional/Voltha_ScaleFunctionalTests.robot
@@ -196,6 +196,7 @@
     Run Keyword If    ${teardown_device}    Execute ONOS CLI Command use single connection    ${ONOS_SSH_IP}    ${ONOS_SSH_PORT}
     ...    device-remove ${of_id}
     Close All ONOS SSH Connections
+    Run Keyword If    ${has_dataplane}    Clean Up All Nodes
 
 Clean Up Linux
     [Documentation]    Kill processes and clean up interfaces on src+dst servers
diff --git a/tests/tt-workflow/Voltha_TT_FailureScenarios.robot b/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
index 9651d01..7009844 100755
--- a/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
+++ b/tests/tt-workflow/Voltha_TT_FailureScenarios.robot
@@ -646,12 +646,6 @@
     ${switch_type}=    Get Variable Value    ${web_power_switch.type}
     Run Keyword If  "${switch_type}"!=""    Set Global Variable    ${powerswitch_type}    ${switch_type}
 
-Teardown Suite
-    [Documentation]    Tear down steps for the suite
-    Run Keyword If    ${has_dataplane}    Clean Up Linux
-    Run Keyword If    ${teardown_device}    Delete All Devices and Verify
-    Close All ONOS SSH Connections
-
 Clear All Devices Then Create New Device
     [Documentation]    Remove any devices from VOLTHA and ONOS & then Create new devices
     # Remove all devices from voltha and onos
diff --git a/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot b/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot
index f3c3b97..2874a82 100755
--- a/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot
+++ b/tests/tt-workflow/Voltha_TT_MultiTcontTests.robot
@@ -579,10 +579,3 @@
     Delete All Devices and Verify
     # Execute normal test Setup Keyword
     Setup
-
-
-Teardown Suite
-    [Documentation]    Tear down steps for the suite
-    Run Keyword If    ${has_dataplane}    Clean Up Linux
-    Run Keyword If    ${teardown_device}    Delete All Devices And Verify
-    Close All ONOS SSH Connections
diff --git a/tests/tt-workflow/Voltha_TT_MulticastTests.robot b/tests/tt-workflow/Voltha_TT_MulticastTests.robot
index a9536b1..12483d4 100644
--- a/tests/tt-workflow/Voltha_TT_MulticastTests.robot
+++ b/tests/tt-workflow/Voltha_TT_MulticastTests.robot
@@ -311,9 +311,3 @@
     Delete All Devices and Verify
     # Execute normal test Setup Keyword
     Setup
-
-Teardown Suite
-    [Documentation]    Tear down steps for the suite
-    Run Keyword If    ${has_dataplane}    Clean Up Linux
-    Run Keyword If    ${teardown_device}    Delete All Devices And Verify
-    Close All ONOS SSH Connections