blob: e8b921bf965d6ab17c0cf43b8bf2bc047c30ce6a [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
Michael Walsh341c21e2017-01-17 16:25:20 -060013# We don't want global variable getting changed when an import is done
14# so we'll save it and restore it.
15quiet = int(BuiltIn().get_variable_value("${quiet}"))
16
Michael Walshffee58a2016-11-22 11:28:33 -060017# We need utils.robot to get keyword "Initiate Power On".
18BuiltIn().import_resource("utils.robot")
19
Michael Walsh341c21e2017-01-17 16:25:20 -060020BuiltIn().set_global_variable("${quiet}", quiet)
21
Michael Walshffee58a2016-11-22 11:28:33 -060022
23###############################################################################
24def bmc_power_on():
25
26 r"""
27 Power the Open BMC machine on and monitor status to verify.
28 """
29
30 grp.rprint_timen("Refreshing state data.")
31 state = state_mod.get_state()
32 grp.rprint_var(state)
33
34 match_state = state_mod.anchor_state(state)
35
36 grp.rprintn()
37 cmd_buf = ["Initiate Power On", "wait=${0}"]
38 grp.rpissuing_keyword(cmd_buf)
39 power = BuiltIn().run_keyword(*cmd_buf)
40
Michael Walsh0957aaf2017-01-10 11:39:03 -060041 state_change_timeout = BuiltIn().get_variable_value(
42 "${STATE_CHANGE_TIMEOUT}", default="1 min")
43
Michael Walshffee58a2016-11-22 11:28:33 -060044 # Wait for the state to change in any way.
Michael Walsh0957aaf2017-01-10 11:39:03 -060045 state_mod.wait_state(match_state, wait_time=state_change_timeout,
46 interval="3 seconds", invert=1)
Michael Walshffee58a2016-11-22 11:28:33 -060047
Michael Walsh341c21e2017-01-17 16:25:20 -060048 if state_mod.OBMC_STATES_VERSION == 0:
49 cmd_buf = ["Create Dictionary", "power=${1}",
50 "bmc=HOST_BOOTED",
51 "boot_progress=FW Progress, Starting OS"]
52 else:
53 cmd_buf = ["Create Dictionary", "chassis=On",
54 "bmc=HOST_BOOTED",
55 "boot_progress=FW Progress, Starting OS",
56 "host=Running"]
Michael Walshffee58a2016-11-22 11:28:33 -060057 grp.rdpissuing_keyword(cmd_buf)
58 final_state = BuiltIn().run_keyword(*cmd_buf)
59
Michael Walsh0957aaf2017-01-10 11:39:03 -060060 os_host = BuiltIn().get_variable_value("${OS_HOST}", default="")
Michael Walshffee58a2016-11-22 11:28:33 -060061
62 if os_host != "":
63 final_state['os_ping'] = 1
64 final_state['os_login'] = 1
65 final_state['os_run_cmd'] = 1
66
67 final_state = state_mod.anchor_state(final_state)
68
69 grp.rprintn()
Michael Walsh0957aaf2017-01-10 11:39:03 -060070 power_on_timeout = BuiltIn().get_variable_value(
71 "${POWER_ON_TIMEOUT}", default="14 mins")
72 state_mod.wait_state(final_state, wait_time=power_on_timeout,
Michael Walsh1ef70562016-12-13 15:53:34 -060073 interval="3 seconds")
Michael Walshffee58a2016-11-22 11:28:33 -060074
75###############################################################################