Add "project_id" filter when changing the network segmentation ID
When the segmentation ID of a network is updated, first the provider network segment is validated and then reserved. If service plugin "network_segment_range" is enabled, the Neutron server retrieves the network segment ranges with shared=True or those ones with the same project_id as the network. This patch adds the "project_id" information to the filters when reserving the network provider segment. This change will allow to retrieve those private networks segments belonging to the same project. Change-Id: I21bd60af000276779f56b3a6d45b4a6c1836bed1 Closes-Bug: #1863619
This commit is contained in:
parent
e61ba4008a
commit
0d43372f14
|
@ -232,6 +232,7 @@ class TypeManager(stevedore.named.NamedExtensionManager):
|
|||
Update operation is currently only supported for VLAN type segments,
|
||||
and only the SEGMENTATION_ID field can be changed.
|
||||
"""
|
||||
project_id = network['project_id']
|
||||
segmentation_id = net_data.get(provider.SEGMENTATION_ID)
|
||||
network_type = segment[api.NETWORK_TYPE]
|
||||
if network_type != constants.TYPE_VLAN:
|
||||
|
@ -246,7 +247,8 @@ class TypeManager(stevedore.named.NamedExtensionManager):
|
|||
api.PHYSICAL_NETWORK: segment[api.PHYSICAL_NETWORK],
|
||||
api.SEGMENTATION_ID: segmentation_id}
|
||||
self.validate_provider_segment(new_segment)
|
||||
self.reserve_provider_segment(context, new_segment)
|
||||
self.reserve_provider_segment(context, new_segment,
|
||||
filters={'project_id': project_id})
|
||||
self._update_network_segment(context, segment['id'], segmentation_id)
|
||||
self.release_network_segment(context, segment)
|
||||
|
||||
|
|
|
@ -213,7 +213,8 @@ class TypeManagerTestCase(base.BaseTestCase):
|
|||
super(TypeManagerTestCase, self).setUp()
|
||||
self.type_manager = managers.TypeManager()
|
||||
self.ctx = mock.Mock()
|
||||
self.network = {'id': uuidutils.generate_uuid()}
|
||||
self.network = {'id': uuidutils.generate_uuid(),
|
||||
'project_id': uuidutils.generate_uuid()}
|
||||
|
||||
def test_update_network_segment_no_vlan_no_segmentation_id(self):
|
||||
net_data = {}
|
||||
|
@ -248,7 +249,9 @@ class TypeManagerTestCase(base.BaseTestCase):
|
|||
self.type_manager.update_network_segment(self.ctx, self.network,
|
||||
net_data, segment)
|
||||
mock_validate.assert_called_once_with(new_segment)
|
||||
mock_reserve.assert_called_once_with(self.ctx, new_segment)
|
||||
mock_reserve.assert_called_once_with(
|
||||
self.ctx, new_segment,
|
||||
filters={'project_id': self.network['project_id']})
|
||||
mock_update_network_segment.assert_called_once_with(
|
||||
self.ctx, segment['id'], segmentation_id)
|
||||
mock_release.assert_called_once_with(self.ctx, segment)
|
||||
|
|
Loading…
Reference in New Issue