diff options
author | Rakesh H S <rh-s@hpe.com> | 2016-03-01 12:08:42 +0530 |
---|---|---|
committer | Rakesh H S <rh-s@hpe.com> | 2016-03-01 12:08:42 +0530 |
commit | 645810eb4038bea334b7c996e49a4ed4f7379290 (patch) | |
tree | 4fe594b8fdb7082537a20a06afb7b67afe8cfca0 /heat/engine/resource.py | |
parent | 4116ec36ba73bdcd33338db0a05f4b7b0bc9c0cc (diff) | |
download | heat-645810eb4038bea334b7c996e49a4ed4f7379290.tar.gz |
Raise ResourceTypeNotFound in get_resource_info()
Rather than return None when doing get_resource_info() on resource types
that don't exist, raise a ResourceTypeNotFound exception. We can then catch
that and turn it into StackValidationFailed where appropriate, but we don't
make assumptions about where the code is being called from at the point where
we raise the exception.
Change-Id: Idf6f837befea8ccb10fdaf9196490da3dd5be1fb
Related-Bug: #1447194
Related-Bug: #1518458
Closes-Bug: #1550179
Diffstat (limited to 'heat/engine/resource.py')
-rw-r--r-- | heat/engine/resource.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/heat/engine/resource.py b/heat/engine/resource.py index e81da4029..324b306c3 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -422,9 +422,14 @@ class Resource(object): """ if self.type() == resource_type: return True - ri = self.stack.env.get_resource_info(self.type(), - self.name) - return ri is not None and ri.name == resource_type + + try: + ri = self.stack.env.get_resource_info(self.type(), + self.name) + except exception.ResourceTypeNotFound: + return False + else: + return ri.name == resource_type def implementation_signature(self): """Return a tuple defining the implementation. |