diff --git a/nova/objects/resource_provider.py b/nova/objects/resource_provider.py index bc61a92d9c..54377d06b3 100644 --- a/nova/objects/resource_provider.py +++ b/nova/objects/resource_provider.py @@ -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: diff --git a/nova/tests/functional/db/test_resource_provider.py b/nova/tests/functional/db/test_resource_provider.py index 1774195e8d..355c8d7f3b 100644 --- a/nova/tests/functional/db/test_resource_provider.py +++ b/nova/tests/functional/db/test_resource_provider.py @@ -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.