blob: 872912a6a9b0d0dca9e7434650287aaa47154ce1 [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
35 # Wait for the state to change in any way.
36 state_mod.wait_state(match_state, wait_time="1 min", interval="3 seconds",
37 invert=1)
38
39 cmd_buf = ["Create Dictionary", "power=${1}",
40 "bmc=HOST_BOOTED",
41 "boot_progress=FW Progress, Starting OS"]
42 grp.rdpissuing_keyword(cmd_buf)
43 final_state = BuiltIn().run_keyword(*cmd_buf)
44
45 try:
46 os_host = BuiltIn().get_variable_value("${OS_HOST}")
47 except TypeError:
48 os_host = ""
49
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()
58 state_mod.wait_state(final_state, wait_time="7 min", interval="3 seconds")
59
60###############################################################################