From 2ac0ee0b28c9c408aeb501d311c880afe59c4fb5 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Wed, 20 Feb 2019 23:09:05 -0500 Subject: [PATCH] Fix pylint E1128 (assignment-from-no-return) in l3-agent Changed migrate_centralized_floating_ip() to return a status in DvrLocalRouter class. Also changed the parent method in RouterInfo class to return FLOATINGIP_STATUS_NOCHANGE, which will cause the agent to not send an updated status for the floating IP. Also changed floating_ip_added_dist() to not use an intermediate variable and just return directly. Change-Id: I7dc4934308da95cf00a36b4ef1020aac7cef7d99 Closes-bug: #1816874 --- neutron/agent/l3/dvr_local_router.py | 7 ++----- neutron/agent/l3/router_info.py | 7 ++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/neutron/agent/l3/dvr_local_router.py b/neutron/agent/l3/dvr_local_router.py index 8010ecdcdbd..fca95aa3bfd 100644 --- a/neutron/agent/l3/dvr_local_router.py +++ b/neutron/agent/l3/dvr_local_router.py @@ -53,7 +53,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase): ip_cidr = common_utils.ip_to_cidr(fip['floating_ip_address']) self.floating_ip_removed_dist(ip_cidr) # Now add the floating_ip to the current host - self.floating_ip_added_dist(fip, ip_cidr) + return self.floating_ip_added_dist(fip, ip_cidr) def floating_forward_rules(self, fip): """Override this function defined in router_info for dvr routers.""" @@ -108,10 +108,7 @@ class DvrLocalRouter(dvr_router_base.DvrRouterBase): def floating_ip_added_dist(self, fip, fip_cidr): """Add floating IP to respective namespace based on agent mode.""" if fip.get(lib_constants.DVR_SNAT_BOUND): - # TODO(dougwig) - remove this disable when fixing bug #1816874 - # pylint: disable=assignment-from-no-return - floating_ip_status = self.add_centralized_floatingip(fip, fip_cidr) - return floating_ip_status + return self.add_centralized_floatingip(fip, fip_cidr) if not self._check_if_floatingip_bound_to_host(fip): # TODO(Swami): Need to figure out what status # should be returned when the floating IP is diff --git a/neutron/agent/l3/router_info.py b/neutron/agent/l3/router_info.py index 3d8b13a726d..a9958798b59 100644 --- a/neutron/agent/l3/router_info.py +++ b/neutron/agent/l3/router_info.py @@ -314,7 +314,10 @@ class RouterInfo(object): raise NotImplementedError() def migrate_centralized_floating_ip(self, fip, interface_name, device): - pass + """Implements centralized->distributed floating IP migration. + Overridden in dvr_local_router.py + """ + return FLOATINGIP_STATUS_NOCHANGE def gateway_redirect_cleanup(self, rtr_interface): pass @@ -377,8 +380,6 @@ class RouterInfo(object): fip.get('host') == self.host): LOG.debug("Floating IP is migrating from centralized " "to distributed: %s", fip) - # TODO(dougwig) - remove this disable when fixing bug #1816874 - # pylint: disable=assignment-from-no-return fip_statuses[fip['id']] = self.migrate_centralized_floating_ip( fip, interface_name, device) elif fip_statuses[fip['id']] == fip['status']: