Add retries to robot command.
Signed-off-by: Michael Shepos <shepos@us.ibm.com>
Change-Id: I5a5b95a2024787a2e5896cccc6a1b92e1d61d75e
diff --git a/bin/plug_ins/Auto_reboot/cp_master b/bin/plug_ins/Auto_reboot/cp_master
index 8dd9e0e..3ad0742 100755
--- a/bin/plug_ins/Auto_reboot/cp_master
+++ b/bin/plug_ins/Auto_reboot/cp_master
@@ -6,6 +6,7 @@
import os
import sys
+import time
save_dir_path = sys.path.pop(0)
@@ -34,7 +35,6 @@
AUTO_REBOOT_DISABLE = "1"
-
def validate_parms():
r"""
@@ -67,6 +67,14 @@
lib_file_path = init_robot_file_path("lib/utils.robot")
+ REDFISH_SUPPORT_TRANS_STATE = int(os.environ.get('REDFISH_SUPPORT_TRANS_STATE', 0))
+ if not REDFISH_SUPPORT_TRANS_STATE:
+ try:
+ from robot.libraries.BuiltIn import BuiltIn
+ REDFISH_SUPPORT_TRANS_STATE = int(BuiltIn().get_variable_value("${REDFISH_SUPPORT_TRANS_STATE}", default=0))
+ except:
+ pass
+
enable_auto_reboot = 1 - AUTO_REBOOT_DISABLE
print_var(enable_auto_reboot)
keyword_string = "Set Auto Reboot Setting ${%i}" % enable_auto_reboot
@@ -76,9 +84,14 @@
REDFISH_SUPPORT_TRANS_STATE, keyword_string, lib_file_path, quiet,
test_mode, debug, outputdir, output, log, report)
- if not robot_cmd_fnc(cmd_buf):
- print_error_report("Robot command execution failed.")
- exit(1)
+ retry_count = 3
+ while not robot_cmd_fnc(cmd_buf):
+ retry_count -= 1
+ if retry_count == 0:
+ print_error_report("Robot command execution failed.")
+ exit(1)
+ time.sleep(30)
+ return
main()