Browse Source

Add another test mech driver for scale simulation

This driver immediately sets ports to ACTIVE upon being bound
to simulate OVS/LinuxBridge agent operation when utilizing
the fake.FakeDriver compute driver.

Change-Id: Ia0c89aa00c1998fdf64a81113c1a355f44719fa1
changes/51/650151/1
Mitchell Jameson 2 years ago
parent
commit
5a90097def
2 changed files with 40 additions and 0 deletions
  1. +39
    -0
      networking_arista/tests/unit/ml2/mechanism_ha_simulator.py
  2. +1
    -0
      setup.cfg

+ 39
- 0
networking_arista/tests/unit/ml2/mechanism_ha_simulator.py View File

@ -16,6 +16,14 @@
from multiprocessing import Queue
import random
from neutron.agent import rpc as agent_rpc
from neutron_lib.agent import topics
from neutron_lib.api.definitions import portbindings
from neutron_lib.callbacks import events
from neutron_lib.callbacks import registry
from neutron_lib.callbacks import resources
from neutron_lib import context
from networking_arista.ml2 import arista_sync
from networking_arista.ml2.mechanism_arista import AristaDriver
@ -58,3 +66,34 @@ class AristaHASimulationDriver(AristaDriver):
def delete_port_postcommit(self, context):
self.provision_queue = random.choice(self.provision_queues)
super(AristaHASimulationDriver, self).delete_port_postcommit(context)
class AristaHAScaleSimulationDriver(AristaHASimulationDriver):
def __init__(self):
super(AristaHAScaleSimulationDriver, self).__init__()
self.context = None
self.plugin_rpc = None
def initialize(self):
super(AristaHAScaleSimulationDriver, self).initialize()
self.context = context.get_admin_context_without_session()
# Subscribe to port updates to force ports to active after binding
# since a fake virt driver is being used, so OVS will never see
# the libvirt interfaces come up, triggering the OVS provisioning
self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
registry.subscribe(self._port_update_callback,
resources.PORT, events.AFTER_UPDATE)
def _port_update_callback(self, resource, event, trigger, **kwargs):
port = kwargs.get('port')
host = port.get(portbindings.HOST_ID)
vif_type = port.get(portbindings.VIF_TYPE)
device_dict = {'device': port['id'],
'agent_id': 'ovs-agent-%s' % host,
'host': host}
if vif_type == 'ovs':
self.plugin_rpc.update_device_up(self.context, **device_dict)
elif (port.get(portbindings.VNIC_TYPE) == 'normal'
and vif_type == 'unbound'):
self.plugin_rpc.update_device_down(self.context, **device_dict)

+ 1
- 0
setup.cfg View File

@ -35,6 +35,7 @@ neutron.ml2.mechanism_drivers =
arista_ml2 = networking_arista.ml2.mechanism_arista:AristaDriver
arista_test_fabric = networking_arista.tests.unit.ml2.mechanism_fabric:TestFabricDriver
arista_ha_sim = networking_arista.tests.unit.ml2.mechanism_ha_simulator:AristaHASimulationDriver
arista_ha_scale_sim = networking_arista.tests.unit.ml2.mechanism_ha_simulator:AristaHAScaleSimulationDriver
neutron.service_plugins =
arista_l3 = networking_arista.l3Plugin.l3_arista:AristaL3ServicePlugin
arista_security_group = networking_arista.ml2.security_groups.arista_security_groups:AristaSecurityGroupHandler


Loading…
Cancel
Save