diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-12 23:15:13 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-12 23:15:13 +0000 |
| commit | 0b1eee6bb39243ef117f65b0eaf3d6f14b0aa3d7 (patch) | |
| tree | 41b1f7735040e59425cf6ed60828a66916c4e596 | |
| parent | 1d8af7541495f460d573dbb245aed8750c4bcbb2 (diff) | |
| parent | 843af52d49554f15c13e5617b9eb672c35c7fe51 (diff) | |
Merge "Check flavor id on resize."
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 4 | ||||
| -rw-r--r-- | nova/compute/api.py | 7 | ||||
| -rw-r--r-- | nova/exception.py | 4 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 4 |
4 files changed, 8 insertions, 11 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index fc4905a11..ba23cb50b 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -949,8 +949,8 @@ class Controller(wsgi.Controller): except exception.FlavorNotFound: msg = _("Unable to locate requested flavor.") raise exc.HTTPBadRequest(explanation=msg) - except exception.CannotResizeToSameSize: - msg = _("Resize requires a change in size.") + except exception.CannotResizeToSameFlavor: + msg = _("Resize requires a flavor change.") raise exc.HTTPBadRequest(explanation=msg) except exception.InstanceInvalidState as state_error: common.raise_http_conflict_for_instance_invalid_state(state_error, diff --git a/nova/compute/api.py b/nova/compute/api.py index a9ab17a13..a85e01d46 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1580,11 +1580,8 @@ class API(base.Base): # NOTE(markwash): look up the image early to avoid auth problems later image = self.image_service.show(context, instance['image_ref']) - current_memory_mb = current_instance_type['memory_mb'] - new_memory_mb = new_instance_type['memory_mb'] - - if (current_memory_mb == new_memory_mb) and flavor_id: - raise exception.CannotResizeToSameSize() + if same_instance_type and flavor_id: + raise exception.CannotResizeToSameFlavor() # ensure there is sufficient headroom for upsizes deltas = self._upsize_quota_delta(context, new_instance_type, diff --git a/nova/exception.py b/nova/exception.py index 1f51a08b5..ad90559bb 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -909,8 +909,8 @@ class PasteAppNotFound(NovaException): message = _("Could not load paste app '%(name)s' from %(path)s") -class CannotResizeToSameSize(NovaException): - message = _("When resizing, instances must change size!") +class CannotResizeToSameFlavor(NovaException): + message = _("When resizing, instances must change flavor!") class ImageTooLarge(NovaException): diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 93330093f..fe54aad90 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -3456,7 +3456,7 @@ class ComputeAPITestCase(BaseTestCase): self.compute.terminate_instance(context, instance=instance) - def test_resize_same_size_fails(self): + def test_resize_same_flavor_fails(self): """Ensure invalid flavors raise""" context = self.context.elevated() instance = self._create_fake_instance() @@ -3465,7 +3465,7 @@ class ComputeAPITestCase(BaseTestCase): self.compute.run_instance(self.context, instance=instance) - self.assertRaises(exception.CannotResizeToSameSize, + self.assertRaises(exception.CannotResizeToSameFlavor, self.compute_api.resize, context, instance, 1) self.compute.terminate_instance(context, instance=instance) |
