@@ -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" )
@@ -196,6 +198,7 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
196198 osnameforhypervisor = testosname ,
197199 osmappingcheckenabled = True
198200 )
201+ self .cleanup .append (self .guestosmapping1 )
199202
200203 list_guestos_mapping = GuestOsMapping .list (self .apiclient , id = self .guestosmapping1 .id , listall = True )
201204 self .assertNotEqual (
@@ -214,11 +217,13 @@ def test_guest_OS_mapping_check_with_hypervisor(self):
214217 self .apiclient ,
215218 id = self .guestosmapping1 .id
216219 )
220+ self .cleanup .remove (self .guestosmapping1 )
217221
218222 GuestOS .remove (
219223 self .apiclient ,
220224 id = self .guestos1 .id
221225 )
226+ self .cleanup .remove (self .guestos1 )
222227
223228 @attr (tags = ['advanced' , 'simulator' , 'basic' , 'sg' ], required_hardware = False )
224229 def test_guest_OS_mapping_check_with_hypervisor_failure (self ):
@@ -234,6 +239,7 @@ def test_guest_OS_mapping_check_with_hypervisor_failure(self):
234239 osdisplayname = "testOSname2" ,
235240 oscategoryid = os_category .id
236241 )
242+ self .cleanup .append (self .guestos1 )
237243
238244 if self .hypervisor .hypervisor .lower () not in ["xenserver" , "vmware" ]:
239245 raise unittest .SkipTest ("OS name check with hypervisor is supported only on XenServer and VMware" )
@@ -249,15 +255,18 @@ def test_guest_OS_mapping_check_with_hypervisor_failure(self):
249255 osnameforhypervisor = testosname ,
250256 osmappingcheckenabled = True
251257 )
258+ self .cleanup .append (self .guestosmapping1 )
252259 GuestOsMapping .remove (
253260 self .apiclient ,
254261 id = self .guestosmapping1 .id
255262 )
263+ self .cleanup .remove (self .guestosmapping1 )
256264 self .fail ("Since os mapping name is wrong, this API should fail" )
257265 except CloudstackAPIException as e :
258266 self .debug ("Addition guest OS mapping failed as expected %s " % e )
259267 GuestOS .remove (
260268 self .apiclient ,
261269 id = self .guestos1 .id
262270 )
271+ self .cleanup .remove (self .guestos1 )
263272 return
0 commit comments