RAS: Disable CPU states through HOST.

Resolves openbmc/openbmc-test-automation#1298

Change-Id: I6bdbc9127e36e5668423f442dca885234d6de3e5
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/lib/ras/host_utils.robot b/lib/ras/host_utils.robot
index 9ab425e..aeda08b 100644
--- a/lib/ras/host_utils.robot
+++ b/lib/ras/host_utils.robot
@@ -136,6 +136,13 @@
 Disable CPU States Through HOST
     [Documentation]  Disable CPU states through host.
 
-    ${cmd}=  Catenate  SEPARATOR=  for file_path in /sys/devices/system/cpu/
-    ...  cpu*/cpuidle/state*/disable; do echo 0 > $file_path; done
+    # Fetch number of states present for cpu0.
+    ${cmd}=  Catenate  ls /sys/devices/system/cpu/cpu0/cpuidle|grep state|wc -l
     ${output}  ${stderr}  ${rc}=  OS Execute Command  ${cmd}
+    ${no_of_states}=  Convert To Integer  ${output}
+
+    # Disable state for all cpus.
+    :FOR  ${i}  IN RANGE  ${no_of_states}
+    \  ${cmd}=  Catenate  SEPARATOR=  for file_path in /sys/devices/system/cpu/
+     ...  cpu*/cpuidle/state${i}/disable; do echo 1 > $file_path; done
+    \  ${output}  ${stderr}  ${rc}=  Run Keyword  OS Execute Command  ${cmd}