Don't allow reboot when instance in rebooting_hard

It shouldn't allow reboot a instance while the instance in
rebooting_hard task state.
If the instance is in rebooting_hard, solf reboot action is
meaningless.

Change-Id: I43147104a7473eaaf1b86f84386bb28b7e3574c3
Closes-bug: #1288926
This commit is contained in:
liu-sheng 2014-03-10 16:20:16 +08:00
parent 4bf25aac3f
commit 00f5125745
2 changed files with 6 additions and 1 deletions

View File

@ -2072,7 +2072,8 @@ class API(base.Base):
state=instance['vm_state'],
method='reboot')
if ((reboot_type == 'SOFT' and
instance['task_state'] == task_states.REBOOTING) or
instance['task_state'] in
(task_states.REBOOTING, task_states.REBOOTING_HARD)) or
(reboot_type == 'HARD' and
instance['task_state'] == task_states.REBOOTING_HARD)):
raise exception.InstanceInvalidState(

View File

@ -398,6 +398,10 @@ class _ComputeAPIUnitTestMixIn(object):
def test_reboot_soft_rebooting(self):
self._test_reboot_type_fails('SOFT', task_state=task_states.REBOOTING)
def test_reboot_soft_rebooting_hard(self):
self._test_reboot_type_fails('SOFT',
task_state=task_states.REBOOTING_HARD)
def test_reboot_soft_rescued(self):
self._test_reboot_type_fails('SOFT', vm_state=vm_states.RESCUED)