Browse Source

Merge "Check external resources after creation" into stable/rocky

stable/rocky
Zuul 1 year ago
committed by Gerrit Code Review
parent
commit
b122028bae
  1. 2
      heat/engine/resource.py
  2. 6
      heat/tests/generic_resource.py
  3. 9
      heat/tests/test_resource.py

2
heat/engine/resource.py

@ -1215,7 +1215,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

6
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

9
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(

Loading…
Cancel
Save