Update metering driver to load interface driver

Currently the metering iptables driver is using the old method
to load the interface driver. This patch allows it to load
interface driver via stevedore aliases.

Change-Id: I9e3027c1ec695ec3a09db0c53a0388e406e4ced6
Related-Bug: #1504536
This commit is contained in:
Hongbin Lu 2018-08-09 21:02:01 +00:00
parent 5226e50c68
commit 38309ca4dc
2 changed files with 9 additions and 7 deletions

View File

@ -15,9 +15,8 @@
from oslo_config import cfg
from oslo_log import helpers as log_helpers
from oslo_log import log as logging
from oslo_utils import importutils
from neutron._i18n import _
from neutron.agent.common import utils as common_utils
from neutron.agent.l3 import dvr_snat_ns
from neutron.agent.l3 import namespaces
from neutron.agent.linux import ip_lib
@ -107,11 +106,7 @@ class IptablesMeteringDriver(abstract_driver.MeteringAbstractDriver):
self.conf = conf or cfg.CONF
self.routers = {}
if not self.conf.interface_driver:
raise SystemExit(_('An interface driver must be specified'))
LOG.info("Loading interface driver %s", self.conf.interface_driver)
self.driver = importutils.import_object(self.conf.interface_driver,
self.conf)
self.driver = common_utils.load_interface_driver(self.conf)
def _update_router(self, router):
r = self.routers.get(router['id'],

View File

@ -0,0 +1,7 @@
---
other:
- |
The metering agent iptables driver can now load its interface driver by
using a stevedore alias in the ``metering_agent.ini`` file. For example,
``interface_driver = openvswitch`` instead of
``interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver``