Fix wrong argument name in _rpc_update_firewall
Passing id (built-in function id) instead of firewall_id to get_firewall_routers caused DBErrors due to wrong argument type. This change fixes this typo and adds missing unit tests that can prevent such error from appearing in the future. Change-Id: I35f13b1aab5a566c1e2768a4027e61120bf6ba2e Closes-Bug: #1475244
This commit is contained in:
parent
96d1c7a0e6
commit
caf39a47e3
|
@ -170,7 +170,7 @@ class FirewallPlugin(
|
|||
# this is triggered on an update to fw rule or policy, no
|
||||
# change in associated routers.
|
||||
fw_with_rules['add-router-ids'] = self.get_firewall_routers(
|
||||
context, id)
|
||||
context, firewall_id)
|
||||
fw_with_rules['del-router-ids'] = []
|
||||
self.agent_rpc.update_firewall(context, fw_with_rules)
|
||||
|
||||
|
|
|
@ -581,3 +581,33 @@ class TestFirewallPluginBase(TestFirewallRouterInsertionBase,
|
|||
description='fw') as fwalls:
|
||||
self._test_list_resources('firewall', [fwalls],
|
||||
query_params='description=fw')
|
||||
|
||||
def test_insert_rule(self):
|
||||
ctx = context.get_admin_context()
|
||||
with self.firewall_rule() as fwr:
|
||||
fr_id = fwr['firewall_rule']['id']
|
||||
rule_info = {'firewall_rule_id': fr_id}
|
||||
with self.firewall_policy() as fwp:
|
||||
fwp_id = fwp['firewall_policy']['id']
|
||||
with self.firewall(firewall_policy_id=fwp_id) as fw:
|
||||
fw_id = fw['firewall']['id']
|
||||
self.plugin.insert_rule(ctx, fwp_id, rule_info)
|
||||
fw_rules = self.plugin._make_firewall_dict_with_rules(
|
||||
ctx, fw_id)
|
||||
self.assertEqual(1, len(fw_rules['firewall_rule_list']))
|
||||
self.assertEqual(fr_id,
|
||||
fw_rules['firewall_rule_list'][0]['id'])
|
||||
|
||||
def test_remove_rule(self):
|
||||
ctx = context.get_admin_context()
|
||||
with self.firewall_rule() as fwr:
|
||||
fr_id = fwr['firewall_rule']['id']
|
||||
rule_info = {'firewall_rule_id': fr_id}
|
||||
with self.firewall_policy(firewall_rules=[fr_id]) as fwp:
|
||||
fwp_id = fwp['firewall_policy']['id']
|
||||
with self.firewall(firewall_policy_id=fwp_id) as fw:
|
||||
fw_id = fw['firewall']['id']
|
||||
self.plugin.remove_rule(ctx, fwp_id, rule_info)
|
||||
fw_rules = self.plugin._make_firewall_dict_with_rules(
|
||||
ctx, fw_id)
|
||||
self.assertEqual([], fw_rules['firewall_rule_list'])
|
||||
|
|
Loading…
Reference in New Issue