diff --git a/heat/engine/resource.py b/heat/engine/resource.py index b6827cca1f..e260010b94 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -1208,7 +1208,7 @@ class Resource(status.ResourceStatus): yield self._do_action(self.ADOPT, resource_data={ 'resource_id': self.external_id}) - self.check() + yield self.check() return # This method can be called when we replace a resource, too. In that diff --git a/heat/tests/generic_resource.py b/heat/tests/generic_resource.py index 5f98af74a0..4bad64ea22 100644 --- a/heat/tests/generic_resource.py +++ b/heat/tests/generic_resource.py @@ -60,6 +60,12 @@ class GenericResource(resource.Resource): self.type()) +class CheckableResource(GenericResource): + def handle_check(self): + LOG.warning(('Checking generic resource (Type "%s")'), + self.type()) + + class CancellableResource(GenericResource): def check_create_complete(self, cookie): return True diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index 1bac44654a..2d30bd464b 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -366,6 +366,15 @@ class ResourceTest(common.HeatTestCase): self.assertEqual((res.CHECK, res.COMPLETE), res.state) self.assertEqual('f00d', res.resource_id) + def test_create_from_external_with_check(self): + tmpl = rsrc_defn.ResourceDefinition( + 'test_resource', 'GenericResourceType', + external_id='f00d') + res = generic_rsrc.CheckableResource('test_resource', tmpl, self.stack) + scheduler.TaskRunner(res.create)() + self.assertEqual((res.CHECK, res.COMPLETE), res.state) + self.assertEqual('f00d', res.resource_id) + def test_create_from_external_not_found(self): external_id = 'f00d' tmpl = rsrc_defn.ResourceDefinition(