@@ -306,7 +306,7 @@ def setUpClass(cls):
306306 podid = cls .pod .id ,
307307 tags = cls .services ["storage_tags" ]["a" ]
308308 )
309- cls . _cleanup . append ( cls . storage_pool_1 )
309+ #PS not appended to _cleanup, it is removed on tearDownClass before cleaning up resources
310310 assert cls .storage_pool_1 .state == 'Up'
311311 storage_pools_response = list_storage_pools (cls .apiclient ,
312312 id = cls .storage_pool_1 .id )
@@ -369,7 +369,18 @@ def setUpClass(cls):
369369 def tearDownClass (cls ):
370370 try :
371371 # First expunge vm, so PS can be cleaned up
372- cls .virtual_machine_1 .delete (cls .apiclient , expunge = True )
372+ cls .virtual_machine_1 .delete (cls .apiclient )
373+
374+ # Force delete primary storage
375+ cmd = enableStorageMaintenance .enableStorageMaintenanceCmd ()
376+ cmd .id = cls .storage_pool_1 .id
377+ cls .apiclient .enableStorageMaintenance (cmd )
378+ time .sleep (30 )
379+ cmd = deleteStoragePool .deleteStoragePoolCmd ()
380+ cmd .id = cls .storage_pool_1 .id
381+ cmd .forced = True
382+ cls .apiclient .deleteStoragePool (cmd )
383+
373384 cleanup_resources (cls .apiclient , cls ._cleanup )
374385 except Exception as e :
375386 raise Exception ("Cleanup failed with %s" % e )
@@ -539,6 +550,9 @@ def test_03_migration_options_storage_tags(self):
539550 )
540551 vol = vm_1_volumes [0 ]
541552
553+ if self .hypervisor .lower () not in ["vmware" , "xenserver" ]:
554+ self .virtual_machine_1 .stop (self .apiclient )
555+
542556 # Check migration options for volume
543557 pools_response = StoragePool .listForMigration (
544558 self .apiclient ,
0 commit comments