blob: e0f30a18fc3345b217bc1fa8bc4c30696b27d971 [file] [log] [blame]
George Keishingdf9ad392017-01-25 13:01:15 -06001#!/usr/bin/env python
2
3r"""
4State Manager module:
5
6 - Defines Valid states of the system
7
8"""
9from robot.libraries.BuiltIn import BuiltIn
10
11BuiltIn().import_resource("state_manager.robot")
12
13# We will build eventually the mapping for warm, cold reset as well.
14VALID_STATES = {
15 'reboot':
16 {
George Keishing4d6f3d62017-02-06 09:50:41 -060017 # (Power Policy, BMC state, Chassis State, Host State)
18 ('LEAVE_OFF','Ready','Off','Off'),
19 ('ALWAYS_POWER_ON','Ready','On','Running'),
20 ('ALWAYS_POWER_ON','Ready','On','Off'),
21 ('RESTORE_LAST_STATE','Ready','On','Running'),
22 ('RESTORE_LAST_STATE','Ready','On','Off'),
23 ('RESTORE_LAST_STATE','Ready','Off','Off'),
George Keishingdf9ad392017-01-25 13:01:15 -060024 },
25}
26
27
28class state_map():
29
30 def get_system_state(self):
31 r"""
George Keishing4d6f3d62017-02-06 09:50:41 -060032 Return the system state as a tuple of power policy, bmc, chassis and
33 host states.
George Keishingdf9ad392017-01-25 13:01:15 -060034 """
George Keishing4d6f3d62017-02-06 09:50:41 -060035 power_policy = BuiltIn().run_keyword('Get System Power Policy')
George Keishingdf9ad392017-01-25 13:01:15 -060036 bmc_state = BuiltIn().run_keyword('Get BMC State')
37 chassis_state = BuiltIn().run_keyword('Get Chassis Power State')
38 host_state = BuiltIn().run_keyword('Get Host State')
George Keishing4d6f3d62017-02-06 09:50:41 -060039 return (str(power_policy),
40 str(bmc_state),
41 str(chassis_state),
42 str(host_state))
George Keishingdf9ad392017-01-25 13:01:15 -060043
44 def valid_boot_state(self, boot_type, state_set):
45 r"""
46 Validate a given set of states is valid.
47
48 Description of arguments:
49 boot_type Reset type (reboot/warm/cold)
50 state_set State set (bmc,chassis,host)
51 """
52 if state_set in set(VALID_STATES[boot_type]):
53 return True
54 else:
55 return False