blob: a861d570a769004a1ce794adb84c214f8fa30392 [file] [log] [blame]
Michael Walshffee58a2016-11-22 11:28:33 -06001#!/usr/bin/env python
2
3r"""
4This module is the python counterpart to utils.robot. It provides many
5functions for communicating with the Open BMC machine.
6"""
7
8import gen_robot_print as grp
9import state as state_mod
10
11from robot.libraries.BuiltIn import BuiltIn
12
13# We need utils.robot to get keyword "Initiate Power On".
14BuiltIn().import_resource("utils.robot")
15
16
17###############################################################################
18def bmc_power_on():
19
20 r"""
21 Power the Open BMC machine on and monitor status to verify.
22 """
23
24 grp.rprint_timen("Refreshing state data.")
25 state = state_mod.get_state()
26 grp.rprint_var(state)
27
28 match_state = state_mod.anchor_state(state)
29
30 grp.rprintn()
31 cmd_buf = ["Initiate Power On", "wait=${0}"]
32 grp.rpissuing_keyword(cmd_buf)
33 power = BuiltIn().run_keyword(*cmd_buf)
34
Michael Walsh0957aaf2017-01-10 11:39:03 -060035 state_change_timeout = BuiltIn().get_variable_value(
36 "${STATE_CHANGE_TIMEOUT}", default="1 min")
37
Michael Walshffee58a2016-11-22 11:28:33 -060038 # Wait for the state to change in any way.
Michael Walsh0957aaf2017-01-10 11:39:03 -060039 state_mod.wait_state(match_state, wait_time=state_change_timeout,
40 interval="3 seconds", invert=1)
Michael Walshffee58a2016-11-22 11:28:33 -060041
42 cmd_buf = ["Create Dictionary", "power=${1}",
43 "bmc=HOST_BOOTED",
44 "boot_progress=FW Progress, Starting OS"]
45 grp.rdpissuing_keyword(cmd_buf)
46 final_state = BuiltIn().run_keyword(*cmd_buf)
47
Michael Walsh0957aaf2017-01-10 11:39:03 -060048 os_host = BuiltIn().get_variable_value("${OS_HOST}", default="")
Michael Walshffee58a2016-11-22 11:28:33 -060049
50 if os_host != "":
51 final_state['os_ping'] = 1
52 final_state['os_login'] = 1
53 final_state['os_run_cmd'] = 1
54
55 final_state = state_mod.anchor_state(final_state)
56
57 grp.rprintn()
Michael Walsh0957aaf2017-01-10 11:39:03 -060058 power_on_timeout = BuiltIn().get_variable_value(
59 "${POWER_ON_TIMEOUT}", default="14 mins")
60 state_mod.wait_state(final_state, wait_time=power_on_timeout,
Michael Walsh1ef70562016-12-13 15:53:34 -060061 interval="3 seconds")
Michael Walshffee58a2016-11-22 11:28:33 -060062
63###############################################################################