blob: 55bb9bffdd4df93131a065663e088cb977114dc9 [file] [log] [blame]
Michael Walshffee58a2016-11-22 11:28:33 -06001#!/usr/bin/env python
2
3r"""
4This module is the python counterpart to poweroffs.robot. It provides
5functions for powering off an 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 Off".
14BuiltIn().import_resource("utils.robot")
15
16
17###############################################################################
18def bmc_power_off():
19
20 r"""
21 Power the Open BMC machine off 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 Off"]
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=${0}",
40 "bmc=HOST_POWERED_OFF", "boot_progress=Off"]
41 grp.rdpissuing_keyword(cmd_buf)
42 final_state = BuiltIn().run_keyword(*cmd_buf)
43
44 final_state = state_mod.anchor_state(final_state)
45
46 grp.rprintn()
47 state_mod.wait_state(final_state, wait_time="2 min", interval="3 seconds")
48
49###############################################################################