← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1265132] [NEW] neutron code redundancy

 

Public bug reported:

I found the code in l3_db.py is redundant,the code is below:
in function _update_router_gw_info:

        if gw_port and gw_port['network_id'] != network_id:
            fip_count = self.get_floatingips_count(context.elevated(),
                                                   {'router_id': [router_id]})
            if fip_count:
                raise l3.RouterExternalGatewayInUseByFloatingIp(
                    router_id=router_id, net_id=gw_port['network_id'])
            if gw_port and gw_port['network_id'] != network_id:
                with context.session.begin(subtransactions=True):
                    router.gw_port = None
                    context.session.add(router)
                self._core_plugin.delete_port(context.elevated(),
                                              gw_port['id'],
                                              l3_port_check=False)

it does not need the third if!

** Affects: neutron
     Importance: Undecided
     Assignee: shihanzhang (shihanzhang)
         Status: New

** Changed in: neutron
     Assignee: (unassigned) => shihanzhang (shihanzhang)

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to neutron.
https://bugs.launchpad.net/bugs/1265132

Title:
  neutron code redundancy

Status in OpenStack Neutron (virtual network service):
  New

Bug description:
  I found the code in l3_db.py is redundant,the code is below:
  in function _update_router_gw_info:

          if gw_port and gw_port['network_id'] != network_id:
              fip_count = self.get_floatingips_count(context.elevated(),
                                                     {'router_id': [router_id]})
              if fip_count:
                  raise l3.RouterExternalGatewayInUseByFloatingIp(
                      router_id=router_id, net_id=gw_port['network_id'])
              if gw_port and gw_port['network_id'] != network_id:
                  with context.session.begin(subtransactions=True):
                      router.gw_port = None
                      context.session.add(router)
                  self._core_plugin.delete_port(context.elevated(),
                                                gw_port['id'],
                                                l3_port_check=False)

  it does not need the third if!

To manage notifications about this bug go to:
https://bugs.launchpad.net/neutron/+bug/1265132/+subscriptions


Follow ups

References