Raise ApiError in response to InstanceTypeNotFound
* Updates methods in nova.compute.instance_types to catch
InstanceTypeNotFound exceptions and re-raise them as ApiError.
- Previously, the methods in instance_types were raising ApiError in
response to DBError, but the underlying db calls have since been
updated to detect empty results and throw more specific exceptions.
* Updates get_instance_type_by_flavor_id to not try to catch DBError,
as the underlying db call only ever raises FlavorNotFound.
get_instance_type_by_flavor_id should not raise ApiError, as callers
expect the FlavorNotFound exception and know how to handle it.
* Fixes bug 872618
Change-Id: I8652f04889adb448017afd253ecdcc840fbb660f
This commit is contained in:
1
Authors
1
Authors
@@ -107,6 +107,7 @@ Lvov Maxim <usrleon@gmail.com>
|
|||||||
Mandell Degerness <mdegerne@gmail.com>
|
Mandell Degerness <mdegerne@gmail.com>
|
||||||
Mark McLoughlin <markmc@redhat.com>
|
Mark McLoughlin <markmc@redhat.com>
|
||||||
Mark Washenberger <mark.washenberger@rackspace.com>
|
Mark Washenberger <mark.washenberger@rackspace.com>
|
||||||
|
Maru Newby <mnewby@internap.com>
|
||||||
Masanori Itoh <itoumsn@nttdata.co.jp>
|
Masanori Itoh <itoumsn@nttdata.co.jp>
|
||||||
Matt Dietz <matt.dietz@rackspace.com>
|
Matt Dietz <matt.dietz@rackspace.com>
|
||||||
Matthew Hooker <matt@cloudscaling.com>
|
Matthew Hooker <matt@cloudscaling.com>
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ class InstanceTypeTestCase(test.TestCase):
|
|||||||
def test_will_not_get_bad_default_instance_type(self):
|
def test_will_not_get_bad_default_instance_type(self):
|
||||||
"""ensures error raised on bad default instance type"""
|
"""ensures error raised on bad default instance type"""
|
||||||
FLAGS.default_instance_type = 'unknown_flavor'
|
FLAGS.default_instance_type = 'unknown_flavor'
|
||||||
self.assertRaises(exception.InstanceTypeNotFoundByName,
|
self.assertRaises(exception.ApiError,
|
||||||
instance_types.get_default_instance_type)
|
instance_types.get_default_instance_type)
|
||||||
|
|
||||||
def test_will_get_instance_type_by_id(self):
|
def test_will_get_instance_type_by_id(self):
|
||||||
@@ -185,12 +185,12 @@ class InstanceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_will_not_get_instance_type_by_unknown_id(self):
|
def test_will_not_get_instance_type_by_unknown_id(self):
|
||||||
"""Ensure get by name returns default flavor with no name"""
|
"""Ensure get by name returns default flavor with no name"""
|
||||||
self.assertRaises(exception.InstanceTypeNotFound,
|
self.assertRaises(exception.ApiError,
|
||||||
instance_types.get_instance_type, 10000)
|
instance_types.get_instance_type, 10000)
|
||||||
|
|
||||||
def test_will_not_get_instance_type_with_bad_id(self):
|
def test_will_not_get_instance_type_with_bad_id(self):
|
||||||
"""Ensure get by name returns default flavor with bad name"""
|
"""Ensure get by name returns default flavor with bad name"""
|
||||||
self.assertRaises(exception.InstanceTypeNotFound,
|
self.assertRaises(exception.ApiError,
|
||||||
instance_types.get_instance_type, 'asdf')
|
instance_types.get_instance_type, 'asdf')
|
||||||
|
|
||||||
def test_instance_type_get_by_None_name_returns_default(self):
|
def test_instance_type_get_by_None_name_returns_default(self):
|
||||||
@@ -201,7 +201,7 @@ class InstanceTypeTestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_will_not_get_instance_type_with_bad_name(self):
|
def test_will_not_get_instance_type_with_bad_name(self):
|
||||||
"""Ensure get by name returns default flavor with bad name"""
|
"""Ensure get by name returns default flavor with bad name"""
|
||||||
self.assertRaises(exception.InstanceTypeNotFoundByName,
|
self.assertRaises(exception.ApiError,
|
||||||
instance_types.get_instance_type_by_name, 10000)
|
instance_types.get_instance_type_by_name, 10000)
|
||||||
|
|
||||||
def test_will_not_get_instance_by_unknown_flavor_id(self):
|
def test_will_not_get_instance_by_unknown_flavor_id(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user