Merge "[placement] Stringify class and provider uuid in error"
This commit is contained in:
@@ -739,8 +739,11 @@ def _check_capacity_exceeded(conn, allocs):
|
||||
# Ensure that all providers have existing inventory
|
||||
missing_provs = provider_uuids - provs_with_inv
|
||||
if missing_provs:
|
||||
raise exception.InvalidInventory(resource_class=str(res_classes),
|
||||
resource_provider=missing_provs)
|
||||
class_str = ', '.join([fields.ResourceClass.from_index(res_class)
|
||||
for res_class in res_classes])
|
||||
provider_str = ', '.join(missing_provs)
|
||||
raise exception.InvalidInventory(resource_class=class_str,
|
||||
resource_provider=provider_str)
|
||||
|
||||
res_providers = {}
|
||||
for alloc in allocs:
|
||||
|
||||
@@ -731,8 +731,14 @@ class TestAllocationListCreateDelete(ResourceProviderBaseCase):
|
||||
self.context, objects=[allocation_1, allocation_2])
|
||||
|
||||
# There's no inventory, we have a failure.
|
||||
self.assertRaises(exception.InvalidInventory,
|
||||
allocation_list.create_all)
|
||||
error = self.assertRaises(exception.InvalidInventory,
|
||||
allocation_list.create_all)
|
||||
# Confirm that the resource class string, not index, is in
|
||||
# the exception and resource providers are listed by uuid.
|
||||
self.assertIn(rp1_class, str(error))
|
||||
self.assertIn(rp2_class, str(error))
|
||||
self.assertIn(rp1.uuid, str(error))
|
||||
self.assertIn(rp2.uuid, str(error))
|
||||
|
||||
# Add inventory for one of the two resource providers. This should also
|
||||
# fail, since rp2 has no inventory.
|
||||
|
||||
Reference in New Issue
Block a user