Pass event filters to the server side
This passes event filters to the server side. It only matters for
event_time with limit now, but this fixes that case, and the case for
resource_type as well.
MODIFY
heatclient/osc/v1/event.py
heatclient/osc/v1/event.py
@@ -175,6 +175,20 @@ class ListEvent(command.Lister):
else:
nested_depth = 0
+ if parsed_args.sort:
+ sorts = []
+ sort_keys = []
+ for sort in parsed_args.sort:
+ if sort.startswith(":"):
+ sorts.append(":".join(["event_time", sort.lstrip(":")]))
+ else:
+ sorts.append(sort)
+ sort_keys.append(sort.split(":")[0])
+ kwargs['sort_keys'] = sort_keys
+
+ if ":" in parsed_args.sort[0]:
+ kwargs['sort_dir'] = parsed_args.sort[0].split(":")[1]
+
if parsed_args.follow:
if parsed_args.formatter != 'log':
msg = _('--follow can only be specified with --format log')
@@ -207,12 +221,6 @@ class ListEvent(command.Lister):
limit=parsed_args.limit)
if parsed_args.sort:
- sorts = []
- for sort in parsed_args.sort:
- if sort.startswith(":"):
- sorts.append(":".join(["event_time", sort.lstrip(":")]))
- else:
- sorts.append(sort)
events = utils.sort_items(events, ','.join(sorts))
if parsed_args.formatter == 'log':

MODIFY
heatclient/tests/unit/osc/v1/test_event.py
heatclient/tests/unit/osc/v1/test_event.py
@@ -194,7 +194,9 @@ class TestEventList(TestEvent):
mock_sort_items.assert_called_with(mock.ANY,
"resource_name:desc")
- self.event_client.list.assert_called_with(**self.defaults)
+ self.event_client.list.assert_called_with(
+ filters={}, resource_name=None, sort_dir='desc',
+ sort_keys=['resource_name'], stack_id='my_stack')
self.assertEqual(self.fields, columns)
@mock.patch('osc_lib.utils.sort_items')
@@ -209,7 +211,9 @@ class TestEventList(TestEvent):
mock_sort_items.assert_called_with(mock.ANY,
"resource_name:desc,id:asc")
- self.event_client.list.assert_called_with(**self.defaults)
+ self.event_client.list.assert_called_with(
+ filters={}, resource_name=None, sort_dir='desc',
+ sort_keys=['resource_name', 'id'], stack_id='my_stack')
self.assertEqual(self.fields, columns)
@mock.patch('osc_lib.utils.sort_items')
@@ -223,7 +227,9 @@ class TestEventList(TestEvent):
columns, data = self.cmd.take_action(parsed_args)
mock_sort_items.assert_called_with(mock.ANY, "event_time:desc")
- self.event_client.list.assert_called_with(**self.defaults)
+ self.event_client.list.assert_called_with(
+ filters={}, resource_name=None, sort_dir='desc', sort_keys=[],
+ stack_id='my_stack')
self.assertEqual(self.fields, columns)
@mock.patch('time.sleep')

Pass event filters to the server side

This passes event filters to the server side. It only matters for
event_time with limit now, but this fixes that case, and the case for
resource_type as well.

Change-Id: Ide8f0481cf031cc61d4bb43d1d92109d42326e95