summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2018-04-23 12:56:57 +0000
committerGerrit Code Review <review@openstack.org>2018-04-23 12:56:57 +0000
commit331b4f34254163ac12548d443f9c76053451c6bf (patch)
tree1bbeaf6667a8bceb2d986b1227fcf41b61486d59
parentfe1d398403e65484c19742ef3604f964d9618428 (diff)
parent43d451d86f8c1f9dff2a8580089a631680bb0c09 (diff)
Merge "Enable sorting and pagination for segments"
-rw-r--r--neutron/extensions/segment.py4
-rw-r--r--neutron/services/segments/plugin.py3
-rw-r--r--neutron/tests/unit/extensions/test_segment.py50
3 files changed, 56 insertions, 1 deletions
diff --git a/neutron/extensions/segment.py b/neutron/extensions/segment.py
index e0eb493..820178c 100644
--- a/neutron/extensions/segment.py
+++ b/neutron/extensions/segment.py
@@ -117,7 +117,9 @@ class Segment(api_extensions.ExtensionDescriptor):
117 SEGMENTS, 117 SEGMENTS,
118 SEGMENT, 118 SEGMENT,
119 directory.get_plugin(SEGMENTS), 119 directory.get_plugin(SEGMENTS),
120 resource_attributes) 120 resource_attributes,
121 allow_pagination=True,
122 allow_sorting=True)
121 return [extensions.ResourceExtension(SEGMENTS, 123 return [extensions.ResourceExtension(SEGMENTS,
122 controller, 124 controller,
123 attr_map=resource_attributes)] 125 attr_map=resource_attributes)]
diff --git a/neutron/services/segments/plugin.py b/neutron/services/segments/plugin.py
index a9f3416..630bde9 100644
--- a/neutron/services/segments/plugin.py
+++ b/neutron/services/segments/plugin.py
@@ -61,6 +61,9 @@ class Plugin(db.SegmentDbMixin, segment.SegmentPluginBase):
61 supported_extension_aliases = ["segment", "ip_allocation", 61 supported_extension_aliases = ["segment", "ip_allocation",
62 l2adj_apidef.ALIAS] 62 l2adj_apidef.ALIAS]
63 63
64 __native_pagination_support = True
65 __native_sorting_support = True
66
64 def __init__(self): 67 def __init__(self):
65 self.nova_updater = NovaSegmentNotifier() 68 self.nova_updater = NovaSegmentNotifier()
66 69
diff --git a/neutron/tests/unit/extensions/test_segment.py b/neutron/tests/unit/extensions/test_segment.py
index f4a1805..409bd91 100644
--- a/neutron/tests/unit/extensions/test_segment.py
+++ b/neutron/tests/unit/extensions/test_segment.py
@@ -348,6 +348,56 @@ class TestSegment(SegmentTestCase):
348 res = self._list('segments') 348 res = self._list('segments')
349 self.assertEqual(2, len(res['segments'])) 349 self.assertEqual(2, len(res['segments']))
350 350
351 def test_list_segments_with_sort(self):
352 with self.network() as network:
353 network = network['network']
354 s1 = self._test_create_segment(network_id=network['id'],
355 physical_network='phys_net1',
356 segmentation_id=200)
357 s2 = self._test_create_segment(network_id=network['id'],
358 physical_network='phys_net2',
359 segmentation_id=201)
360 self._test_list_with_sort('segment',
361 (s2, s1),
362 [('physical_network', 'desc')],
363 query_params='network_id=%s' % network['id'])
364
365 def test_list_segments_with_pagination(self):
366 with self.network() as network:
367 network = network['network']
368 s1 = self._test_create_segment(network_id=network['id'],
369 physical_network='phys_net1',
370 segmentation_id=200)
371 s2 = self._test_create_segment(network_id=network['id'],
372 physical_network='phys_net2',
373 segmentation_id=201)
374 s3 = self._test_create_segment(network_id=network['id'],
375 physical_network='phys_net3',
376 segmentation_id=202)
377 self._test_list_with_pagination(
378 'segment',
379 (s1, s2, s3),
380 ('physical_network', 'asc'), 2, 2,
381 query_params='network_id=%s' % network['id'])
382
383 def test_list_segments_with_pagination_reverse(self):
384 with self.network() as network:
385 network = network['network']
386 s1 = self._test_create_segment(network_id=network['id'],
387 physical_network='phys_net1',
388 segmentation_id=200)
389 s2 = self._test_create_segment(network_id=network['id'],
390 physical_network='phys_net2',
391 segmentation_id=201)
392 s3 = self._test_create_segment(network_id=network['id'],
393 physical_network='phys_net3',
394 segmentation_id=202)
395 self._test_list_with_pagination_reverse(
396 'segment',
397 (s1, s2, s3),
398 ('physical_network', 'asc'), 2, 2,
399 query_params='network_id=%s' % network['id'])
400
351 def test_update_segments(self): 401 def test_update_segments(self):
352 with self.network() as network: 402 with self.network() as network:
353 net = network['network'] 403 net = network['network']