mirror of
https://opendev.org/openstack/python-heatclient.git
synced 2026-01-16 23:00:35 +00:00
Allow to set poll interval to OSC stack create
In certain scenarios the default poll interval of 5s used by `openstack stack create --wait` command is too short. Setting the poll interval was supported in heat CLI with `heat stack-create --poll N` but is missing in OSC plugin. This patch adds an optional argument `--poll N` (N defaults to 5) to the `openstack stack create` command. Change-Id: Id279d92ea890032f280e453b795ede2818ffbb8c Story: 2004863 Task: 29106
This commit is contained in:
parent
4d8f270157
commit
033511c291
2 changed files with 28 additions and 1 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue