Store segmentation_id during segment create
The segmentation_id of a new segment is assigned by the _handle_segment_change callback in the ML2 plugin, which is executed after the segment was created, before commiting it to the DB. This patchset adds code to update the newly created segment with the segmentation_id assigned by the callback. Change-Id: I493278a0bf5a3a0aadad10e5bee546d83b949fdc Closes-Bug: #1698596
This commit is contained in:
parent
ab0dba40d1
commit
323c29fd05
neutron
@ -114,6 +114,9 @@ class SegmentDbMixin(common_db_mixin.CommonDbMixin):
|
||||
registry.notify(
|
||||
resources.SEGMENT, events.PRECOMMIT_CREATE, self,
|
||||
context=context, segment=new_segment)
|
||||
# The new segment might have been updated by the callbacks
|
||||
# subscribed to the PRECOMMIT_CREATE event. So update it in the DB
|
||||
new_segment.update()
|
||||
return new_segment
|
||||
|
||||
@log_helpers.log_method_call
|
||||
|
@ -1424,13 +1424,33 @@ class TestSegmentAwareIpam(SegmentAwareIpamTestCase):
|
||||
|
||||
|
||||
class TestSegmentAwareIpamML2(TestSegmentAwareIpam):
|
||||
|
||||
VLAN_MIN = 200
|
||||
VLAN_MAX = 209
|
||||
|
||||
def setUp(self):
|
||||
config.cfg.CONF.set_override('network_vlan_ranges',
|
||||
['physnet:200:209', 'physnet0:200:209',
|
||||
'physnet1:200:209', 'physnet2:200:209'],
|
||||
group='ml2_type_vlan')
|
||||
# NOTE(mlavalle): ml2_type_vlan requires to be registered before used.
|
||||
# This piece was refactored and removed from .config, so it causes
|
||||
# a problem, when tests are executed with pdb.
|
||||
# There is no problem when tests are running without debugger.
|
||||
driver_type.register_ml2_drivers_vlan_opts()
|
||||
config.cfg.CONF.set_override(
|
||||
'network_vlan_ranges',
|
||||
['physnet:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
|
||||
'physnet0:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
|
||||
'physnet1:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
|
||||
'physnet2:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX)],
|
||||
group='ml2_type_vlan')
|
||||
super(TestSegmentAwareIpamML2, self).setUp(plugin='ml2')
|
||||
|
||||
def test_segmentation_id_stored_in_db(self):
|
||||
network, segment, subnet = self._create_test_segment_with_subnet()
|
||||
self.assertTrue(self.VLAN_MIN <=
|
||||
segment['segment']['segmentation_id'] <= self.VLAN_MAX)
|
||||
retrieved_segment = self._show('segments', segment['segment']['id'])
|
||||
self.assertEqual(segment['segment']['segmentation_id'],
|
||||
retrieved_segment['segment']['segmentation_id'])
|
||||
|
||||
|
||||
class TestNovaSegmentNotifier(SegmentAwareIpamTestCase):
|
||||
_mechanism_drivers = ['openvswitch', 'logger']
|
||||
|
Loading…
x
Reference in New Issue
Block a user