Skip to content

Commit

Permalink
Fix filters default value in get_networks
Browse files Browse the repository at this point in the history
With that change, if get_networks() is called without fields set to
something, _filter_nets_l3 fails because it tries to call "filters.get()"
where filters is None.

This fixes bug #1060047

Change-Id: Ia0787e7a278a3562af5409861762f067d71f2cf6
Signed-off-by: Julien Danjou <julien@danjou.info>
  • Loading branch information
jd committed Oct 2, 2012
1 parent 903e95f commit f723e1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion quantum/db/l3_db.py
Expand Up @@ -709,7 +709,7 @@ def _process_l3_update(self, context, net_data, net_id):
network_id=net_id).delete()

def _filter_nets_l3(self, context, nets, filters):
vals = filters.get('router:external', [])
vals = filters and filters.get('router:external', [])
if not vals:
return nets

Expand Down
6 changes: 6 additions & 0 deletions quantum/tests/unit/test_l3_plugin.py
Expand Up @@ -892,6 +892,12 @@ def test_list_nets_external(self):
query_params="%s=False" % l3.EXTERNAL)
self.assertEquals(len(body['networks']), 1)

def test_get_network_succeeds_without_filter(self):
plugin = manager.QuantumManager.get_plugin()
ctx = context.Context(None, None, is_admin=True)
result = plugin.get_networks(ctx, filters=None)
self.assertEqual(result, [])

def test_network_filter_hook_admin_context(self):
plugin = manager.QuantumManager.get_plugin()
ctx = context.Context(None, None, is_admin=True)
Expand Down

0 comments on commit f723e1a

Please sign in to comment.