1818"""
1919# Import Local Modules
2020from nose .plugins .attrib import attr
21- from marvin .cloudstackTestCase import cloudstackTestCase , unittest
21+ from marvin .cloudstackTestCase import cloudstackTestCase
2222
2323from marvin .lib .base import (Snapshot ,
2424 Template ,
@@ -167,9 +167,12 @@ def setUpClass(cls):
167167 cls .domain = get_domain (cls .api_client )
168168 cls .zone = get_zone (cls .api_client , cls .testClient .getZoneForTests ())
169169 cls .services ['mode' ] = cls .zone .networktype
170- cls .hypervisor = cls .testClient .getHypervisorInfo ()
171- if cls .hypervisor .lower () in ['lxc' ]:
172- raise unittest .SkipTest ("snapshots are not supported on %s" % cls .hypervisor .lower ())
170+ cls ._cleanup = []
171+ cls .unsupportedHypervisor = False
172+ cls .hypervisor = get_hypervisor_type (cls .api_client )
173+ if cls .hypervisor .lower () in ['hyperv' , 'lxc' ]:
174+ cls .unsupportedHypervisor = True
175+ return
173176 cls .disk_offering = DiskOffering .create (
174177 cls .api_client ,
175178 cls .services ["disk_offering" ]
@@ -196,9 +199,6 @@ def setUpClass(cls):
196199 cls .services ["service_offering" ]
197200 )
198201
199- # Get Hypervisor Type
200- cls .hypervisor = (get_hypervisor_type (cls .api_client )).lower ()
201-
202202 cls ._cleanup = [
203203 cls .service_offering ,
204204 cls .disk_offering
@@ -216,15 +216,21 @@ def tearDownClass(cls):
216216
217217 def setUp (self ):
218218 self .apiclient = self .testClient .getApiClient ()
219- self .hypervisor = str (self .testClient .getHypervisorInfo ()).lower ()
220219 self .dbclient = self .testClient .getDbConnection ()
220+ self .cleanup = []
221+
222+ if self .unsupportedHypervisor :
223+ self .skipTest ("Skipping test because unsupported hypervisor: %s" %
224+ self .hypervisor )
225+
221226
222227 # Create VMs, NAT Rules etc
223228 self .account = Account .create (
224229 self .apiclient ,
225230 self .services ["account" ],
226231 domainid = self .domain .id
227232 )
233+ self .cleanup .append (self .account )
228234
229235 self .virtual_machine = self .virtual_machine_with_disk = \
230236 VirtualMachine .create (
@@ -236,7 +242,6 @@ def setUp(self):
236242 serviceofferingid = self .service_offering .id ,
237243 mode = self .services ["mode" ]
238244 )
239- self .cleanup = [self .account , ]
240245 return
241246
242247 def tearDown (self ):
@@ -966,15 +971,17 @@ def setUpClass(cls):
966971 TestCreateVMSnapshotTemplate ,
967972 cls ).getClsTestClient ()
968973 cls .api_client = cls .testClient .getApiClient ()
969- cls .hypervisor = cls . testClient . getHypervisorInfo ()
974+ cls ._cleanup = []
970975 cls .services = Services ().services
971976 # Get Zone, Domain and templates
972977 cls .domain = get_domain (cls .api_client )
973978 cls .zone = get_zone (cls .api_client , cls .testClient .getZoneForTests ())
974979 cls .services ['mode' ] = cls .zone .networktype
975- cls .hypervisor = cls .testClient .getHypervisorInfo ()
976- if cls .hypervisor .lower () in ['lxc' ]:
977- raise unittest .SkipTest ("snapshots are not supported on %s" % cls .hypervisor .lower ())
980+ cls .unsupportedHypervisor = False
981+ cls .hypervisor = get_hypervisor_type (cls .api_client )
982+ if cls .hypervisor .lower () in ['hyperv' , 'lxc' ]:
983+ cls .unsupportedHypervisor = True
984+ return
978985
979986 cls .template = get_template (
980987 cls .api_client ,
@@ -1012,9 +1019,11 @@ def tearDownClass(cls):
10121019
10131020 def setUp (self ):
10141021 self .apiclient = self .testClient .getApiClient ()
1015- self .hypervisor = str (self .testClient .getHypervisorInfo ()).lower ()
10161022 self .dbclient = self .testClient .getDbConnection ()
10171023 self .cleanup = []
1024+
1025+ if self .unsupportedHypervisor :
1026+ self .skipTest ("snapshots are not supported on %s" % self .hypervisor .lower ())
10181027 return
10191028
10201029 def tearDown (self ):
@@ -1183,15 +1192,17 @@ class TestSnapshotEvents(cloudstackTestCase):
11831192 def setUpClass (cls ):
11841193 cls .testClient = super (TestSnapshotEvents , cls ).getClsTestClient ()
11851194 cls .api_client = cls .testClient .getApiClient ()
1186- cls .hypervisor = cls .testClient .getHypervisorInfo ()
11871195 cls .services = Services ().services
1196+ cls ._cleanup = []
11881197 # Get Zone, Domain and templates
11891198 cls .domain = get_domain (cls .api_client )
11901199 cls .zone = get_zone (cls .api_client , cls .testClient .getZoneForTests ())
11911200 cls .services ['mode' ] = cls .zone .networktype
1192- cls .hypervisor = cls .testClient .getHypervisorInfo ()
1193- if cls .hypervisor .lower () in ['lxc' ]:
1194- raise unittest .SkipTest ("snapshots are not supported on %s" % cls .hypervisor .lower ())
1201+ cls .unsupportedHypervisor = False
1202+ cls .hypervisor = get_hypervisor_type (cls .api_client )
1203+ if cls .hypervisor .lower () in ['hyperv' , 'lxc' ]:
1204+ cls .unsupportedHypervisor = True
1205+ return
11951206
11961207 template = get_template (
11971208 cls .api_client ,
@@ -1241,9 +1252,11 @@ def tearDownClass(cls):
12411252
12421253 def setUp (self ):
12431254 self .apiclient = self .testClient .getApiClient ()
1244- self .hypervisor = str (self .testClient .getHypervisorInfo ()).lower ()
12451255 self .dbclient = self .testClient .getDbConnection ()
12461256 self .cleanup = []
1257+
1258+ if self .unsupportedHypervisor :
1259+ self .skipTest ("snapshots are not supported on %s" % self .hypervisor )
12471260 return
12481261
12491262 def tearDown (self ):
0 commit comments