diff options
author | Jay Pipes <jaypipes@gmail.com> | 2016-10-23 10:58:25 +0200 |
---|---|---|
committer | Jay Pipes <jaypipes@gmail.com> | 2016-11-03 11:48:53 -0400 |
commit | 69bac2f99c01b3e5bc09179c03fd24606e12d041 (patch) | |
tree | eb7a5e339b7668c83f046b654ec37e445ad09cf3 /nova/exception.py | |
parent | 419cd6a8bc5e833de8d8d686bf7bd9452ed0578f (diff) | |
download | nova-69bac2f99c01b3e5bc09179c03fd24606e12d041.tar.gz |
placement: raise exc when resource class not found
The ResourceProvider.set_inventory() method was not raising NotFound
when an Inventory object in the supplied InventoryList object was using
a resource class that did not exist in the resource class cache. This
patch fixes that by having the string_from_id() and id_from_string()
methods of the resource class cache raise ResourceClassNotFound instead
of returning None. We raise specific ResourceClassNotFound and
InventoryWithResourceClassNotFound exception subclasses to differentiate
in the inventory API handler between an unknown resource class and a
known resource class that doesn't exist in a given resource provider's
inventory.
We return a 400 Not Found when InventoryWithResourceClassNotFound is
raised on updating a single inventory, but return a 409 Conflict when
InventoryWithResourceClassNotFound is raised on updating a set of
inventory records since in the latter scenario, it represents a race
condition that frankly should not occur.
Change-Id: I350b02dcdbaa9d30d885cd085f60daa6b53a7745
Diffstat (limited to 'nova/exception.py')
-rw-r--r-- | nova/exception.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/nova/exception.py b/nova/exception.py index c9e5212055..e56d2ad6ee 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -2114,10 +2114,18 @@ class ConcurrentUpdateDetected(NovaException): "Please retry your update") +class ResourceClassNotFound(NotFound): + msg_fmt = _("No such resource class %(resource_class)s.") + + class ResourceProviderInUse(NovaException): msg_fmt = _("Resource provider has allocations.") +class InventoryWithResourceClassNotFound(NotFound): + msg_fmt = _("No inventory of class %(resource_class)s found.") + + class InvalidInventory(Invalid): msg_fmt = _("Inventory for '%(resource_class)s' on " "resource provider '%(resource_provider)s' invalid.") |