@@ -47,19 +47,14 @@ def setUpClass(cls):
4747
4848 cls .hypervisor = cls .get_hypervisor_type ()
4949
50- @classmethod
5150 def setUp (self ):
5251 self .apiclient = self .testClient .getApiClient ()
5352
5453 #build cleanup list
5554 self .cleanup = []
5655
57- @classmethod
5856 def tearDown (self ):
59- try :
60- cleanup_resources (self .apiclient , self .cleanup )
61- except Exception as e :
62- self .debug ("Warning! Exception in tearDown: %s" % e )
57+ super (TestGuestOS , self ).tearDown ()
6358
6459 @classmethod
6560 def get_hypervisor_type (cls ):
@@ -95,6 +90,7 @@ def test_CRUD_operations_guest_OS(self):
9590 osdisplayname = "testCentOS" ,
9691 oscategoryid = os_category .id
9792 )
93+ self .cleanup .append (self .guestos1 )
9894 list_guestos = GuestOS .list (self .apiclient , id = self .guestos1 .id , listall = True )
9995 self .assertNotEqual (
10096 len (list_guestos ),
@@ -112,6 +108,7 @@ def test_CRUD_operations_guest_OS(self):
112108 self .apiclient ,
113109 id = self .guestos1 .id
114110 )
111+ self .cleanup .remove (self .guestos1 )
115112
116113 @attr (tags = ['advanced' , 'simulator' , 'basic' , 'sg' ], required_hardware = False )
117114 def test_CRUD_operations_guest_OS_mapping (self ):
@@ -127,6 +124,7 @@ def test_CRUD_operations_guest_OS_mapping(self):
127124 osdisplayname = "testCentOS" ,
128125 oscategoryid = os_category .id
129126 )
127+ self .cleanup .append (self .guestos1 )
130128
131129 if self .hypervisor .hypervisor .lower () not in ["xenserver" , "vmware" ]:
132130 raise unittest .SkipTest ("OS name check with hypervisor is supported only on XenServer and VMware" )
@@ -138,6 +136,7 @@ def test_CRUD_operations_guest_OS_mapping(self):
138136 hypervisorversion = self .hypervisor .hypervisorversion ,
139137 osnameforhypervisor = "testOSMappingName"
140138 )
139+ self .cleanup .append (self .guestosmapping1 )
141140
142141 list_guestos_mapping = GuestOsMapping .list (self .apiclient , id = self .guestosmapping1 .id , listall = True )
143142 self .assertNotEqual (
@@ -156,11 +155,13 @@ def test_CRUD_operations_guest_OS_mapping(self):
156155 self .apiclient ,
157156 id = self .guestosmapping1 .id
158157 )
158+ self .cleanup .remove (self .guestosmapping1 )
159159
160160 GuestOS .remove (
161161 self .apiclient ,
162162 id = self .guestos1 .id
163163 )
164+ self .cleanup .remove (self .guestos1 )
164165
165166 @attr (tags = ['advanced' , 'simulator' , 'basic' , 'sg' ], required_hardware = False )
166167 def test_guest_OS_mapping_check_with_hypervisor (self ):
@@ -176,6 +177,7 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
176177 osdisplayname = "testOSname1" ,
177178 oscategoryid = os_category .id
178179 )
180+ self .cleanup .append (self .guestos1 )
179181
180182 if self .hypervisor .hypervisor .lower () not in ["xenserver" , "vmware" ]:
181183 raise unittest .SkipTest ("OS name check with hypervisor is supported only on XenServer and VMware" )
@@ -193,6 +195,7 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
193195 osnameforhypervisor = testosname ,
194196 osmappingcheckenabled = True
195197 )
198+ self .cleanup .append (self .guestosmapping1 )
196199
197200 list_guestos_mapping = GuestOsMapping .list (self .apiclient , id = self .guestosmapping1 .id , listall = True )
198201 self .assertNotEqual (
@@ -211,11 +214,13 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
211214 self .apiclient ,
212215 id = self .guestosmapping1 .id
213216 )
217+ self .cleanup .remove (self .guestosmapping1 )
214218
215219 GuestOS .remove (
216220 self .apiclient ,
217221 id = self .guestos1 .id
218222 )
223+ self .cleanup .remove (self .guestos1 )
219224
220225 @attr (tags = ['advanced' , 'simulator' , 'basic' , 'sg' ], required_hardware = False )
221226 def test_guest_OS_mapping_check_with_hypervisor_failure (self ):
@@ -231,6 +236,7 @@ def test_guest_OS_mapping_check_with_hypervisor_failure(self):
231236 osdisplayname = "testOSname2" ,
232237 oscategoryid = os_category .id
233238 )
239+ self .cleanup .append (self .guestos1 )
234240
235241 if self .hypervisor .hypervisor .lower () not in ["xenserver" , "vmware" ]:
236242 raise unittest .SkipTest ("OS name check with hypervisor is supported only on XenServer and VMware" )
@@ -246,15 +252,18 @@ def test_guest_OS_mapping_check_with_hypervisor_failure(self):
246252 osnameforhypervisor = testosname ,
247253 osmappingcheckenabled = True
248254 )
255+ self .cleanup .append (self .guestosmapping1 )
249256 GuestOsMapping .remove (
250257 self .apiclient ,
251258 id = self .guestosmapping1 .id
252259 )
260+ self .cleanup .remove (self .guestosmapping1 )
253261 self .fail ("Since os mapping name is wrong, this API should fail" )
254262 except CloudstackAPIException as e :
255263 self .debug ("Addition guest OS mapping failed as expected %s " % e )
256264 GuestOS .remove (
257265 self .apiclient ,
258266 id = self .guestos1 .id
259267 )
268+ self .cleanup .remove (self .guestos1 )
260269 return
0 commit comments