George Keishing | df9ad39 | 2017-01-25 13:01:15 -0600 | [diff] [blame^] | 1 | #!/usr/bin/env python |
| 2 | |
| 3 | r""" |
| 4 | State Manager module: |
| 5 | |
| 6 | - Defines Valid states of the system |
| 7 | |
| 8 | """ |
| 9 | from robot.libraries.BuiltIn import BuiltIn |
| 10 | |
| 11 | BuiltIn().import_resource("state_manager.robot") |
| 12 | |
| 13 | # We will build eventually the mapping for warm, cold reset as well. |
| 14 | VALID_STATES = { |
| 15 | 'reboot': |
| 16 | { |
| 17 | # (BMC state, Chassis State, Host State) |
| 18 | ('Ready','Off','Off'), |
| 19 | ('Ready','On','Running'), |
| 20 | }, |
| 21 | } |
| 22 | |
| 23 | |
| 24 | class state_map(): |
| 25 | |
| 26 | def get_system_state(self): |
| 27 | r""" |
| 28 | Return the system state as a tuple of bmc, chassis and host states. |
| 29 | """ |
| 30 | bmc_state = BuiltIn().run_keyword('Get BMC State') |
| 31 | chassis_state = BuiltIn().run_keyword('Get Chassis Power State') |
| 32 | host_state = BuiltIn().run_keyword('Get Host State') |
| 33 | return (bmc_state, chassis_state, host_state) |
| 34 | |
| 35 | def valid_boot_state(self, boot_type, state_set): |
| 36 | r""" |
| 37 | Validate a given set of states is valid. |
| 38 | |
| 39 | Description of arguments: |
| 40 | boot_type Reset type (reboot/warm/cold) |
| 41 | state_set State set (bmc,chassis,host) |
| 42 | """ |
| 43 | if state_set in set(VALID_STATES[boot_type]): |
| 44 | return True |
| 45 | else: |
| 46 | return False |