Test to verify IPMI chassis power restore policy settings.

TC verifies whether the change of power policy setting through REST API
is reflected in the IPMI chassis status power restore policy settings.

Change-Id: If51c531660c2a3f0771e53c5ba00faec9466a15c
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/lib/utils.robot b/lib/utils.robot
index 63c7cae..66b51d6 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -18,14 +18,15 @@
 #${dbuscmdString}=  string:"xyz.openbmc_project.settings.Host" string:
 ${dbuscmdString}=   string:"org.openbmc.settings.Host" string:
 
-
 # Assign default value to QUIET for programs which may not define it.
 ${QUIET}  ${0}
 ${bmc_mem_free_cmd}=   free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f4
 ${bmc_mem_total_cmd}=   free | tr -s ' ' | sed '/^Mem/!d' | cut -d" " -f2
 ${bmc_cpu_usage_cmd}=   top -n 1  | grep CPU: | cut -c 7-9
+${HOST_SETTING}    ${SETTINGS_URI}host0
 
 *** Keywords ***
+
 Wait For Host To Ping
     [Arguments]  ${host}  ${timeout}=${OPENBMC_REBOOT_TIMEOUT}min
     ...          ${interval}=5 sec
@@ -508,6 +509,7 @@
     ${resp}=   Get Matches   ${list}   regexp=^.*[0-9a-z_].${endpoint}[0-9]*$
     [Return]   ${resp}
 
+
 Check Zombie Process
     [Documentation]    Check if any defunct process exist or not on BMC
     ${count}  ${stderr}  ${rc}=  Execute Command  ps -o stat | grep Z | wc -l
@@ -532,3 +534,12 @@
 
     Should Be Equal  ${rc}  ${0}  msg=${stderr}
     Should Contain   ${stderr}  Vacuuming done
+
+Set BMC Power Policy
+    [Documentation]   Set the given BMC power policy.
+    [arguments]   ${policy}
+
+    ${valueDict}=     create dictionary  data=${policy}
+    Write Attribute    ${HOST_SETTING}    power_policy   data=${valueDict}
+    ${currentPolicy}=  Read Attribute     ${HOST_SETTING}   power_policy
+    Should Be Equal    ${currentPolicy}   ${policy}