Add support for redfish power policy
Changes:
- Added redfish power policy to get and set.
- Added redfish support check for policy in boot path.
Change-Id: I8e4249f82b2169c00a3e02d85f591389e6966730
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index 000a497..338821d 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -38,6 +38,8 @@
sys.path.append(base_path + "extended/")
import run_keyword as rk
+redfish = BuiltIn().get_library_instance('redfish')
+
# Setting master_pid correctly influences the behavior of plug-ins like
# DB_Logging
program_pid = os.getpid()
@@ -70,10 +72,12 @@
default_power_off = "Redfish Power Off"
delete_errlogs_cmd = "Delete Error Logs"
# TODO: delete_errlogs_cmd="Redfish Purge Event Log"
+ default_set_power_policy = "Redfish Set Power Restore Policy AlwaysOff"
else:
default_power_on = "REST Power On"
default_power_off = "REST Power Off"
delete_errlogs_cmd = "Delete Error Logs"
+ default_set_power_policy = "Set BMC Power Policy ALWAYS_POWER_OFF"
boot_count = 0
LOG_LEVEL = BuiltIn().get_variable_value("${LOG_LEVEL}")
@@ -259,7 +263,7 @@
additional_values = ["program_pid", "master_pid", "ffdc_dir_path",
"status_dir_path", "base_tool_dir_path",
"ffdc_list_file_path", "ffdc_report_list_path",
- "ffdc_summary_list_path", "execdir"]
+ "ffdc_summary_list_path", "execdir", "redfish_supported"]
plug_in_vars = parm_list + additional_values
@@ -396,6 +400,9 @@
gp.qprintn()
+ if redfish_supported:
+ redfish.login()
+
set_default_siguser1()
transitional_boot_selected = False
@@ -421,7 +428,7 @@
gp.qprint_pgm_header()
- grk.run_key("Set BMC Power Policy ALWAYS_POWER_OFF")
+ grk.run_key_u(default_set_power_policy)
initial_plug_in_setup()
@@ -1033,6 +1040,9 @@
"A keyword timeout occurred ending this program.\n"]
BuiltIn().run_keyword_if_timeout_occurred(*cmd_buf)
+ if redfish_supported:
+ redfish.logout()
+
gp.qprint_pgm_footer()
diff --git a/lib/utils.robot b/lib/utils.robot
index 9f6c948..95fdf9e 100755
--- a/lib/utils.robot
+++ b/lib/utils.robot
@@ -353,6 +353,13 @@
[Return] ${currentPolicy}
+Redfish Get Power Restore Policy
+ [Documentation] Returns the BMC power restore policy.
+
+ ${power_restore_policy}= Redfish.Get Attribute /redfish/v1/Systems/system PowerRestorePolicy
+ [Return] ${power_restore_policy}
+
+
Get Auto Reboot
[Documentation] Returns auto reboot setting.
${setting}= Read Attribute ${CONTROL_HOST_URI}/auto_reboot AutoReboot
@@ -658,6 +665,17 @@
Write Attribute ${HOST_SETTING} power_policy data=${valueDict}
+Redfish Set Power Restore Policy
+ [Documentation] Set the BMC power restore policy.
+ [Arguments] ${power_restore_policy}
+
+ # Description of argument(s):
+ # power_restore_policy Power restore policy (e.g. "AlwaysOff", "AlwaysOn", "LastState").
+
+ Redfish.Patch /redfish/v1/Systems/system body={"PowerRestorePolicy": "${power_restore_policy}"}
+ ... valid_status_codes=[${HTTP_OK}, ${HTTP_NO_CONTENT}]
+
+
Set Auto Reboot
[Documentation] Set the given auto reboot setting.
[Arguments] ${setting}