Check & enable opal-prd service on HOST OS.

Resolves openbmc/openbmc-test-automation#1240

Change-Id: I5d9cd711804c26d8771bdf0f14c3d6adda999205
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/lib/ras/host_utils.robot b/lib/ras/host_utils.robot
index aeda08b..988b655 100644
--- a/lib/ras/host_utils.robot
+++ b/lib/ras/host_utils.robot
@@ -146,3 +146,22 @@
     \  ${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}
+
+Is Opal-PRD Service Enabled
+    [Documentation]  Check if Opal-PRD service is running & return either
+    ...              'enabled' or 'disabled'.
+
+    ${cmd}=  Catenate  systemctl list-unit-files | grep opal-prd
+    ${output}  ${stderr}  ${rc}=  OS Execute Command  ${cmd}
+    ${opal_prd_state}=  Split String  ${output}
+
+    # Example output from prior command:
+    # opal-prd.service enabled
+    [Return]  ${opal_prd_state[1]}
+
+Enable Opal-PRD Service On HOST
+    [Documentation]  Enable Opal-PRD service on host.
+
+    OS Execute Command  service opal-prd start
+    ${opal_prd_state}=  Is Opal-PRD Service Enabled
+    Should Contain  ${opal_prd_state}  enabled
diff --git a/ras/test_host_ras.robot b/ras/test_host_ras.robot
index 7e4a62c..ef07aeb 100755
--- a/ras/test_host_ras.robot
+++ b/ras/test_host_ras.robot
@@ -480,6 +480,11 @@
     # Boot to Os.
     REST Power On  quiet=${1}
 
+    # Check Opal-PRD service enabled on host.
+    ${opal_prd_state}=  Is Opal-PRD Service Enabled
+    Run Keyword If  '${opal_prd_state}' == 'disabled'
+    ...  Enable Opal-PRD Service On HOST
+
 RAS Suite Cleanup
     [Documentation]  Perform RAS suite cleanup and verify that host
     ...              boots after test suite run.