Merge "Allow deleting nodes in ENROLL state"

This commit is contained in:
Jenkins 2015-07-27 10:46:02 +00:00 committed by Gerrit Code Review
commit 7f88443bce
3 changed files with 6 additions and 7 deletions

View File

@ -163,6 +163,9 @@ INSPECTFAIL = 'inspect failed'
UPDATE_ALLOWED_STATES = (DEPLOYFAIL, INSPECTING, INSPECTFAIL, CLEANFAIL, ERROR)
"""Transitional states in which we allow updating a node."""
DELETE_ALLOWED_STATES = (AVAILABLE, NOSTATE, MANAGEABLE, ENROLL)
"""States in which node deletion is allowed."""
##############
# Power states

View File

@ -1379,8 +1379,6 @@ class ConductorManager(periodic_task.PeriodicTasks):
raise exception.NodeAssociated(node=node.uuid,
instance=node.instance_uuid)
# TODO(lucasagomes): We should add ENROLLED once it's part of our
# state machine
# NOTE(lucasagomes): For the *FAIL states we users should
# move it to a safe state prior to deletion. This is because we
# should try to avoid deleting a node in a dirty/whacky state,
@ -1391,15 +1389,13 @@ class ConductorManager(periodic_task.PeriodicTasks):
# INSPECTIONFAIL -> MANAGEABLE
# DEPLOYFAIL -> DELETING
# ZAPFAIL -> MANAGEABLE (in the future)
valid_states = (states.AVAILABLE, states.NOSTATE,
states.MANAGEABLE)
if (not node.maintenance and
node.provision_state not in valid_states):
node.provision_state not in states.DELETE_ALLOWED_STATES):
msg = (_('Can not delete node "%(node)s" while it is in '
'provision state "%(state)s". Valid provision states '
'to perform deletion are: "%(valid_states)s"') %
{'node': node.uuid, 'state': node.provision_state,
'valid_states': valid_states})
'valid_states': states.DELETE_ALLOWED_STATES})
raise exception.InvalidState(msg)
if node.console_enabled:
try:

View File

@ -2311,7 +2311,7 @@ class DestroyNodeTestCase(_ServiceSetUpMixin, tests_db_base.DbTestCase):
def test_destroy_node(self):
self._start_service()
for state in (states.MANAGEABLE, states.NOSTATE, states.AVAILABLE):
for state in states.DELETE_ALLOWED_STATES:
node = obj_utils.create_test_node(self.context,
provision_state=state)
self.service.destroy_node(self.context, node.uuid)