1919""" Component tests for inter VLAN 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
31-
23+ from marvin .cloudstackTestCase import cloudstackTestCase
24+ #from marvin.cloudstackAPI import *
25+ from marvin .lib .utils import cleanup_resources , validateList
26+ from marvin .lib .base import (NetworkOffering ,
27+ Network ,
28+ VirtualMachine ,
29+ ServiceOffering ,
30+ LoadBalancerRule ,
31+ PublicIPAddress ,
32+ VPC ,
33+ VpcOffering ,
34+ PhysicalNetwork ,
35+ NetworkACL ,
36+ Account ,
37+ NATRule ,
38+ NetworkServiceProvider ,
39+ StaticNATRule )
40+ from marvin .lib .common import (get_domain ,
41+ get_zone ,
42+ get_template )
43+ from marvin .codes import PASS , FAILED
3244
3345class Services :
3446 """Test inter VLAN services
@@ -180,6 +192,28 @@ def setUpClass(cls):
180192 cls ._cleanup = [
181193 cls .service_offering ,
182194 ]
195+ try :
196+ list_physical_networks = PhysicalNetwork .list (
197+ cls .apiclient ,
198+ zoneid = cls .zone .id
199+ )
200+ assert validateList (list_physical_networks )[0 ] == PASS ,\
201+ "physical networks list validation failed"
202+
203+ cls .isOvsPluginEnabled = False
204+ for i in range (0 , len (list_physical_networks )):
205+ list_network_serviceprovider = NetworkServiceProvider .list (
206+ cls .apiclient ,
207+ physicalnetworkid = list_physical_networks [i ].id
208+ )
209+ for j in range (0 , len (list_network_serviceprovider )):
210+ if ((str (list_network_serviceprovider [j ].name ).lower () == 'ovs' ) and
211+ (str (list_network_serviceprovider [j ].state ).lower () == 'enabled' )):
212+ cls .isOvsPluginEnabled = True
213+ break
214+ except Exception as e :
215+ cls .tearDownClass ()
216+ raise unittest .SkipTest (e )
183217 return
184218
185219 @classmethod
@@ -293,6 +327,9 @@ def test_02_create_vpc_from_offering_with_distributedrouter_service_capability(s
293327 # 1. Create VPC Offering by specifying all supported Services
294328 # 2. VPC offering should be created successfully.
295329
330+ if not self .isOvsPluginEnabled :
331+ self .skipTest ("OVS plugin should be enabled to run this test case" )
332+
296333 self .debug ("Creating inter VPC offering" )
297334 vpc_off = VpcOffering .create (
298335 self .apiclient ,
@@ -332,6 +369,9 @@ def test_03_deploy_vms_in_vpc_with_distributedrouter(self):
332369 # 9. Create Egress Network ACL for this network to access google.com.
333370 # 10. Enable VPN services
334371
372+ if not self .isOvsPluginEnabled :
373+ self .skipTest ("OVS plugin should be enabled to run this test case" )
374+
335375 self .debug ("Creating a VPC offering.." )
336376 vpc_off = VpcOffering .create (
337377 self .apiclient ,
@@ -407,7 +447,7 @@ def test_03_deploy_vms_in_vpc_with_distributedrouter(self):
407447 self .debug ("Creating LB rule for IP address: %s" %
408448 public_ip .ipaddress .ipaddress )
409449
410- lb_rule = LoadBalancerRule .create (
450+ LoadBalancerRule .create (
411451 self .apiclient ,
412452 self .services ["lbrule" ],
413453 ipaddressid = public_ip .ipaddress .id ,
@@ -431,7 +471,7 @@ def test_03_deploy_vms_in_vpc_with_distributedrouter(self):
431471 network .id
432472 ))
433473
434- nat_rule = NATRule .create (
474+ NATRule .create (
435475 self .apiclient ,
436476 virtual_machine ,
437477 self .services ["natrule" ],
@@ -442,14 +482,14 @@ def test_03_deploy_vms_in_vpc_with_distributedrouter(self):
442482 )
443483
444484 self .debug ("Adding NetwrokACl rules to make PF and LB accessible" )
445- networkacl_1 = NetworkACL .create (
485+ NetworkACL .create (
446486 self .apiclient ,
447487 networkid = network .id ,
448488 services = self .services ["natrule" ],
449489 traffictype = 'Ingress'
450490 )
451491
452- networkacl_2 = NetworkACL .create (
492+ NetworkACL .create (
453493 self .apiclient ,
454494 networkid = network .id ,
455495 services = self .services ["lbrule" ],
0 commit comments