diff options
| author | YangLei <yanglyy@cn.ibm.com> | 2013-05-21 15:00:53 +0800 |
|---|---|---|
| committer | YangLei <yanglyy@cn.ibm.com> | 2013-05-28 14:32:22 +0800 |
| commit | 62ca3783ce4fcc0b03e96936972abc83b54c772f (patch) | |
| tree | a2546be8b72532b335c177b8315c911e9d8dd4d8 | |
| parent | eebcd6f2058d78c87dd2ee0a9a90f21f33f44e97 (diff) | |
| download | nova-62ca3783ce4fcc0b03e96936972abc83b54c772f.tar.gz nova-62ca3783ce4fcc0b03e96936972abc83b54c772f.tar.xz nova-62ca3783ce4fcc0b03e96936972abc83b54c772f.zip | |
No relevant message when stop a stopped VM
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
| -rw-r--r-- | nova/compute/api.py | 2 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index f31aefb9b..9f61788ae 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1310,7 +1310,7 @@ class API(base.Base): @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.""" diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 3101e3aa2..6711de77f 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -5119,6 +5119,16 @@ class ComputeAPITestCase(BaseTestCase): 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': ''}) |
