← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 1361605] Re: Use lazy init for L3 plugin reference

 

Kevin, I like the patch you posted above, that's very insightful.

Can you post a patch to calculate how much it takes a developer to type
'that garbage' over the lifespan of Neutron? :)

I don't have a strong opinion on both approaches, but I like the idea of
conciseness so that we can save the developer the trouble to just copy
and paste this all over the place, which makes the code simpler and more
readable. That to me is the real savings!

That said, I'd rather introduce the property on an ad-hoc basis rather
than doing a sweep patch as proposed here.

** Changed in: neutron
       Status: New => Opinion

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

Title:
  Use lazy init for L3 plugin reference

Status in OpenStack Neutron (virtual network service):
  Opinion

Bug description:
  In many L3 plugins, there is a reference needed to the L3 core plugin.
  This is typically done as:

          plugin =
  manager.NeutronManager.get_service_plugins().get(constants.L3_ROUTER_NAT)

  Rather than looking up the plugin, each time it is needed (e.g.
  processing each VPN API request), this bug proposes to do a lazy init
  of the plugin as in:

      @property
      def l3_plugin(self):
          try:
              return self._l3_plugin
          except AttributeError:
              self._l3_plugin = manager.NeutronManager.get_service_plugins().get(
                  constants.L3_ROUTER_NAT)
              return self._l3_plugin

  In addition, we can look at placing this in a common area (mixin?) or
  as a decorator, so that each class that needs it could use the mixin,
  rather than repeat this property.

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


References