Bug fix: create_stack() fails when waiting
The create_stack() call had two bugs: If wait was True, it attempted to call an iterate method that had been moved to _utils; it also did not return the stack from the get_stack() calls. Change-Id: I2588e3a84729a8f1b3bfcb6d401c7d51fb16832b
This commit is contained in:
parent
fb8ea73f27
commit
451e51340d
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
fixes:
|
||||||
|
- The create_stack() call was fixed to call the correct iterator
|
||||||
|
method and to return the updated stack object when waiting.
|
@ -730,10 +730,11 @@ class OpenStackCloud(object):
|
|||||||
stack = self.manager.submitTask(_tasks.StackCreate(**params))
|
stack = self.manager.submitTask(_tasks.StackCreate(**params))
|
||||||
if not wait:
|
if not wait:
|
||||||
return stack
|
return stack
|
||||||
for count in _iterate_timeout(
|
for count in _utils._iterate_timeout(
|
||||||
timeout,
|
timeout,
|
||||||
"Timed out waiting for heat stack to finish"):
|
"Timed out waiting for heat stack to finish"):
|
||||||
if self.get_stack(name, cache=False):
|
stack = self.get_stack(name, cache=False)
|
||||||
|
if stack:
|
||||||
return stack
|
return stack
|
||||||
|
|
||||||
def delete_stack(self, name_or_id):
|
def delete_stack(self, name_or_id):
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
import mock
|
import mock
|
||||||
import testtools
|
import testtools
|
||||||
|
|
||||||
|
from heatclient.common import template_utils
|
||||||
|
|
||||||
import shade
|
import shade
|
||||||
from shade import meta
|
from shade import meta
|
||||||
from shade.tests import fakes
|
from shade.tests import fakes
|
||||||
@ -76,3 +78,36 @@ class TestStack(base.TestCase):
|
|||||||
"Failed to delete stack %s" % stack['id']
|
"Failed to delete stack %s" % stack['id']
|
||||||
):
|
):
|
||||||
self.cloud.delete_stack('stack_name')
|
self.cloud.delete_stack('stack_name')
|
||||||
|
|
||||||
|
@mock.patch.object(template_utils, 'get_template_contents')
|
||||||
|
@mock.patch.object(shade.OpenStackCloud, 'heat_client')
|
||||||
|
def test_create_stack(self, mock_heat, mock_template):
|
||||||
|
mock_template.return_value = ({}, {})
|
||||||
|
self.cloud.create_stack('stack_name')
|
||||||
|
self.assertTrue(mock_template.called)
|
||||||
|
mock_heat.stacks.create.assert_called_once_with(
|
||||||
|
stack_name='stack_name',
|
||||||
|
disable_rollback=False,
|
||||||
|
parameters={},
|
||||||
|
template={},
|
||||||
|
files={}
|
||||||
|
)
|
||||||
|
|
||||||
|
@mock.patch.object(template_utils, 'get_template_contents')
|
||||||
|
@mock.patch.object(shade.OpenStackCloud, 'get_stack')
|
||||||
|
@mock.patch.object(shade.OpenStackCloud, 'heat_client')
|
||||||
|
def test_create_stack_wait(self, mock_heat, mock_get, mock_template):
|
||||||
|
stack = {'id': 'stack_id', 'name': 'stack_name'}
|
||||||
|
mock_template.return_value = ({}, {})
|
||||||
|
mock_get.side_effect = iter([None, stack])
|
||||||
|
ret = self.cloud.create_stack('stack_name', wait=True)
|
||||||
|
self.assertTrue(mock_template.called)
|
||||||
|
mock_heat.stacks.create.assert_called_once_with(
|
||||||
|
stack_name='stack_name',
|
||||||
|
disable_rollback=False,
|
||||||
|
parameters={},
|
||||||
|
template={},
|
||||||
|
files={}
|
||||||
|
)
|
||||||
|
self.assertEqual(2, mock_get.call_count)
|
||||||
|
self.assertEqual(stack, ret)
|
||||||
|
Loading…
Reference in New Issue
Block a user