summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-06-19 21:53:32 +0000
committerGerrit Code Review <review@openstack.org>2017-06-19 21:53:32 +0000
commit6af12de193dc619c491c8534970ebc00bae6e653 (patch)
treef968dc5cef5d56e7a27b7b21b1a08d21b6de3f70
parente54b2e4a3e8f4df8425232696177be564cde6054 (diff)
parent323c29fd054913493325ad0e987007181fb48976 (diff)
Merge "Store segmentation_id during segment create"
-rw-r--r--neutron/services/segments/db.py3
-rw-r--r--neutron/tests/unit/extensions/test_segment.py28
2 files changed, 27 insertions, 4 deletions
diff --git a/neutron/services/segments/db.py b/neutron/services/segments/db.py
index 9b31232..b71fda7 100644
--- a/neutron/services/segments/db.py
+++ b/neutron/services/segments/db.py
@@ -114,6 +114,9 @@ class SegmentDbMixin(common_db_mixin.CommonDbMixin):
114 registry.notify( 114 registry.notify(
115 resources.SEGMENT, events.PRECOMMIT_CREATE, self, 115 resources.SEGMENT, events.PRECOMMIT_CREATE, self,
116 context=context, segment=new_segment) 116 context=context, segment=new_segment)
117 # The new segment might have been updated by the callbacks
118 # subscribed to the PRECOMMIT_CREATE event. So update it in the DB
119 new_segment.update()
117 return new_segment 120 return new_segment
118 121
119 @log_helpers.log_method_call 122 @log_helpers.log_method_call
diff --git a/neutron/tests/unit/extensions/test_segment.py b/neutron/tests/unit/extensions/test_segment.py
index 900fba4..12ec1b1 100644
--- a/neutron/tests/unit/extensions/test_segment.py
+++ b/neutron/tests/unit/extensions/test_segment.py
@@ -1424,13 +1424,33 @@ class TestSegmentAwareIpam(SegmentAwareIpamTestCase):
1424 1424
1425 1425
1426class TestSegmentAwareIpamML2(TestSegmentAwareIpam): 1426class TestSegmentAwareIpamML2(TestSegmentAwareIpam):
1427
1428 VLAN_MIN = 200
1429 VLAN_MAX = 209
1430
1427 def setUp(self): 1431 def setUp(self):
1428 config.cfg.CONF.set_override('network_vlan_ranges', 1432 # NOTE(mlavalle): ml2_type_vlan requires to be registered before used.
1429 ['physnet:200:209', 'physnet0:200:209', 1433 # This piece was refactored and removed from .config, so it causes
1430 'physnet1:200:209', 'physnet2:200:209'], 1434 # a problem, when tests are executed with pdb.
1431 group='ml2_type_vlan') 1435 # There is no problem when tests are running without debugger.
1436 driver_type.register_ml2_drivers_vlan_opts()
1437 config.cfg.CONF.set_override(
1438 'network_vlan_ranges',
1439 ['physnet:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
1440 'physnet0:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
1441 'physnet1:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX),
1442 'physnet2:%s:%s' % (self.VLAN_MIN, self.VLAN_MAX)],
1443 group='ml2_type_vlan')
1432 super(TestSegmentAwareIpamML2, self).setUp(plugin='ml2') 1444 super(TestSegmentAwareIpamML2, self).setUp(plugin='ml2')
1433 1445
1446 def test_segmentation_id_stored_in_db(self):
1447 network, segment, subnet = self._create_test_segment_with_subnet()
1448 self.assertTrue(self.VLAN_MIN <=
1449 segment['segment']['segmentation_id'] <= self.VLAN_MAX)
1450 retrieved_segment = self._show('segments', segment['segment']['id'])
1451 self.assertEqual(segment['segment']['segmentation_id'],
1452 retrieved_segment['segment']['segmentation_id'])
1453
1434 1454
1435class TestNovaSegmentNotifier(SegmentAwareIpamTestCase): 1455class TestNovaSegmentNotifier(SegmentAwareIpamTestCase):
1436 _mechanism_drivers = ['openvswitch', 'logger'] 1456 _mechanism_drivers = ['openvswitch', 'logger']