Merge "Allow to set poll interval to OSC stack create"

This commit is contained in:
Zuul
2020-02-21 07:52:00 +00:00
committed by Gerrit Code Review
2 changed files with 28 additions and 1 deletions

View File

@@ -90,6 +90,14 @@ class CreateStack(command.ShowOne):
action='store_true',
help=_('Wait until stack goes to CREATE_COMPLETE or CREATE_FAILED')
)
parser.add_argument(
'--poll',
metavar='SECONDS',
type=int,
default=5,
help=_('Poll interval in seconds for use with --wait, '
'defaults to 5.')
)
parser.add_argument(
'--tags',
metavar='<tag1,tag2...>',
@@ -184,7 +192,8 @@ class CreateStack(command.ShowOne):
stack = client.stacks.create(**fields)['stack']
if parsed_args.wait:
stack_status, msg = event_utils.poll_for_events(
client, parsed_args.name, action='CREATE')
client, parsed_args.name, action='CREATE',
poll_period=parsed_args.poll)
if stack_status == 'CREATE_FAILED':
raise exc.CommandError(msg)

View File

@@ -148,6 +148,24 @@ class TestStackCreate(TestStack):
self.cmd.take_action(parsed_args)
mock_poll.assert_called_once_with(mock.ANY, 'my_stack',
action='CREATE', poll_period=5)
self.stack_client.create.assert_called_with(**self.defaults)
self.stack_client.get.assert_called_with(**{'stack_id': '1234',
'resolve_outputs': False})
@mock.patch('heatclient.common.event_utils.poll_for_events',
return_value=('CREATE_COMPLETE',
'Stack my_stack CREATE_COMPLETE'))
def test_stack_create_wait_with_poll(self, mock_poll):
arglist = ['my_stack', '-t', self.template_path, '--wait',
'--poll', '10']
parsed_args = self.check_parser(self.cmd, arglist, [])
self.cmd.take_action(parsed_args)
mock_poll.assert_called_once_with(mock.ANY, 'my_stack',
action='CREATE', poll_period=10)
self.stack_client.create.assert_called_with(**self.defaults)
self.stack_client.get.assert_called_with(**{'stack_id': '1234',
'resolve_outputs': False})