New Auto_reboot plug-in II
Also, added code to obmc boot test to process rest_username and
rest_password.
Change-Id: I7b64be7072d4848230e9d47a4da54ac89794af64
diff --git a/bin/plug_ins/Auto_reboot/cp_cleanup b/bin/plug_ins/Auto_reboot/cp_cleanup
new file mode 120000
index 0000000..2cb0b31
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/cp_cleanup
@@ -0,0 +1 @@
+cp_master
\ No newline at end of file
diff --git a/bin/plug_ins/Auto_reboot/cp_master b/bin/plug_ins/Auto_reboot/cp_master
new file mode 100755
index 0000000..36d40f2
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/cp_master
@@ -0,0 +1,121 @@
+#!/usr/bin/env python
+
+r"""
+Set the auto_boot policy according to the caller's wishes.
+"""
+
+import os
+import sys
+
+save_path_0 = sys.path[0]
+del sys.path[0]
+
+from gen_print import *
+from gen_valid import *
+from gen_arg import *
+from gen_misc import *
+from gen_cmd import *
+from gen_plug_in_utils import *
+from gen_call_robot import *
+
+# Restore sys.path[0].
+sys.path.insert(0, save_path_0)
+
+# Set exit_on_error for gen_valid functions.
+set_exit_on_error(True)
+
+parser = argparse.ArgumentParser(
+ usage='%(prog)s [OPTIONS]',
+ description="%(prog)s will set the auto_boot policy according to the"
+ + " user's wishes.",
+ formatter_class=argparse.RawTextHelpFormatter,
+ prefix_chars='-+')
+
+
+# Populate stock_list with options we want.
+stock_list = [("test_mode", get_plug_default("test_mode", 0)),
+ ("quiet", get_plug_default("quiet", 0)),
+ ("debug", get_plug_default("debug", 0))]
+
+AUTO_REBOOT_DISABLE = "1"
+
+def exit_function(signal_number=0,
+ frame=None):
+ r"""
+ Execute whenever the program ends normally or with the signals that we
+ catch (i.e. TERM, INT).
+ """
+
+ dprint_executing()
+ dprint_var(signal_number)
+
+ # Your cleanup code here.
+
+ qprint_pgm_footer()
+
+
+def signal_handler(signal_number,
+ frame):
+ r"""
+ Handle signals. Without a function to catch a SIGTERM or SIGINT, our
+ program would terminate immediately with return code 143 and without
+ calling our exit_function.
+ """
+
+ # Our convention is to set up exit_function with atexit.register() so
+ # there is no need to explicitly call exit_function from here.
+
+ dprint_executing()
+
+ # Calling exit prevents us from returning to the code that was running
+ # when we received the signal.
+ exit(0)
+
+
+def validate_parms():
+
+ r"""
+ Validate program parameters, etc. Return True or False (i.e. pass/fail)
+ accordingly.
+ """
+
+ get_plug_vars()
+
+ valid_value(AUTOBOOT_OPENBMC_HOST, ["", None])
+ global AUTO_REBOOT_DISABLE
+ if pgm_name == "cp_cleanup":
+ AUTO_REBOOT_DISABLE = 0
+ else:
+ valid_value(AUTO_REBOOT_DISABLE, valid_values=["0", "1"])
+ AUTO_REBOOT_DISABLE = int(AUTO_REBOOT_DISABLE)
+
+ gen_post_validation(exit_function, signal_handler)
+
+
+def main():
+
+ gen_get_options(parser, stock_list)
+
+ validate_parms()
+
+ qprint_pgm_header()
+
+ dprint_plug_vars()
+
+ init_robot_out_parms(get_plug_in_package_name() + "." + pgm_name + ".")
+
+ lib_file_path = init_robot_file_path("lib/utils.robot")
+
+ keyword_string = "Set Auto Reboot ${%i}" % AUTO_REBOOT_DISABLE
+
+ cmd_buf = create_robot_cmd_string("extended/run_keyword.robot",
+ OPENBMC_HOST, REST_USERNAME,
+ REST_PASSWORD, 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)
+
+
+main()
diff --git a/bin/plug_ins/Auto_reboot/cp_post_reboot b/bin/plug_ins/Auto_reboot/cp_post_reboot
new file mode 120000
index 0000000..2cb0b31
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/cp_post_reboot
@@ -0,0 +1 @@
+cp_master
\ No newline at end of file
diff --git a/bin/plug_ins/Auto_reboot/cp_pre_boot b/bin/plug_ins/Auto_reboot/cp_pre_boot
new file mode 120000
index 0000000..2cb0b31
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/cp_pre_boot
@@ -0,0 +1 @@
+cp_master
\ No newline at end of file
diff --git a/bin/plug_ins/Auto_reboot/cp_setup b/bin/plug_ins/Auto_reboot/cp_setup
new file mode 120000
index 0000000..2cb0b31
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/cp_setup
@@ -0,0 +1 @@
+cp_master
\ No newline at end of file
diff --git a/bin/plug_ins/Auto_reboot/integrated b/bin/plug_ins/Auto_reboot/integrated
new file mode 100755
index 0000000..050dfc4
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/integrated
@@ -0,0 +1,2 @@
+# The presence of this file tells our software that this plug-in is
+# integrated. In other words, the user can't choose to unselect it.
diff --git a/bin/plug_ins/Auto_reboot/parm_def b/bin/plug_ins/Auto_reboot/parm_def
new file mode 100755
index 0000000..748be18
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/parm_def
@@ -0,0 +1,2 @@
+# Indicates whether auto_boot should be disabled.
+disable=boolean
diff --git a/bin/plug_ins/Auto_reboot/supports_obmc b/bin/plug_ins/Auto_reboot/supports_obmc
new file mode 100755
index 0000000..ffa0963
--- /dev/null
+++ b/bin/plug_ins/Auto_reboot/supports_obmc
@@ -0,0 +1,2 @@
+# The presence of this file tells programs like validate_plug_ins.py that
+# this plug-in supports OBMC.
diff --git a/bin/process_plug_in_packages.py b/bin/process_plug_in_packages.py
index fc9f64b..900dd31 100755
--- a/bin/process_plug_in_packages.py
+++ b/bin/process_plug_in_packages.py
@@ -238,7 +238,13 @@
status_dir_path =\
add_trailing_slash(os.environ.get("STATUS_DIR_PATH",
os.environ['HOME']
- + "/autoipl/status/"))
+ + "/status/"))
+ if not os.path.isdir(status_dir_path):
+ AUTOBOOT_EXECDIR = \
+ add_trailing_slash(os.environ.get("AUTOBOOT_EXECDIR", ""))
+ status_dir_path = AUTOBOOT_EXECDIR + "logs/"
+ if not os.path.exists(status_dir_path):
+ os.makedirs(status_dir_path)
status_file_name = autoscript_prefix + "." + file_date_time_stamp() \
+ ".status"
autoscript_subcmd = "autoscript --status_dir_path=" + status_dir_path\
diff --git a/extended/obmc_boot_test_resource.robot b/extended/obmc_boot_test_resource.robot
index 9c9dbc6..8fc3907 100644
--- a/extended/obmc_boot_test_resource.robot
+++ b/extended/obmc_boot_test_resource.robot
@@ -13,20 +13,24 @@
# Create parm_list containing all of our program parameters. This is used by
# 'Rqprint Pgm Header'
@{parm_list} openbmc_nickname openbmc_host openbmc_username
-... openbmc_password os_host os_username os_password pdu_host
-... pdu_username pdu_password pdu_slot_no openbmc_serial_host
-... openbmc_serial_port stack_mode boot_stack boot_list max_num_tests
-... plug_in_dir_paths status_file_path openbmc_model boot_pass boot_fail
-... ffdc_dir_path_style ffdc_check ffdc_only ffdc_function_list
-... state_change_timeout power_on_timeout power_off_timeout
-... boot_fail_threshold delete_errlogs call_post_stack_plug test_mode
-... quiet debug
+... openbmc_password rest_username rest_password ipmi_username
+... ipmi_password os_host os_username os_password pdu_host pdu_username
+... pdu_password pdu_slot_no openbmc_serial_host openbmc_serial_port
+... stack_mode boot_stack boot_list max_num_tests plug_in_dir_paths
+... status_file_path openbmc_model boot_pass boot_fail ffdc_dir_path_style
+... ffdc_check ffdc_only ffdc_function_list state_change_timeout
+... power_on_timeout power_off_timeout boot_fail_threshold delete_errlogs
+... call_post_stack_plug test_mode quiet debug
# Initialize each program parameter.
${openbmc_host} ${EMPTY}
${openbmc_nickname} ${openbmc_host}
${openbmc_username} root
${openbmc_password} 0penBmc
+${rest_username} ${openbmc_username}
+${rest_password} ${openbmc_password}
+${ipmi_username} ${openbmc_username}
+${ipmi_password} ${openbmc_password}
${os_host} ${EMPTY}
${os_username} root
${os_password} P@ssw0rd
diff --git a/lib/gen_call_robot.py b/lib/gen_call_robot.py
index e336229..3944c79 100755
--- a/lib/gen_call_robot.py
+++ b/lib/gen_call_robot.py
@@ -50,7 +50,7 @@
os.environ.get("TMP_ROBOT_DIR_PATH",
os.environ.get("STATUS_DIR_PATH",
os.environ.get("HOME", ".")
- + "/autoipl/status"))
+ + "/status"))
outputdir = gm.add_trailing_slash(outputdir)
seconds = time.time()
loc_time = time.localtime(seconds)
@@ -259,7 +259,7 @@
Would return a string something like this.
robot -v OPENBMC_HOST:beye6 -v quiet:0 -v test_mode:1 -v debug:1
- --outputdir=/gsa/ausgsa/projects/a/autoipl/status
+ --outputdir=/gsa/ausgsa/projects/a/status
--output=beye6.OS_Console.output.xml --log=beye6.OS_Console.log.html
--report=beye6.OS_Console.report.html tools/start_sol_console.robot
"""
@@ -370,7 +370,7 @@
# to FFDC cleanup.
target_dir_path = os.environ.get("FFDC_DIR_PATH",
os.environ.get("HOME", ".")
- + "/autoipl/ffdc")
+ + "/ffdc")
target_dir_path = gm.add_trailing_slash(target_dir_path)
targ_file_list = [re.sub(".*/", target_dir_path, x)
@@ -440,6 +440,10 @@
PATH_LIST = os.environ.get("PATH", "").split(":")
if python27_path in PATH_LIST:
NEW_PATH_LIST.append(python27_path)
+ # Make sure robot can be found in robot jail.
+ robot_dir_path = os.path.dirname(gm.which('robot'))
+ if robot_dir_path in PATH_LIST:
+ NEW_PATH_LIST.append(robot_dir_path)
NEW_PATH_LIST.extend(["/usr/local/sbin", "/usr/local/bin", "/usr/sbin",
"/usr/bin", "/sbin", "/bin"])
PATH = ":".join(NEW_PATH_LIST)
diff --git a/lib/gen_robot_plug_in.py b/lib/gen_robot_plug_in.py
index a89e07c..31236c4 100755
--- a/lib/gen_robot_plug_in.py
+++ b/lib/gen_robot_plug_in.py
@@ -213,6 +213,8 @@
if proc_plug_pkg_rc != 0:
hex = 1
+ if quiet:
+ os.system("cat " + temp_file_path + " >&2")
if grep_rc != 0:
gp.print_varx("grep_rc", grep_rc, hex)
gp.print_varx("proc_plug_pkg_rc", proc_plug_pkg_rc, hex)
diff --git a/lib/obmc_boot_test.py b/lib/obmc_boot_test.py
index 4aa63cd..f0b6ad3 100755
--- a/lib/obmc_boot_test.py
+++ b/lib/obmc_boot_test.py
@@ -242,7 +242,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"]
+ "ffdc_summary_list_path", "execdir"]
plug_in_vars = parm_list + additional_values
@@ -417,6 +417,10 @@
grv.rvalid_value("openbmc_host")
grv.rvalid_value("openbmc_username")
grv.rvalid_value("openbmc_password")
+ grv.rvalid_value("rest_username")
+ grv.rvalid_value("rest_password")
+ grv.rvalid_value("ipmi_username")
+ grv.rvalid_value("ipmi_password")
if os_host != "":
grv.rvalid_value("os_username")
grv.rvalid_value("os_password")
@@ -677,7 +681,8 @@
gp.qprintn(more_header_info)
gp.qpvars(host_name, host_ip, openbmc_nickname, openbmc_host,
openbmc_host_name, openbmc_ip, openbmc_username,
- openbmc_password, os_host, os_host_name, os_ip, os_username,
+ openbmc_password, rest_username, rest_password, ipmi_username,
+ ipmi_password, os_host, os_host_name, os_ip, os_username,
os_password, pdu_host, pdu_host_name, pdu_ip, pdu_username,
pdu_password, pdu_slot_no, openbmc_serial_host,
openbmc_serial_host_name, openbmc_serial_ip, openbmc_serial_port)