Add wait_for_stack call to heat driver
This adds a 'wait_for_stack' call to the heat_v1 driver. This method can be used to simplify the many wait logics in the heat stack profile. Change-Id: I94df298dd264da412fd9bd9b31c0cd9d8d06c4b5
This commit is contained in:
@@ -48,6 +48,18 @@ class HeatClient(base.DriverBase):
|
||||
return self.conn.orchestration.delete_stack(stack_id,
|
||||
ignore_missing)
|
||||
|
||||
@sdk.translate_exception
|
||||
def wait_for_stack(self, stack_id, status, failures=None, interval=2,
|
||||
timeout=None):
|
||||
if failures is None:
|
||||
failures = []
|
||||
|
||||
if timeout is None:
|
||||
timeout = cfg.CONF.default_action_timeout
|
||||
|
||||
return self.conn.orchestration.wait_for_status(
|
||||
stack_id, status, failures, interval, timeout)
|
||||
|
||||
@sdk.translate_exception
|
||||
def wait_for_stack_delete(self, stack_id, timeout=None):
|
||||
'''Wait for stack deleting complete'''
|
||||
|
||||
@@ -68,6 +68,23 @@ class TestHeatV1(base.SenlinTestCase):
|
||||
self.hc.stack_delete('stack_id', ignore_missing=True)
|
||||
self.orch.delete_stack.assert_called_once_with('stack_id', True)
|
||||
|
||||
def test_wait_for_stack(self):
|
||||
self.hc.wait_for_stack('FAKE_ID', 'STATUS', [], 100, 200)
|
||||
self.orch.wait_for_status.assert_called_once_with(
|
||||
'FAKE_ID', 'STATUS', [], 100, 200)
|
||||
|
||||
def test_wait_for_stack_failures_not_specified(self):
|
||||
self.hc.wait_for_stack('FAKE_ID', 'STATUS', None, 100, 200)
|
||||
self.orch.wait_for_status.assert_called_once_with(
|
||||
'FAKE_ID', 'STATUS', [], 100, 200)
|
||||
|
||||
def test_wait_for_stack_default_timeout(self):
|
||||
cfg.CONF.set_override('default_action_timeout', 361, enforce_type=True)
|
||||
|
||||
self.hc.wait_for_stack('FAKE_ID', 'STATUS', None, 100, None)
|
||||
self.orch.wait_for_status.assert_called_once_with(
|
||||
'FAKE_ID', 'STATUS', [], 100, 361)
|
||||
|
||||
def test_wait_for_stack_delete_successful(self):
|
||||
fake_stack = mock.Mock(id='stack_id')
|
||||
self.orch.find_stack.return_value = fake_stack
|
||||
|
||||
Reference in New Issue
Block a user