1919""" Component tests for region level VPC functionality
2020"""
2121#Import Local Modules
22- import marvin
2322from nose .plugins .attrib import attr
24- from marvin .cloudstackTestCase import *
25- from marvin .cloudstackAPI import *
26- from marvin .lib .utils import *
27- from marvin .lib .base import *
28- from marvin .lib .common import *
29- from marvin .sshClient import SshClient
30- import datetime
23+ from marvin .cloudstackTestCase import cloudstackTestCase
24+ from marvin .lib .utils import cleanup_resources , validateList
25+ from marvin .lib .base import (VPC ,
26+ VpcOffering ,
27+ ServiceOffering ,
28+ PhysicalNetwork ,
29+ Account ,
30+ NetworkOffering ,
31+ Network ,
32+ VirtualMachine ,
33+ NetworkServiceProvider ,
34+ PublicIPAddress ,
35+ LoadBalancerRule ,
36+ NATRule ,
37+ NetworkACL ,
38+ StaticNATRule )
39+ from marvin .lib .common import (get_domain ,
40+ get_zone ,
41+ get_template )
42+ from marvin .codes import FAILED , PASS
3143
3244
3345class Services :
@@ -161,7 +173,7 @@ class TestRegionVpcOffering(cloudstackTestCase):
161173 def setUpClass (cls ):
162174 testClient = super (TestRegionVpcOffering , cls ).getClsTestClient ()
163175 cls .apiclient = testClient .getApiClient ()
164- cls .services = testClient . getParsedTestDataConfig ()
176+ cls .services = Services (). services
165177
166178 # Get Zone, Domain and templates
167179 cls .domain = get_domain (cls .apiclient )
@@ -185,9 +197,30 @@ def setUpClass(cls):
185197 cls .apiclient ,
186198 cls .services ["service_offering" ]
187199 )
188- cls ._cleanup = [
189- cls .service_offering ,
190- ]
200+ cls ._cleanup = [cls .service_offering , ]
201+
202+ try :
203+ list_physical_networks = PhysicalNetwork .list (
204+ cls .apiclient ,
205+ zoneid = cls .zone .id
206+ )
207+ assert validateList (list_physical_networks )[0 ] == PASS ,\
208+ "physical networks list validation failed"
209+
210+ cls .isOvsPluginEnabled = False
211+ for i in range (0 , len (list_physical_networks )):
212+ list_network_serviceprovider = NetworkServiceProvider .list (
213+ cls .apiclient ,
214+ physicalnetworkid = list_physical_networks [i ].id
215+ )
216+ for j in range (0 , len (list_network_serviceprovider )):
217+ if ((str (list_network_serviceprovider [j ].name ).lower () == 'ovs' ) and
218+ (str (list_network_serviceprovider [j ].state ).lower () == 'enabled' )):
219+ cls .isOvsPluginEnabled = True
220+ break
221+ except Exception as e :
222+ cls .tearDownClass ()
223+ raise unittest .SkipTest (e )
191224 return
192225
193226 @classmethod
@@ -243,7 +276,7 @@ def validate_vpc_offering(self, vpc_offering):
243276 "Name of the VPC offering should match with listVPCOff data"
244277 )
245278 self .assertEqual (
246- vpc_offs [0 ].regionlevelvpc ,True ,
279+ vpc_offs [0 ].supportsregionLevelvpc ,True ,
247280 "VPC offering is not set up for region level VPC"
248281 )
249282 self .debug (
@@ -301,6 +334,9 @@ def test_02_create_vpc_from_offering_with_regionlevelvpc_service_capability(self
301334 # 1. Create VPC Offering by specifying all supported Services
302335 # 2. VPC offering should be created successfully.
303336
337+ if not self .isOvsPluginEnabled :
338+ self .skipTest ("OVS plugin should be enabled to run this test case" )
339+
304340 self .debug ("Creating inter VPC offering" )
305341 vpc_off = VpcOffering .create (
306342 self .apiclient ,
@@ -313,7 +349,8 @@ def test_02_create_vpc_from_offering_with_regionlevelvpc_service_capability(self
313349 vpcofferingid = vpc_off .id ,
314350 zoneid = self .zone .id ,
315351 account = self .account .name ,
316- domainid = self .account .domainid
352+ domainid = self .account .domainid ,
353+ networkDomain = self .account .domainid
317354 )
318355 self .assertEqual (vpc .distributedvpcrouter , True , "VPC created should have 'distributedvpcrouter' set to True" )
319356
@@ -340,6 +377,9 @@ def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
340377 # 9. Create Egress Network ACL for this network to access google.com.
341378 # 10. Enable VPN services
342379
380+ if not self .isOvsPluginEnabled :
381+ self .skipTest ("OVS plugin should be enabled to run this test case" )
382+
343383 self .debug ("Creating a VPC offering.." )
344384 vpc_off = VpcOffering .create (
345385 self .apiclient ,
@@ -356,7 +396,8 @@ def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
356396 vpcofferingid = vpc_off .id ,
357397 zoneid = self .zone .id ,
358398 account = self .account .name ,
359- domainid = self .account .domainid
399+ domainid = self .account .domainid ,
400+ networkDomain = self .account .domainid
360401 )
361402 self .validate_vpc_network (vpc )
362403
@@ -415,7 +456,7 @@ def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
415456 self .debug ("Creating LB rule for IP address: %s" %
416457 public_ip .ipaddress .ipaddress )
417458
418- lb_rule = LoadBalancerRule .create (
459+ LoadBalancerRule .create (
419460 self .apiclient ,
420461 self .services ["lbrule" ],
421462 ipaddressid = public_ip .ipaddress .id ,
@@ -439,7 +480,7 @@ def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
439480 network .id
440481 ))
441482
442- nat_rule = NATRule .create (
483+ NATRule .create (
443484 self .apiclient ,
444485 virtual_machine ,
445486 self .services ["natrule" ],
@@ -450,14 +491,14 @@ def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
450491 )
451492
452493 self .debug ("Adding NetwrokACl rules to make PF and LB accessible" )
453- networkacl_1 = NetworkACL .create (
494+ NetworkACL .create (
454495 self .apiclient ,
455496 networkid = network .id ,
456497 services = self .services ["natrule" ],
457498 traffictype = 'Ingress'
458499 )
459500
460- networkacl_2 = NetworkACL .create (
501+ NetworkACL .create (
461502 self .apiclient ,
462503 networkid = network .id ,
463504 services = self .services ["lbrule" ],
@@ -520,4 +561,4 @@ def test_03_deploy_vms_in_vpc_with_regionlevelvpc(self):
520561 "List public Ip for network should list the Ip addr"
521562 )
522563 # TODO: Remote Access VPN is not yet supported in VPC
523- return
564+ return
0 commit comments