101
109
REBOOT = 'rebooting'
102
110
""" Node is rebooting. """
113
#####################
114
# State machine model
115
#####################
116
def on_exit(old_state, event):
117
"""Used to log when a state is exited."""
118
LOG.debug("Exiting old state '%s' in response to event '%s'",
122
def on_enter(new_state, event):
123
"""Used to log when entering a state."""
124
LOG.debug("Entering new state '%s' in response to event '%s'",
128
watchers['on_exit'] = on_exit
129
watchers['on_enter'] = on_enter
134
machine.add_state(NOSTATE, **watchers)
135
machine.add_state(ACTIVE, **watchers)
136
machine.add_state(ERROR, **watchers)
139
machine.add_state(DEPLOYDONE, target=ACTIVE, **watchers)
140
machine.add_state(DEPLOYING, target=DEPLOYDONE, **watchers)
141
machine.add_state(DEPLOYWAIT, **watchers)
142
machine.add_state(DEPLOYFAIL, **watchers)
145
machine.add_state(DELETED, target=NOSTATE, **watchers)
146
machine.add_state(DELETING, target=DELETED, **watchers)
149
# From NOSTATE, a deployment may be started
150
machine.add_transition(NOSTATE, DEPLOYING, 'deploy')
152
# A deployment may fail
153
machine.add_transition(DEPLOYING, DEPLOYFAIL, 'fail')
155
# A failed deployment may be retried
156
# ironic/conductor/manager.py:do_node_deploy()
157
machine.add_transition(DEPLOYFAIL, DEPLOYING, 'rebuild')
159
# A deployment may also wait on external callbacks
160
machine.add_transition(DEPLOYING, DEPLOYWAIT, 'wait')
161
machine.add_transition(DEPLOYWAIT, DEPLOYING, 'resume')
163
# A deployment waiting on callback may time out
164
machine.add_transition(DEPLOYWAIT, DEPLOYFAIL, 'fail')
166
# A deployment may complete
167
machine.add_transition(DEPLOYING, ACTIVE, 'done')
169
# An active instance may be re-deployed
170
# ironic/conductor/manager.py:do_node_deploy()
171
machine.add_transition(ACTIVE, DEPLOYING, 'rebuild')
173
# An active instance may be deleted
174
# ironic/conductor/manager.py:do_node_tear_down()
175
machine.add_transition(ACTIVE, DELETING, 'delete')
177
# While a deployment is waiting, it may be deleted
178
# ironic/conductor/manager.py:do_node_tear_down()
179
machine.add_transition(DEPLOYWAIT, DELETING, 'delete')
181
# A failed deployment may also be deleted
182
# ironic/conductor/manager.py:do_node_tear_down()
183
machine.add_transition(DEPLOYFAIL, DELETING, 'delete')
185
# A delete may complete
186
machine.add_transition(DELETING, NOSTATE, 'done')
188
# These states can also transition to error
189
machine.add_transition(NOSTATE, ERROR, 'error')
190
machine.add_transition(DEPLOYING, ERROR, 'error')
191
machine.add_transition(ACTIVE, ERROR, 'error')
192
machine.add_transition(DELETING, ERROR, 'error')
194
# An errored instance can be rebuilt
195
# ironic/conductor/manager.py:do_node_deploy()
196
machine.add_transition(ERROR, DEPLOYING, 'rebuild')
198
# ironic/conductor/manager.py:do_node_tear_down()
199
machine.add_transition(ERROR, DELETING, 'delete')