Populate full VLAN range in "parse_network_vlan_ranges"
The method "parse_network_vlan_ranges" parses the "network_vlan_ranges" parameter that defines, for the VLAN type driver, the available physical networks and the assigned VLAN ID ranges. If only the network name is passed without defining a VLAN ID range, that means all valid VLAN IDs are allowed (1, 4094). The returned variable should contain this range in this case. Change-Id: I53726d64167ba38c233c2cfc095ff6462bcb664e Closes-Bug: #1918274
This commit is contained in:
parent
698e4c8daa
commit
02e070fe09
@ -324,6 +324,7 @@ NETWORK_SEGMENT_RANGE_TYPES = [TYPE_VLAN, TYPE_VXLAN, TYPE_GRE, TYPE_GENEVE]
|
||||
# For VLAN Network
|
||||
MIN_VLAN_TAG = 1
|
||||
MAX_VLAN_TAG = 4094
|
||||
VLAN_VALID_RANGE = (MIN_VLAN_TAG, MAX_VLAN_TAG)
|
||||
|
||||
# For Geneve Tunnel
|
||||
MIN_GENEVE_VNI = 1
|
||||
|
@ -199,9 +199,11 @@ def parse_network_vlan_ranges(network_vlan_ranges_cfg_entries):
|
||||
for entry in network_vlan_ranges_cfg_entries:
|
||||
network, vlan_range = parse_network_vlan_range(entry)
|
||||
if vlan_range:
|
||||
if networks.get(network) == [constants.VLAN_VALID_RANGE]:
|
||||
continue
|
||||
networks.setdefault(network, []).append(vlan_range)
|
||||
else:
|
||||
networks.setdefault(network, [])
|
||||
networks[network] = [constants.VLAN_VALID_RANGE]
|
||||
return networks
|
||||
|
||||
|
||||
|
@ -83,8 +83,9 @@ class TestUtils(base.BaseTestCase):
|
||||
'n1:a:4')
|
||||
|
||||
def test_parse_network_vlan_ranges(self):
|
||||
ranges = utils.parse_network_vlan_ranges(['n1:1:3', 'n2:2:4'])
|
||||
self.assertEqual(2, len(ranges.keys()))
|
||||
ranges = utils.parse_network_vlan_ranges(
|
||||
['n1:1:3', 'n2:2:4', 'n3', 'n4', 'n4:10:12'])
|
||||
self.assertEqual(4, len(ranges.keys()))
|
||||
self.assertIn('n1', ranges.keys())
|
||||
self.assertIn('n2', ranges.keys())
|
||||
self.assertEqual(2, len(ranges['n1'][0]))
|
||||
@ -93,6 +94,8 @@ class TestUtils(base.BaseTestCase):
|
||||
self.assertEqual(2, len(ranges['n2'][0]))
|
||||
self.assertEqual(2, ranges['n2'][0][0])
|
||||
self.assertEqual(4, ranges['n2'][0][1])
|
||||
self.assertEqual([constants.VLAN_VALID_RANGE], ranges['n3'])
|
||||
self.assertEqual([constants.VLAN_VALID_RANGE], ranges['n4'])
|
||||
|
||||
def test_is_valid_gre_id(self):
|
||||
for v in [constants.MIN_GRE_ID, constants.MIN_GRE_ID + 2,
|
||||
|
Loading…
Reference in New Issue
Block a user