blob: ca406c99a774d087e27ab549820de7b5afe84b32 [file] [log] [blame]
George Keishinge7e91712021-09-03 11:28:44 -05001#!/usr/bin/env python3
George Keishingcfa950c2019-07-18 12:46:46 -05002
3r"""
4This module contains functions for tftp update.
5"""
6
George Keishing7a486012023-03-01 12:29:53 +05307import gen_print as gp # NOQA
Patrick Williams20f38712022-12-08 06:18:26 -06008import state as st
George Keishinge635ddc2022-12-08 07:38:02 -06009
George Keishingcfa950c2019-07-18 12:46:46 -050010
11def get_pre_reboot_state():
12 r"""
13 Get and return a custom state which is comprised of the
14 st.default_req_states plus epoch_seconds.
15 """
16
17 global state
18
Patrick Williams20f38712022-12-08 06:18:26 -060019 req_states = ["epoch_seconds"] + st.default_req_states
George Keishingcfa950c2019-07-18 12:46:46 -050020
21 gp.qprint_timen("Get system state.")
22 state = st.get_state(req_states=req_states, quiet=0)
23 gp.qprint_var(state)
24 return state
25
26
George Keishing68e98272022-07-15 03:26:48 -050027def wait_for_reboot(start_boot_seconds, wait_state_check=True):
George Keishingcfa950c2019-07-18 12:46:46 -050028 r"""
29 Wait for the BMC to complete a previously initiated reboot.
30
31 Description of argument(s):
32 start_boot_seconds The time that the boot test started. The format is the
33 epoch time in seconds, i.e. the number of seconds since
34 1970-01-01 00:00:00 UTC. This value should be obtained
35 from the BMC so that it is not dependent on any kind of
36 synchronization between this machine and the target BMC
37 This will allow this program to work correctly even in
38 a simulated environment. This value should be obtained
39 by the caller prior to initiating a reboot. It can be
40 obtained as follows:
41 state = st.get_state(req_states=['epoch_seconds'])
George Keishing68e98272022-07-15 03:26:48 -050042 wait_state_check By default check the state, ignore if set to False.
George Keishingcfa950c2019-07-18 12:46:46 -050043
44 """
45
46 st.wait_for_comm_cycle(int(start_boot_seconds))
47
48 gp.qprintn()
George Keishing68e98272022-07-15 03:26:48 -050049 if wait_state_check:
Patrick Williams20f38712022-12-08 06:18:26 -060050 st.wait_state(
51 st.standby_match_state, wait_time="10 mins", interval="10 seconds"
52 )