blob: 266e7743d85f962f9fe8168b47fe173fb7ee80ed [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
7from robot.libraries.BuiltIn import BuiltIn
8
9import state as st
10import gen_print as gp
11
12
13def get_pre_reboot_state():
14 r"""
15 Get and return a custom state which is comprised of the
16 st.default_req_states plus epoch_seconds.
17 """
18
19 global state
20
21 req_states = ['epoch_seconds'] + st.default_req_states
22
23 gp.qprint_timen("Get system state.")
24 state = st.get_state(req_states=req_states, quiet=0)
25 gp.qprint_var(state)
26 return state
27
28
George Keishing68e98272022-07-15 03:26:48 -050029def wait_for_reboot(start_boot_seconds, wait_state_check=True):
George Keishingcfa950c2019-07-18 12:46:46 -050030 r"""
31 Wait for the BMC to complete a previously initiated reboot.
32
33 Description of argument(s):
34 start_boot_seconds The time that the boot test started. The format is the
35 epoch time in seconds, i.e. the number of seconds since
36 1970-01-01 00:00:00 UTC. This value should be obtained
37 from the BMC so that it is not dependent on any kind of
38 synchronization between this machine and the target BMC
39 This will allow this program to work correctly even in
40 a simulated environment. This value should be obtained
41 by the caller prior to initiating a reboot. It can be
42 obtained as follows:
43 state = st.get_state(req_states=['epoch_seconds'])
George Keishing68e98272022-07-15 03:26:48 -050044 wait_state_check By default check the state, ignore if set to False.
George Keishingcfa950c2019-07-18 12:46:46 -050045
46 """
47
48 st.wait_for_comm_cycle(int(start_boot_seconds))
49
50 gp.qprintn()
George Keishing68e98272022-07-15 03:26:48 -050051 if wait_state_check:
52 st.wait_state(st.standby_match_state, wait_time="10 mins", interval="10 seconds")