summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Baker <sbaker@redhat.com>2015-10-26 17:04:47 +0900
committerSteve Baker <sbaker@redhat.com>2015-11-06 13:04:53 +1300
commitcf60e32d208d776831329c057c5ccd156d423ee5 (patch)
tree1c4a57cd6c26f75097db500076954253ef7804f9
parent534e3e9d076f763f836510856cb890571bfb79c0 (diff)
downloadheat-cf60e32d208d776831329c057c5ccd156d423ee5.tar.gz
Resource.has_interface check get_resource_info result
This changes the behaviour of has_interface to not assume that get_resource_info always returns a type. There are circumstances when it won't, such as when the type is no longer in the new registry during a stack update. Change-Id: Idd9dade85d105dc6839ff0740e6c80aca6b7ad9f Closes-Bug: #1509880 (cherry picked from commit af3355d34c8b8e4030f7a928a6c7cb9ad70e0795)
-rw-r--r--heat/engine/resource.py2
-rw-r--r--heat/tests/test_resource.py6
2 files changed, 7 insertions, 1 deletions
diff --git a/heat/engine/resource.py b/heat/engine/resource.py
index bb51964e1..d8079a48a 100644
--- a/heat/engine/resource.py
+++ b/heat/engine/resource.py
@@ -331,7 +331,7 @@ class Resource(object):
return True
ri = self.stack.env.get_resource_info(self.type(),
self.name)
- return ri.name == resource_type
+ return ri is not None and ri.name == resource_type
def implementation_signature(self):
'''
diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py
index b77466ebf..2dda46eab 100644
--- a/heat/tests/test_resource.py
+++ b/heat/tests/test_resource.py
@@ -270,6 +270,12 @@ class ResourceTest(common.HeatTestCase):
res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
self.assertTrue(res.has_interface('GenericResourceType'))
+ def test_has_interface_mapping_no_match(self):
+ tmpl = rsrc_defn.ResourceDefinition('test_resource',
+ 'OS::Test::GenoricResort')
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
+ self.assertFalse(res.has_interface('GenericResourceType'))
+
def test_created_time(self):
tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo')
res = generic_rsrc.GenericResource('test_res_new', tmpl, self.stack)