Load Linux Bridge Trunk extension if service plugin configured
Load the Linux Driver Trunk agent extension driver only if the service plugin is enabled. If the service plugin is not enabled, the agent extension will not subscribe to the port events. Change-Id: I883abb5ef122ac7f8fb029d0334fa2d68893f8aa Closes-Bug: #1930443
This commit is contained in:
parent
389584c389
commit
817d807e9d
|
@ -22,6 +22,7 @@ from neutron.api.rpc.callbacks import events
|
|||
from neutron.api.rpc.handlers import resources_rpc
|
||||
from neutron.services.trunk.drivers.linuxbridge.agent import trunk_plumber
|
||||
from neutron.services.trunk.rpc import agent as trunk_rpc
|
||||
from neutron.services.trunk import utils as trunk_utils
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -29,7 +30,8 @@ LOG = logging.getLogger(__name__)
|
|||
|
||||
def init_handler(resource, event, trigger, payload=None):
|
||||
"""Handler for agent init event."""
|
||||
LinuxBridgeTrunkDriver()
|
||||
if trunk_utils.is_trunk_service_loaded():
|
||||
LinuxBridgeTrunkDriver()
|
||||
|
||||
|
||||
@registry.has_registry_receivers
|
||||
|
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
from neutron_lib.api import extensions
|
||||
from neutron_lib.plugins import directory
|
||||
from neutron_lib.utils import runtime
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.common import utils as common_utils
|
||||
|
||||
|
@ -53,3 +55,15 @@ def is_driver_compatible(context, driver, interface, host_agent_types):
|
|||
|
||||
# For an agent-based driver, both interface and agent compat is required.
|
||||
return is_interface_compatible and driver.agent_type in host_agent_types
|
||||
|
||||
|
||||
def is_trunk_service_loaded():
|
||||
for service_plugins in cfg.CONF.service_plugins:
|
||||
try:
|
||||
klass = runtime.load_class_by_alias_or_classname(
|
||||
'neutron.service_plugins', service_plugins)
|
||||
if klass.__name__ == 'TrunkPlugin':
|
||||
return True
|
||||
except ImportError:
|
||||
continue
|
||||
return False
|
||||
|
|
Loading…
Reference in New Issue