diff options
| -rw-r--r-- | nova/api/openstack/compute/servers.py | 3 | ||||
| -rw-r--r-- | nova/compute/api.py | 7 | ||||
| -rw-r--r-- | nova/tests/compute/test_compute.py | 7 |
3 files changed, 9 insertions, 8 deletions
diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index 1b758f23f..e386ee1c7 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -540,6 +540,9 @@ class Controller(wsgi.Controller): except exception.MarkerNotFound as e: msg = _('marker [%s] not found') % marker raise webob.exc.HTTPBadRequest(explanation=msg) + except exception.FlavorNotFound as e: + msg = _("Flavor could not be found") + raise webob.exc.HTTPUnprocessableEntity(explanation=msg) if is_detail: self._add_instance_faults(context, instance_list) diff --git a/nova/compute/api.py b/nova/compute/api.py index c3b61d0a3..48068eca1 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1128,11 +1128,8 @@ class API(base.Base): filters = {} def _remap_flavor_filter(flavor_id): - try: - instance_type = instance_types.get_instance_type_by_flavor_id( - flavor_id) - except exception.FlavorNotFound: - raise ValueError() + instance_type = instance_types.get_instance_type_by_flavor_id( + flavor_id) filters['instance_type_id'] = instance_type['id'] diff --git a/nova/tests/compute/test_compute.py b/nova/tests/compute/test_compute.py index 3ee294272..264566d7a 100644 --- a/nova/tests/compute/test_compute.py +++ b/nova/tests/compute/test_compute.py @@ -4254,9 +4254,10 @@ class ComputeAPITestCase(BaseTestCase): search_opts={'flavor': 5}) self.assertEqual(len(instances), 0) - # ensure unknown filter maps to an empty list, not an exception - instances = self.compute_api.get_all(c, search_opts={'flavor': 99}) - self.assertEqual(instances, []) + # ensure unknown filter maps to an exception + self.assertRaises(exception.FlavorNotFound, + self.compute_api.get_all, c, + search_opts={'flavor': 99}) instances = self.compute_api.get_all(c, search_opts={'flavor': 3}) self.assertEqual(len(instances), 1) |
