Browse Source

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

stable/ussuri
Zuul 2 weeks ago
committed by Gerrit Code Review
parent
commit
ec6cd9ed00
3 changed files with 16 additions and 1 deletions
  1. +1
    -1
      heat/engine/resource.py
  2. +6
    -0
      heat/tests/generic_resource.py
  3. +9
    -0
      heat/tests/test_resource.py

+ 1
- 1
heat/engine/resource.py View File

@@ -1206,7 +1206,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
- 0
heat/tests/generic_resource.py View File

@@ -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
- 0
heat/tests/test_resource.py View File

@@ -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