@@ -272,6 +272,34 @@ def validate_vpc_network(self, network, state=None):
272272 self .debug ("VPC network validated - %s" % network .name )
273273 return
274274
275+ def getFreeVlan (self , apiclient , zoneid ):
276+ """
277+ Find an unallocated VLAN outside the range allocated to the physical network.
278+
279+ @note: This does not guarantee that the VLAN is available for use in
280+ the deployment's network gear
281+ @return: physical_network, shared_vlan_tag
282+ """
283+ list_physical_networks_response = PhysicalNetwork .list (
284+ apiclient ,
285+ zoneid = zoneid
286+ )
287+ assert isinstance (list_physical_networks_response , list )
288+ assert len (list_physical_networks_response ) > 0 , "No physical networks found in zone %s" % zoneid
289+
290+ physical_network = list_physical_networks_response [0 ]
291+ vlans = xsplit (physical_network .vlan , ['-' , ',' ])
292+
293+ assert len (vlans ) > 0
294+ assert int (vlans [0 ]) < int (vlans [- 1 ]), "VLAN range %s was improperly split" % physical_network .vlan
295+ shared_ntwk_vlan = int (vlans [- 1 ]) + random .randrange (1 , 20 )
296+ if shared_ntwk_vlan > 4095 :
297+ shared_ntwk_vlan = int (vlans [0 ]) - random .randrange (1 , 20 )
298+ assert shared_ntwk_vlan > 0 , "VLAN chosen %s is invalid < 0" % shared_ntwk_vlan
299+ self .debug ("Attempting free VLAN %s for shared network creation" % shared_ntwk_vlan )
300+ return shared_ntwk_vlan
301+
302+
275303 @attr (tags = ["advanced" , "intervlan" ])
276304 def test_01_deploy_vms_in_network (self ):
277305 """ Test deploy VMs in VPC networks
@@ -1995,14 +2023,16 @@ def test_07_delete_network_with_rules(self):
19952023 services = self .services ["http_rule" ],
19962024 traffictype = 'Egress'
19972025 )
2026+
2027+ vlan = self .getFreeVlan (self .api_client , self .zone .id )
19982028
19992029 self .debug ("Creating private gateway in VPC: %s" % vpc .name )
20002030 private_gateway = PrivateGateway .create (
20012031 self .apiclient ,
20022032 gateway = '10.2.3.1' ,
20032033 ipaddress = '10.2.3.2' ,
20042034 netmask = '255.255.255.0' ,
2005- vlan = 678 ,
2035+ vlan = vlan ,
20062036 vpcid = vpc .id
20072037 )
20082038 self .debug ("Check if the private gateway created successfully?" )
@@ -2110,7 +2140,8 @@ def test_07_delete_network_with_rules(self):
21102140 self .assertEqual (
21112141 public_ips [0 ].ipaddress ,
21122142 public_ip_6 .ipaddress .ipaddress ,
2113- "List public Ip for network should list the Ip addr"
2143+ "List public Ips %s for network should list the Ip addr %s"
2144+ % (public_ips [0 ].ipaddress , public_ip_6 .ipaddress .ipaddress )
21142145 )
21152146
21162147 self .debug ("Associating public IP for network: %s" % vpc .name )
@@ -2150,13 +2181,14 @@ def test_07_delete_network_with_rules(self):
21502181 traffictype = 'Egress'
21512182 )
21522183
2184+ vlan = self .getFreeVlan (self .api_client , self .zone .id )
21532185 self .debug ("Creating private gateway in VPC: %s" % vpc .name )
21542186 private_gateway = PrivateGateway .create (
21552187 self .apiclient ,
21562188 gateway = '10.2.4.1' ,
21572189 ipaddress = '10.2.4.2' ,
21582190 netmask = '255.255.255.0' ,
2159- vlan = 678 ,
2191+ vlan = vlan ,
21602192 vpcid = vpc .id
21612193 )
21622194 self .debug ("Check if the private gateway created successfully?" )
@@ -2219,6 +2251,8 @@ def test_07_delete_network_with_rules(self):
22192251 (public_ip_1 .ipaddress .ipaddress , e ))
22202252
22212253 result = str (res )
2254+ self .debug ("result = %s, result.count = %s" % (result , result .count ("1 received" )))
2255+ self .debug ("Public IP = %s" % public_ip_1 .ipaddress .ipaddress )
22222256 self .assertEqual (
22232257 result .count ("1 received" ),
22242258 1 ,
0 commit comments