George Keishing | e7e9171 | 2021-09-03 11:28:44 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 2 | |
| 3 | r""" |
| 4 | This module contains functions for tftp update. |
| 5 | """ |
| 6 | |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 7 | import gen_print as gp |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 8 | import state as st |
| 9 | from robot.libraries.BuiltIn import BuiltIn |
George Keishing | e635ddc | 2022-12-08 07:38:02 -0600 | [diff] [blame] | 10 | |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 11 | |
| 12 | def get_pre_reboot_state(): |
| 13 | r""" |
| 14 | Get and return a custom state which is comprised of the |
| 15 | st.default_req_states plus epoch_seconds. |
| 16 | """ |
| 17 | |
| 18 | global state |
| 19 | |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 20 | req_states = ["epoch_seconds"] + st.default_req_states |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 21 | |
| 22 | gp.qprint_timen("Get system state.") |
| 23 | state = st.get_state(req_states=req_states, quiet=0) |
| 24 | gp.qprint_var(state) |
| 25 | return state |
| 26 | |
| 27 | |
George Keishing | 68e9827 | 2022-07-15 03:26:48 -0500 | [diff] [blame] | 28 | def wait_for_reboot(start_boot_seconds, wait_state_check=True): |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 29 | r""" |
| 30 | Wait for the BMC to complete a previously initiated reboot. |
| 31 | |
| 32 | Description of argument(s): |
| 33 | start_boot_seconds The time that the boot test started. The format is the |
| 34 | epoch time in seconds, i.e. the number of seconds since |
| 35 | 1970-01-01 00:00:00 UTC. This value should be obtained |
| 36 | from the BMC so that it is not dependent on any kind of |
| 37 | synchronization between this machine and the target BMC |
| 38 | This will allow this program to work correctly even in |
| 39 | a simulated environment. This value should be obtained |
| 40 | by the caller prior to initiating a reboot. It can be |
| 41 | obtained as follows: |
| 42 | state = st.get_state(req_states=['epoch_seconds']) |
George Keishing | 68e9827 | 2022-07-15 03:26:48 -0500 | [diff] [blame] | 43 | wait_state_check By default check the state, ignore if set to False. |
George Keishing | cfa950c | 2019-07-18 12:46:46 -0500 | [diff] [blame] | 44 | |
| 45 | """ |
| 46 | |
| 47 | st.wait_for_comm_cycle(int(start_boot_seconds)) |
| 48 | |
| 49 | gp.qprintn() |
George Keishing | 68e9827 | 2022-07-15 03:26:48 -0500 | [diff] [blame] | 50 | if wait_state_check: |
Patrick Williams | 20f3871 | 2022-12-08 06:18:26 -0600 | [diff] [blame] | 51 | st.wait_state( |
| 52 | st.standby_match_state, wait_time="10 mins", interval="10 seconds" |
| 53 | ) |