diff options
author | Devananda van der Veen <devananda.vdv@gmail.com> | 2015-01-26 07:39:41 -0800 |
---|---|---|
committer | Devananda van der Veen <devananda.vdv@gmail.com> | 2015-02-04 19:11:07 -0800 |
commit | 5dbd06f89da2ef8395460d0c4af8f4bfc1963030 (patch) | |
tree | e587b1f82f9db83f6402cd6baa1247fc735d424f /ironic/common/states.py | |
parent | b0af29e66478eeb48d42ba7be720f9ae06ab1044 (diff) | |
download | ironic-5dbd06f89da2ef8395460d0c4af8f4bfc1963030.tar.gz |
Add MANAGEABLE state and associated transitions
This patch adds the MANAGEABLE state, and associated transitions to and
from AVAILABLE, as well as a new RPC method to initiate transitions
between provisioning states.
It also adds a new VERBS entity to ironic/common/states.py to hold the
action-phrases, as described in blueprint new-ironic-state-machine. This
provides a single place to check whether a requested target state is
allowed to be requested by checking if the value is "in" the keys of
this dictionary. It also provides a mapping for two phrases which are
currently inconsistent:
target:deleted -> action:delete
target:active -> action:deploy
It updates the API controller for nodes.py without changing the HTTP
status codes which are returned in exception cases. The changes in unit
tests now prepare the node appropriately, but do not change the
assertions being tested.
Juno allowed the rebuild of a failed deploy to be initiated by PUTting
a target state of "active"; this behavior, while inconsistent with the
new state machine, is added to the state model for compatibility, now
that stronger checking is done within the API service, based on the
actual modelling of state transitions.
Implements: blueprint new-ironic-state-machine
Co-Authored-By: David Shrewsbury <shrewsbury.dave@gmail.com>
Change-Id: Id0af5a607b7432d287eef643c1e30e324dc4f879
Diffstat (limited to 'ironic/common/states.py')
-rw-r--r-- | ironic/common/states.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ironic/common/states.py b/ironic/common/states.py index 9ef7edc53..fcef88d99 100644 --- a/ironic/common/states.py +++ b/ironic/common/states.py @@ -37,6 +37,25 @@ LOG = logging.getLogger(__name__) # Provisioning states ##################### +# TODO(deva): add add'l state mappings here +VERBS = { + 'active': 'deploy', + 'deleted': 'delete', + 'manage': 'manage', + 'provide': 'provide', + } +""" Mapping of state-changing events that are PUT to the REST API + +This is a mapping of target states which are PUT to the API, eg, + PUT /v1/node/states/provision {'target': 'active'} + +The dict format is: + {target string used by the API: internal verb} + +This provides a reference set of supported actions, and in the future +may be used to support renaming these actions. +""" + NOSTATE = None """ No state information. @@ -44,6 +63,14 @@ This state is used with power_state to represent a lack of knowledge of power state, and in target_*_state fields when there is no target. """ +MANAGEABLE = 'manageable' +""" Node is in a manageable state. + +This state indicates that Ironic has verified, at least once, that it had +sufficient information to manage the hardware. While in this state, the node +is not available for provisioning (it must be in the AVAILABLE state for that). +""" + AVAILABLE = 'available' """ Node is available for use and scheduling. @@ -91,6 +118,8 @@ In Kilo, this will be a transitory value of provision_state, and never represented in target_provision_state. """ +# TODO(deva): add CLEAN* states + ERROR = 'error' """ An error occurred during node processing. @@ -140,10 +169,18 @@ watchers['on_enter'] = on_enter machine = fsm.FSM() # Add stable states +machine.add_state(MANAGEABLE, **watchers) machine.add_state(AVAILABLE, **watchers) machine.add_state(ACTIVE, **watchers) machine.add_state(ERROR, **watchers) +# From MANAGEABLE, a node may be made available +# TODO(deva): add CLEAN* states to this path +machine.add_transition(MANAGEABLE, AVAILABLE, 'provide') + +# From AVAILABLE, a node may be made unavailable by managing it +machine.add_transition(AVAILABLE, MANAGEABLE, 'manage') + # Add deploy* states # NOTE(deva): Juno shows a target_provision_state of DEPLOYDONE # this is changed in Kilo to ACTIVE @@ -165,6 +202,8 @@ machine.add_transition(DEPLOYING, DEPLOYFAIL, 'fail') # A failed deployment may be retried # ironic/conductor/manager.py:do_node_deploy() machine.add_transition(DEPLOYFAIL, DEPLOYING, 'rebuild') +# NOTE(deva): Juno allows a client to send "active" to initiate a rebuild +machine.add_transition(DEPLOYFAIL, DEPLOYING, 'deploy') # A deployment may also wait on external callbacks machine.add_transition(DEPLOYING, DEPLOYWAIT, 'wait') |