summaryrefslogtreecommitdiff
path: root/heatclient
diff options
context:
space:
mode:
authorPavlo Shchelokovskyy <shchelokovskyy@gmail.com>2019-01-25 11:47:31 +0200
committerPavlo Shchelokovskyy <pshchelokovskyy@mirantis.com>2019-09-25 08:57:33 +0000
commit033511c291c811f9368aaccdc81de3c9c93c9ae2 (patch)
tree068e68dbbea9ec8ed89d6e90274b55fffa3c60a5 /heatclient
parent4d8f270157bf2e56ede62c61985c8fad41daceb7 (diff)
downloadpython-heatclient-033511c291c811f9368aaccdc81de3c9c93c9ae2.tar.gz
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
Diffstat (limited to 'heatclient')
-rw-r--r--heatclient/osc/v1/stack.py11
-rw-r--r--heatclient/tests/unit/osc/v1/test_stack.py18
2 files changed, 28 insertions, 1 deletions
diff --git a/heatclient/osc/v1/stack.py b/heatclient/osc/v1/stack.py
index bdf7f5f..761b323 100644
--- a/heatclient/osc/v1/stack.py
+++ b/heatclient/osc/v1/stack.py
@@ -91,6 +91,14 @@ class CreateStack(command.ShowOne):
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...>',
help=_('A list of tags to associate with the stack')
@@ -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)
diff --git a/heatclient/tests/unit/osc/v1/test_stack.py b/heatclient/tests/unit/osc/v1/test_stack.py
index 146c1bc..d6a51b0 100644
--- a/heatclient/tests/unit/osc/v1/test_stack.py
+++ b/heatclient/tests/unit/osc/v1/test_stack.py
@@ -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})