Add a config option for BGP speaker scheduling

Depending on the Scheduler being used in neutron-dynamic-routing, it may
be necessary to explicitly schedule a speaker to an agent when it is
being created. Add an option that allows to request this behavior.

Needed-By: https://review.opendev.org/c/openstack/neutron-dynamic-routing/+/815265
Signed-off-by: Dr. Jens Harbott <harbott@osism.tech>
Change-Id: Ic685d1b174660cc58b8a29178e98f838d8b496e1
diff --git a/neutron_tempest_plugin/config.py b/neutron_tempest_plugin/config.py
index 36fec30..a40fb0d 100644
--- a/neutron_tempest_plugin/config.py
+++ b/neutron_tempest_plugin/config.py
@@ -141,6 +141,12 @@
                      'If True, multicast test(s) will assert that multicast '
                      'traffic is not being flooded to all ports. Defaults '
                      'to False.'),
+    # Option for scheduling BGP speakers to agents explicitly
+    # The default is false with automatic scheduling on creation
+    # happening with the default scheduler
+    cfg.BoolOpt('bgp_schedule_speakers_to_agents',
+                default=False,
+                help='Schedule BGP speakers to agents explicitly.'),
 ]
 
 # TODO(amuller): Redo configuration options registration as part of the planned
diff --git a/neutron_tempest_plugin/neutron_dynamic_routing/scenario/base.py b/neutron_tempest_plugin/neutron_dynamic_routing/scenario/base.py
index b4be57b..c7023af 100644
--- a/neutron_tempest_plugin/neutron_dynamic_routing/scenario/base.py
+++ b/neutron_tempest_plugin/neutron_dynamic_routing/scenario/base.py
@@ -25,9 +25,9 @@
 from tempest import config
 
 from neutron_tempest_plugin.api import base
+from neutron_tempest_plugin import config as nconfig
 from neutron_tempest_plugin.services.bgp import bgp_client
 
-
 CONF = config.CONF
 
 Scope = collections.namedtuple('Scope', 'name')
@@ -149,6 +149,9 @@
         if auto_delete:
             self.addCleanup(self.bgp_adm_client.delete_bgp_speaker,
                             bgp_speaker_id)
+        if nconfig.CONF.neutron_plugin_options.bgp_schedule_speakers_to_agents:
+            self.add_bgp_speaker_to_dragent(self.get_dragent_id(),
+                                            bgp_speaker_id)
         return bgp_speaker['bgp_speaker']
 
     def delete_bgp_speaker(self, id):