]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
engine : rename check_active to make it more generic
authorSteven Hardy <shardy@redhat.com>
Mon, 13 May 2013 13:45:56 +0000 (14:45 +0100)
committerSteven Hardy <shardy@redhat.com>
Mon, 13 May 2013 13:45:56 +0000 (14:45 +0100)
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

heat/engine/resource.py
heat/engine/resources/autoscaling.py
heat/engine/resources/instance.py
heat/tests/test_autoscaling.py
heat/tests/test_instance.py
heat/tests/test_instance_group.py
heat/tests/test_metadata_refresh.py

index 92263211c99b74fa246ea0d8316078807e80bff6..b64c62371544ea6594c8fbfab8bdb979141b90c4 100644 (file)
@@ -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
index 8d9a468b628988eed6ccb81546caaf8a62b65dde..81a0f027b3bd290092b0f238a06ef0958105a486 100644 (file)
@@ -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
 
index a83c49889eb6d44c8e2767e0e85112c473ac0b07..ee7bcbd67da6b58c8724224540acf1271dff4f60 100644 (file)
@@ -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
 
index d39f5663f4974fe6ae0e835b986b351bae6660ac..dc6578cc6040bf9b39fea363393ba34f19aa2443 100644 (file)
@@ -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:
index c032aef0c4f1899b4e152fa55800db2f86dee1d4..2d319b06545bc8d176a77fab03c99f7cd1b69d05 100644 (file)
@@ -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
index b7cb51d23f49a91a177029d881536589a402813c..5b238719b200160973ec477967535f6f6c48b6bf 100644 (file)
@@ -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,
index b1a080e0bad04850d228a761cd12c72f97f2f491..b9f0e9d8c844f8813e6e4a0d586c0e5433a5df9f 100644 (file)
@@ -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)