diff options
author | Zane Bitter <zbitter@redhat.com> | 2016-12-05 14:58:20 -0500 |
---|---|---|
committer | Zane Bitter <zbitter@redhat.com> | 2016-12-05 14:58:20 -0500 |
commit | f310a1f6bc84e4c96e283b35514894065513b6f8 (patch) | |
tree | 8d64f35cf32d512bcaa7f87e4efc9ad01aa2cfcc /heat/objects | |
parent | 4078e228dd713e3b97b17b5c625bc2a710dd2eb0 (diff) | |
download | heat-f310a1f6bc84e4c96e283b35514894065513b6f8.tar.gz |
Handle ambiguous physical resource IDs
It's possible that we could end up with multiple resources with the same
physical resource ID, but that would be undetectable since we return only
one from the database layer. This change allows us to detect the problem an
return an error where the result is rendered ambiguous.
Change-Id: I2c5ddbe6731c33a09ec7c4a7b91dcfe414da4385
Diffstat (limited to 'heat/objects')
-rw-r--r-- | heat/objects/resource.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/heat/objects/resource.py b/heat/objects/resource.py index 0c9b34b03..d49efbd8a 100644 --- a/heat/objects/resource.py +++ b/heat/objects/resource.py @@ -202,11 +202,12 @@ class Resource( return cls._from_db_object(cls(context), context, resource_db) @classmethod - def get_by_physical_resource_id(cls, context, physical_resource_id): - resource_db = db_api.resource_get_by_physical_resource_id( + def get_all_by_physical_resource_id(cls, context, physical_resource_id): + matches = db_api.resource_get_all_by_physical_resource_id( context, physical_resource_id) - return cls._from_db_object(cls(context), context, resource_db) + return [cls._from_db_object(cls(context), context, resource_db) + for resource_db in matches] @classmethod def update_by_id(cls, context, resource_id, values): |