~ubuntu-branches/ubuntu/vivid/ironic/vivid-updates

« back to all changes in this revision

Viewing changes to ironic/common/states.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2015-03-30 11:14:57 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20150330111457-kr4ju3guf22m4vbz
Tags: 2015.1~b3-0ubuntu1
* New upstream release.
  + d/control: 
    - Align with upstream dependencies.
    - Add dh-python to build-dependencies.
    - Add psmisc as a dependency. (LP: #1358820)
  + d/p/fix-requirements.patch: Rediffed.
  + d/ironic-conductor.init.in: Fixed typos in LSB headers,
    thanks to JJ Asghar. (LP: #1429962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
        'deleted': 'delete',
44
44
        'manage': 'manage',
45
45
        'provide': 'provide',
46
 
    }
 
46
        'inspect': 'inspect',
 
47
}
47
48
""" Mapping of state-changing events that are PUT to the REST API
48
49
 
49
50
This is a mapping of target states which are PUT to the API, eg,
118
119
represented in target_provision_state.
119
120
"""
120
121
 
121
 
# TODO(deva): add CLEAN* states
 
122
CLEANING = 'cleaning'
 
123
""" Node is being automatically cleaned to prepare it for provisioning. """
 
124
 
 
125
CLEANFAIL = 'clean failed'
 
126
""" Node failed cleaning. This requires operator intervention to resolve. """
122
127
 
123
128
ERROR = 'error'
124
129
""" An error occurred during node processing.
133
138
provision_state via the REST API.
134
139
"""
135
140
 
 
141
INSPECTING = 'inspecting'
 
142
""" Node is under inspection.
 
143
 
 
144
This is the provision state used when inspection is started. A successfully
 
145
inspected node shall transition to MANAGEABLE status.
 
146
"""
 
147
 
 
148
 
 
149
INSPECTFAIL = 'inspect failed'
 
150
""" Node inspection failed. """
 
151
 
 
152
 
 
153
UPDATE_ALLOWED_STATES = (DEPLOYFAIL, INSPECTING, INSPECTFAIL)
 
154
"""Transitional states in which we allow updating a node."""
 
155
 
136
156
 
137
157
##############
138
158
# Power states
169
189
machine = fsm.FSM()
170
190
 
171
191
# Add stable states
172
 
machine.add_state(MANAGEABLE, **watchers)
173
 
machine.add_state(AVAILABLE, **watchers)
174
 
machine.add_state(ACTIVE, **watchers)
175
 
machine.add_state(ERROR, **watchers)
176
 
 
177
 
# From MANAGEABLE, a node may be made available
178
 
# TODO(deva): add CLEAN* states to this path
179
 
machine.add_transition(MANAGEABLE, AVAILABLE, 'provide')
180
 
 
181
 
# From AVAILABLE, a node may be made unavailable by managing it
182
 
machine.add_transition(AVAILABLE, MANAGEABLE, 'manage')
 
192
machine.add_state(MANAGEABLE, stable=True, **watchers)
 
193
machine.add_state(AVAILABLE, stable=True, **watchers)
 
194
machine.add_state(ACTIVE, stable=True, **watchers)
 
195
machine.add_state(ERROR, stable=True, **watchers)
183
196
 
184
197
# Add deploy* states
185
198
# NOTE(deva): Juno shows a target_provision_state of DEPLOYDONE
188
201
machine.add_state(DEPLOYWAIT, target=ACTIVE, **watchers)
189
202
machine.add_state(DEPLOYFAIL, target=ACTIVE, **watchers)
190
203
 
 
204
# Add clean* states
 
205
machine.add_state(CLEANING, target=AVAILABLE, **watchers)
 
206
machine.add_state(CLEANFAIL, target=AVAILABLE, **watchers)
 
207
 
191
208
# Add delete* states
192
 
# NOTE(deva): Juno shows a target_provision_state of DELETED
193
 
#             this is changed in Kilo to AVAILABLE
194
209
machine.add_state(DELETING, target=AVAILABLE, **watchers)
195
210
 
196
211
# From AVAILABLE, a deployment may be started
197
212
machine.add_transition(AVAILABLE, DEPLOYING, 'deploy')
198
213
 
 
214
# Add inspect* states.
 
215
machine.add_state(INSPECTING, target=MANAGEABLE, **watchers)
 
216
machine.add_state(INSPECTFAIL, target=MANAGEABLE, **watchers)
 
217
 
199
218
# A deployment may fail
200
219
machine.add_transition(DEPLOYING, DEPLOYFAIL, 'fail')
201
220
 
231
250
# ironic/conductor/manager.py:do_node_tear_down()
232
251
machine.add_transition(DEPLOYFAIL, DELETING, 'delete')
233
252
 
234
 
# A delete may complete
235
 
machine.add_transition(DELETING, AVAILABLE, 'done')
236
 
 
237
253
# This state can also transition to error
238
254
machine.add_transition(DELETING, ERROR, 'error')
239
255
 
 
256
# When finished deleting, a node will begin cleaning
 
257
machine.add_transition(DELETING, CLEANING, 'clean')
 
258
 
 
259
# If cleaning succeeds, it becomes available for scheduling
 
260
machine.add_transition(CLEANING, AVAILABLE, 'done')
 
261
 
 
262
# If cleaning fails, wait for operator intervention
 
263
machine.add_transition(CLEANING, CLEANFAIL, 'fail')
 
264
 
 
265
# A node that fails cleaning may be put back through cleaning
 
266
machine.add_transition(CLEANFAIL, CLEANING, 'clean')
 
267
 
 
268
# An operator may want to hold a CLEANFAIL node in operator for zapping or
 
269
# outside-of-Ironic operations (like replacing hardware)
 
270
machine.add_transition(CLEANFAIL, MANAGEABLE, 'manage')
 
271
 
 
272
# From MANAGEABLE, a node may move to available after going through cleaning
 
273
machine.add_transition(MANAGEABLE, CLEANING, 'provide')
 
274
 
 
275
# From AVAILABLE, a node may be made unavailable by managing it
 
276
machine.add_transition(AVAILABLE, MANAGEABLE, 'manage')
 
277
 
240
278
# An errored instance can be rebuilt
241
279
# ironic/conductor/manager.py:do_node_deploy()
242
280
machine.add_transition(ERROR, DEPLOYING, 'rebuild')
243
281
# or deleted
244
282
# ironic/conductor/manager.py:do_node_tear_down()
245
283
machine.add_transition(ERROR, DELETING, 'delete')
 
284
 
 
285
# Added transitions for inspection.
 
286
# Initiate inspection.
 
287
machine.add_transition(MANAGEABLE, INSPECTING, 'inspect')
 
288
 
 
289
# ironic/conductor/manager.py:inspect_hardware().
 
290
machine.add_transition(INSPECTING, MANAGEABLE, 'done')
 
291
 
 
292
# Inspection may fail.
 
293
machine.add_transition(INSPECTING, INSPECTFAIL, 'fail')
 
294
 
 
295
# Move the node to manageable state for any other
 
296
# action.
 
297
machine.add_transition(INSPECTFAIL, MANAGEABLE, 'manage')
 
298
 
 
299
# Reinitiate the inspect after inspectfail.
 
300
machine.add_transition(INSPECTFAIL, INSPECTING, 'inspect')