Set trunk status to ACTIVE upon creation.
Align Dragonflow Trunk driver with status policy stated in the body of the Trunk plugin. Close-Bug: #1707495 Change-Id: Icd792d2e3d64c28f3860830c192c2368fb07d0b0
This commit is contained in:
parent
8f6dee2f4c
commit
9fac743d24
|
@ -56,6 +56,7 @@ class DragonflowDriver(base.DriverBase, mixins.LazyNbApiMixin):
|
|||
"""
|
||||
super(DragonflowDriver, self).register(resource, event, trigger,
|
||||
**kwargs)
|
||||
self._register_trunk_events()
|
||||
self._register_subport_events()
|
||||
|
||||
def _register_init_events(self):
|
||||
|
@ -63,6 +64,10 @@ class DragonflowDriver(base.DriverBase, mixins.LazyNbApiMixin):
|
|||
constants.TRUNK_PLUGIN,
|
||||
events.AFTER_INIT)
|
||||
|
||||
def _register_trunk_events(self):
|
||||
registry.subscribe(self._add_trunk_handler,
|
||||
constants.TRUNK, events.AFTER_CREATE)
|
||||
|
||||
def _register_subport_events(self):
|
||||
registry.subscribe(self._add_subports_handler,
|
||||
constants.SUBPORTS, events.AFTER_CREATE)
|
||||
|
@ -79,6 +84,12 @@ class DragonflowDriver(base.DriverBase, mixins.LazyNbApiMixin):
|
|||
base = "{}/{}".format(trunk.port_id, subport.port_id)
|
||||
return str(uuid.uuid5(trunk_models.UUID_NAMESPACE, base))
|
||||
|
||||
def _add_trunk_handler(self, *args, **kwargs):
|
||||
"""Handle the event that trunk was created"""
|
||||
payload = kwargs['payload']
|
||||
trunk = payload.current_trunk
|
||||
trunk.update(status=constants.ACTIVE_STATUS)
|
||||
|
||||
def _add_subports_handler(self, *args, **kwargs):
|
||||
"""Handle the event that subports were created"""
|
||||
payload = kwargs['payload']
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from neutron.services.trunk import constants as trunk_const
|
||||
from neutron.services.trunk import drivers as trunk_drivers
|
||||
from neutron.services.trunk import plugin as trunk_plugin
|
||||
from neutron_lib import constants
|
||||
|
@ -63,6 +64,20 @@ class TestDFTrunkDriver(test_mech_driver.DFMechanismDriverTestCase):
|
|||
df_driver = driver.DragonflowDriver()
|
||||
self.assertFalse(df_driver.is_loaded)
|
||||
|
||||
def test_driver_create_trunk(self):
|
||||
# Create parent port
|
||||
# Create trunk port
|
||||
# Check trunk is ACTIVE
|
||||
with self.port() as parent:
|
||||
trunk = self.trunk_plugin.create_trunk(self.context, {
|
||||
'trunk': {
|
||||
'port_id': parent['port']['id'],
|
||||
'tenant_id': 'project1',
|
||||
'sub_ports': [],
|
||||
}
|
||||
})
|
||||
self.assertTrue(trunk['status'] == trunk_const.ACTIVE_STATUS)
|
||||
|
||||
def test_driver_create_delete_subport(self):
|
||||
# Create parent port
|
||||
# Create sub port
|
||||
|
|
Loading…
Reference in New Issue