Enable host quiesced check at the end of test case.

This change includes:
  - Collect FFDC and fails test case if host reaches
    quiesced at the end of test case run.
  - Also recovers host from quiesce state.

Resolves openbmc/openbmc-test-automation#322

Change-Id: I721730ee8f325d833333787e31e4c15b16a13ce8
Signed-off-by: Rahul Maheshwari <rahulmaheshwari@in.ibm.com>
diff --git a/lib/openbmc_ffdc.robot b/lib/openbmc_ffdc.robot
index cf90cc4..f5596b0 100755
--- a/lib/openbmc_ffdc.robot
+++ b/lib/openbmc_ffdc.robot
@@ -37,13 +37,16 @@
 FFDC On Test Case Fail
     [Documentation]   Generic FFDC entry point. Place holder to hook in
     ...               other data collection methods
-    ...               1. Collect Logs if test fails
-    ...               2. Added Test execution history logging
+    ...               1. Collect Logs if test fails or host reaches quiesced
+    ...                  state.
+    ...               2. Recover host from quiesced state
+    ...               3. Added Test execution history logging
     ...                  By default this will log Test status PASS/FAIL format
     ...                  EX: 20160822041250932049:Test:Test case 1:PASS
     ...                      20160822041250969913:Test:Test case 2:FAIL
 
-    Run Keyword If  '${TEST_STATUS}' == 'FAIL'
-    ...    FFDC
+    ${status}=  Is Host Quiesced
+    Run Keyword If  '${TEST_STATUS}' == 'FAIL' or '${status}'=='True'  FFDC
+    Run Keyword If  '${status}'=='True'  Recover Quiesced Host
 
     Log Test Case Status
diff --git a/lib/state_manager.robot b/lib/state_manager.robot
index 440bc48..3fe83de 100755
--- a/lib/state_manager.robot
+++ b/lib/state_manager.robot
@@ -82,6 +82,15 @@
     [Return]  ${status}
 
 
+Recover Quiesced Host
+    [Documentation]  Recover host from quisced state.
+
+    ${resp}=  Run Keyword And Return Status  Is Host Quiesced
+    Run Keyword If  '${resp}' == 'True'
+    ...  Run Keywords  Initiate Host PowerOff  AND
+    ...  Log  HOST is recovered from quiesced state
+
+
 Get Host State
     [Documentation]  Return the state of the host as a string.
     [Arguments]  ${quiet}=${QUIET}