Optimize if statement in dvr_local_router.py
The if statement for calling create_rtr_2_fip_link and kicking the FW agent includes a check on floating_ips, that has already been performed by the previous if block. Pull this block into the previous block for code clarity. Change-Id: I8661aa3998bda9341f558d0ecbc8e2663cd95aca Signed-off-by: Ryan Moats <rmoats@us.ibm.com> Co-Authored-By: Brian Haley <brian.haley@hpe.com>
This commit is contained in:
parent
693db7cf7c
commit
b07fb26292
|
@ -408,8 +408,8 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase):
|
|||
else:
|
||||
self.fip_ns.create_gateway_port(fip_agent_port)
|
||||
|
||||
if self.fip_ns.agent_gateway_port and floating_ips:
|
||||
if self.dist_fip_count == 0 or is_first:
|
||||
if (self.fip_ns.agent_gateway_port and
|
||||
(self.dist_fip_count == 0 or is_first)):
|
||||
self.fip_ns.create_rtr_2_fip_link(self)
|
||||
|
||||
# kicks the FW Agent to add rules for the IR namespace if
|
||||
|
|
|
@ -946,6 +946,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
ri.dist_fip_count = 0
|
||||
ri.fip_ns.subscribe = mock.Mock()
|
||||
ri.fip_ns.agent_router_gateway = mock.Mock()
|
||||
agent.process_router_add = mock.Mock()
|
||||
|
||||
with mock.patch.object(ri, 'get_floating_ips') as fips, \
|
||||
mock.patch.object(ri, 'get_floating_agent_gw_interface'
|
||||
|
@ -958,6 +959,7 @@ class TestBasicRouterOperations(BasicRouterOperationsFramework):
|
|||
self.assertEqual(ri.fip_ns.agent_gateway_port,
|
||||
agent_gateway_port[0])
|
||||
self.assertTrue(ri.rtr_fip_subnet)
|
||||
self.assertEqual(1, agent.process_router_add.call_count)
|
||||
|
||||
@mock.patch.object(lla.LinkLocalAllocator, '_write')
|
||||
def test_create_dvr_fip_interfaces_for_restart_l3agent_case(self,
|
||||
|
|
Loading…
Reference in New Issue