VLAN "allocate_partially_specified_segment" can return any physnet

When allocating a partially defined segment with VLAN type driver, any
physical network can be returned. The method will select randomly any
VLAN segment available, independently of the physnet configured order.

Conflicts:
    neutron/tests/unit/plugins/ml2/drivers/test_type_vlan.py

Change-Id: I4d344f5ca6673b70b69a03503ec0f267bf0cadf7
Closes-Bug: #1929190
(cherry picked from commit 05ce5a1f94)
(cherry picked from commit c823bc3294)
(cherry picked from commit e07b66e710)
This commit is contained in:
Rodolfo Alonso Hernandez 2021-05-21 09:44:22 +00:00 committed by Slawek Kaplonski
parent 16a2fe7722
commit 9b0f094564
1 changed files with 10 additions and 4 deletions

View File

@ -251,10 +251,16 @@ class VlanTypeTest(testlib_api.SqlTestCase):
observed = self.driver.reserve_provider_segment(self.context, segment)
alloc = self._get_allocation(self.context, observed)
self.assertTrue(alloc.allocated)
vlan_id = observed[api.SEGMENTATION_ID]
self.assertThat(vlan_id, matchers.GreaterThan(VLAN_MIN - 1))
self.assertThat(vlan_id, matchers.LessThan(VLAN_MAX + 1))
self.assertEqual(TENANT_NET, observed[api.PHYSICAL_NETWORK])
if observed[api.PHYSICAL_NETWORK] == PROVIDER_NET:
self.assertIn(observed[api.SEGMENTATION_ID],
range(p_const.MIN_VLAN_TAG,
p_const.MAX_VLAN_TAG + 1))
elif observed[api.PHYSICAL_NETWORK] == TENANT_NET:
self.assertIn(observed[api.SEGMENTATION_ID],
range(VLAN_MIN, VLAN_MAX + 1))
else:
self.fail('The observed physical network %s does not match with '
'any configured' % [api.PHYSICAL_NETWORK])
def test_reserve_provider_segment_all_allocateds(self):
for __ in range(VLAN_MIN, VLAN_MAX + 1):