Skip to content

Commit

Permalink
No relevant message when stop a stopped VM
Browse files Browse the repository at this point in the history
When user tries to stop a stopped VM, there is no need to stop it again,
and We need return it's vm_state.

Fixes bug 1181934

Change-Id: I71772dfcead440cb49b6ccdbb4e1a891475bb75e
(cherry picked from commit 62ca378)
  • Loading branch information
iamhappg authored and glongwave committed Aug 9, 2013
1 parent 37e3b55 commit df365c6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion nova/compute/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1280,7 +1280,7 @@ def force_delete(self, context, instance):
@check_instance_lock
@check_instance_host
@check_instance_state(vm_state=[vm_states.ACTIVE, vm_states.RESCUED,
vm_states.ERROR, vm_states.STOPPED],
vm_states.ERROR],
task_state=[None])
def stop(self, context, instance, do_cast=True):
"""Stop an instance."""
Expand Down
10 changes: 10 additions & 0 deletions nova/tests/compute/test_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -4679,6 +4679,16 @@ def test_stop(self):

db.instance_destroy(self.context, instance['uuid'])

def test_stop_a_stopped_inst(self):
instance = jsonutils.to_primitive(self._create_fake_instance(
{'vm_state': vm_states.STOPPED}))

self.assertRaises(exception.InstanceInvalidState,
self.compute_api.stop,
self.context, instance)

db.instance_destroy(self.context, instance['uuid'])

def test_stop_no_host(self):
instance = self._create_fake_instance(params={'host': ''})

Expand Down

0 comments on commit df365c6

Please sign in to comment.