From: Steven Hardy Date: Mon, 13 May 2013 13:45:56 +0000 (+0100) Subject: engine : rename check_active to make it more generic X-Git-Tag: 2014.1~622 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=8026858af59c2a0d886881ffaf73c6d2cde39db3;p=openstack-build%2Fheat-build.git engine : rename check_active to make it more generic Rename check_active to check_create_complete, since "active" is really a detail of Instance state, and so it seems wrong for other resources which take a long time to create but are not Instance based (e.g WaitConditions). This change will also allow us to align other stack "state check" functions with the state we're checking for in a consistent way (e.g check_delete_complete etc) Fixes bug #1178591 Change-Id: I55a824e6ba3de87cedd0b844e7f4e1294917533a --- diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 92263211..b64c6237 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -319,7 +319,7 @@ class Resource(object): if callable(getattr(self, 'handle_create', None)): create_data = self.handle_create() yield - while not self.check_active(create_data): + while not self.check_create_complete(create_data): yield except greenlet.GreenletExit: # Older versions of greenlet erroneously had GreenletExit inherit @@ -343,7 +343,7 @@ class Resource(object): else: self.state_set(self.CREATE_COMPLETE) - def check_active(self, create_data): + def check_create_complete(self, create_data): ''' Check if the resource is active (ready to move to the CREATE_COMPLETE state). By default this happens as soon as the handle_create() method diff --git a/heat/engine/resources/autoscaling.py b/heat/engine/resources/autoscaling.py index 8d9a468b..81a0f027 100644 --- a/heat/engine/resources/autoscaling.py +++ b/heat/engine/resources/autoscaling.py @@ -80,7 +80,7 @@ class InstanceGroup(resource.Resource): def handle_create(self): return self.resize(int(self.properties['Size']), raise_on_error=True) - def check_active(self, creator): + def check_create_complete(self, creator): if creator is None: return True diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index a83c4988..ee7bcbd6 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -323,7 +323,7 @@ class Instance(resource.Resource): return server - def check_active(self, server): + def check_create_complete(self, server): if server.status == 'ACTIVE': return True diff --git a/heat/tests/test_autoscaling.py b/heat/tests/test_autoscaling.py index d39f5663..dc6578cc 100644 --- a/heat/tests/test_autoscaling.py +++ b/heat/tests/test_autoscaling.py @@ -107,13 +107,14 @@ class AutoScalingTest(HeatTestCase): self.m.StubOutWithMock(eventlet, 'sleep') self.m.StubOutWithMock(instance.Instance, 'handle_create') - self.m.StubOutWithMock(instance.Instance, 'check_active') + self.m.StubOutWithMock(instance.Instance, 'check_create_complete') cookie = object() for x in range(num): instance.Instance.handle_create().AndReturn(cookie) - instance.Instance.check_active(cookie).AndReturn(False) + instance.Instance.check_create_complete(cookie).AndReturn(False) eventlet.sleep(mox.IsA(int)).AndReturn(None) - instance.Instance.check_active(cookie).MultipleTimes().AndReturn(True) + instance.Instance.check_create_complete( + cookie).MultipleTimes().AndReturn(True) def _stub_lb_reload(self, expected_list, unset=True): if unset: diff --git a/heat/tests/test_instance.py b/heat/tests/test_instance.py index c032aef0..2d319b06 100644 --- a/heat/tests/test_instance.py +++ b/heat/tests/test_instance.py @@ -150,7 +150,7 @@ class instancesTest(HeatTestCase): 'test_instance_status_build') instance.resource_id = 1234 - # Bind new fake get method which Instance.check_active will call + # Bind fake get method which Instance.check_create_complete will call def activate_status(server): server.status = 'ACTIVE' return_server.get = activate_status.__get__(return_server) @@ -192,7 +192,7 @@ class instancesTest(HeatTestCase): 'test_instance_status_build') instance.resource_id = 1234 - # Bind new fake get method which Instance.check_active will call + # Bind fake get method which Instance.check_create_complete will call def activate_status(server): if hasattr(server, '_test_check_iterations'): server._test_check_iterations += 1 diff --git a/heat/tests/test_instance_group.py b/heat/tests/test_instance_group.py index b7cb51d2..5b238719 100644 --- a/heat/tests/test_instance_group.py +++ b/heat/tests/test_instance_group.py @@ -64,13 +64,14 @@ class InstanceGroupTest(HeatTestCase): self.m.StubOutWithMock(eventlet, 'sleep') self.m.StubOutWithMock(instance.Instance, 'handle_create') - self.m.StubOutWithMock(instance.Instance, 'check_active') + self.m.StubOutWithMock(instance.Instance, 'check_create_complete') cookie = object() for x in range(num): instance.Instance.handle_create().AndReturn(cookie) - instance.Instance.check_active(cookie).AndReturn(False) + instance.Instance.check_create_complete(cookie).AndReturn(False) eventlet.sleep(mox.IsA(int)).AndReturn(None) - instance.Instance.check_active(cookie).MultipleTimes().AndReturn(True) + instance.Instance.check_create_complete( + cookie).MultipleTimes().AndReturn(True) def create_instance_group(self, t, stack, resource_name): resource = asc.InstanceGroup(resource_name, diff --git a/heat/tests/test_metadata_refresh.py b/heat/tests/test_metadata_refresh.py index b1a080e0..b9f0e9d8 100644 --- a/heat/tests/test_metadata_refresh.py +++ b/heat/tests/test_metadata_refresh.py @@ -142,10 +142,10 @@ class MetadataRefreshTest(HeatTestCase): self.stack_id = stack.store() self.m.StubOutWithMock(instance.Instance, 'handle_create') - self.m.StubOutWithMock(instance.Instance, 'check_active') + self.m.StubOutWithMock(instance.Instance, 'check_create_complete') for cookie in (object(), object()): instance.Instance.handle_create().AndReturn(cookie) - instance.Instance.check_active(cookie).AndReturn(True) + instance.Instance.check_create_complete(cookie).AndReturn(True) self.m.StubOutWithMock(instance.Instance, 'FnGetAtt') return stack @@ -202,10 +202,10 @@ class WaitCondMetadataUpdateTest(HeatTestCase): self.stack_id = stack.store() self.m.StubOutWithMock(instance.Instance, 'handle_create') - self.m.StubOutWithMock(instance.Instance, 'check_active') + self.m.StubOutWithMock(instance.Instance, 'check_create_complete') cookie = object() instance.Instance.handle_create().AndReturn(cookie) - instance.Instance.check_active(cookie).AndReturn(True) + instance.Instance.check_create_complete(cookie).AndReturn(True) self.m.StubOutWithMock(wc.WaitConditionHandle, 'keystone') wc.WaitConditionHandle.keystone().MultipleTimes().AndReturn(self.fc)