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
This commit is contained in:
Steven Hardy 2013-05-13 14:45:56 +01:00
parent 652a5c0c78
commit 8026858af5
7 changed files with 18 additions and 16 deletions

View 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

View 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

View 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

View 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:

View 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

View 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,

View 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)