blob: 0977d4c8bde7d968b9699be16f700b78bb8f70c3 [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
Michael Walsh16cbb7f2017-02-02 15:54:16 -060010import gen_robot_utils as gru
Michael Walshffee58a2016-11-22 11:28:33 -060011
12from robot.libraries.BuiltIn import BuiltIn
13
14# We need utils.robot to get keyword "Initiate Power On".
Michael Walsh16cbb7f2017-02-02 15:54:16 -060015gru.my_import_resource("utils.robot")
Michael Walsh341c21e2017-01-17 16:25:20 -060016
Michael Walshffee58a2016-11-22 11:28:33 -060017
18###############################################################################
19def bmc_power_on():
20
21 r"""
22 Power the Open BMC machine on and monitor status to verify.
23 """
24
25 grp.rprint_timen("Refreshing state data.")
26 state = state_mod.get_state()
27 grp.rprint_var(state)
28
29 match_state = state_mod.anchor_state(state)
30
31 grp.rprintn()
32 cmd_buf = ["Initiate Power On", "wait=${0}"]
33 grp.rpissuing_keyword(cmd_buf)
34 power = BuiltIn().run_keyword(*cmd_buf)
35
Michael Walsh0957aaf2017-01-10 11:39:03 -060036 state_change_timeout = BuiltIn().get_variable_value(
37 "${STATE_CHANGE_TIMEOUT}", default="1 min")
38
Michael Walshffee58a2016-11-22 11:28:33 -060039 # Wait for the state to change in any way.
Michael Walsh0957aaf2017-01-10 11:39:03 -060040 state_mod.wait_state(match_state, wait_time=state_change_timeout,
41 interval="3 seconds", invert=1)
Michael Walshffee58a2016-11-22 11:28:33 -060042
Michael Walsh341c21e2017-01-17 16:25:20 -060043 if state_mod.OBMC_STATES_VERSION == 0:
44 cmd_buf = ["Create Dictionary", "power=${1}",
45 "bmc=HOST_BOOTED",
46 "boot_progress=FW Progress, Starting OS"]
47 else:
Michael Walsh65b12542017-02-03 15:34:38 -060048 # TODO: Add back boot_progress when ipmi is enabled on Witherspoon.
Michael Walsh341c21e2017-01-17 16:25:20 -060049 cmd_buf = ["Create Dictionary", "chassis=On",
Michael Walsh65b12542017-02-03 15:34:38 -060050 "bmc=Ready",
51 # "boot_progress=FW Progress, Starting OS",
Michael Walsh341c21e2017-01-17 16:25:20 -060052 "host=Running"]
Michael Walshffee58a2016-11-22 11:28:33 -060053 grp.rdpissuing_keyword(cmd_buf)
54 final_state = BuiltIn().run_keyword(*cmd_buf)
55
Michael Walsh0957aaf2017-01-10 11:39:03 -060056 os_host = BuiltIn().get_variable_value("${OS_HOST}", default="")
Michael Walshffee58a2016-11-22 11:28:33 -060057
58 if os_host != "":
59 final_state['os_ping'] = 1
60 final_state['os_login'] = 1
61 final_state['os_run_cmd'] = 1
62
63 final_state = state_mod.anchor_state(final_state)
64
65 grp.rprintn()
Michael Walsh0957aaf2017-01-10 11:39:03 -060066 power_on_timeout = BuiltIn().get_variable_value(
67 "${POWER_ON_TIMEOUT}", default="14 mins")
68 state_mod.wait_state(final_state, wait_time=power_on_timeout,
Michael Walsh1ef70562016-12-13 15:53:34 -060069 interval="3 seconds")
Michael Walshffee58a2016-11-22 11:28:33 -060070
71###############################################################################