Added volume backup cleanup, small volume.* fixes
* Added the volume backups cleanup.
* Added force=True for the volume snapshots delete.
* Fixed several calls of wait_for_delete() since it needs
the object as the argument, not just the id_ string.
Related-PROD: PROD-37187
Change-Id: I89030e16d889cb811c579a1f217f747d435245e2
diff --git a/cleanup.py b/cleanup.py
index a8431d6..8767588 100644
--- a/cleanup.py
+++ b/cleanup.py
@@ -148,8 +148,9 @@
for id_ in stacks_to_delete:
_log_resource_delete(id_, stacks_to_delete[id_], 'stack')
+ stack_obj = orchestration.get_stack(id_)
orchestration.delete_stack(id_)
- orchestration.wait_for_delete(id_)
+ orchestration.wait_for_delete(stack_obj)
def cleanup_flavors():
@@ -210,10 +211,11 @@
if args.dry_run:
return
for id_ in snapshots_to_delete:
+ snapshot_obj = volume.get_snapshot(id_)
volume.reset_snapshot(id_, 'available')
_log_resource_delete(id_, snapshots_to_delete[id_], 'snapshot')
- volume.delete_snapshot(id_)
- volume.wait_for_delete(id_)
+ volume.delete_snapshot(id_, force=True)
+ volume.wait_for_delete(snapshot_obj)
def cleanup_volumes():
@@ -241,6 +243,19 @@
volume.delete_group(id_)
+def cleanup_volume_backups():
+ backups = volume.backups(all_tenants=True)
+ backups_to_delete = _filter_test_resources(backups, 'name')
+ _log_resources_count(len(backups_to_delete), 'volume backup(s)')
+ if args.dry_run:
+ return
+ for id_ in backups_to_delete:
+ backup_obj = volume.get_backup(id_)
+ _log_resource_delete(id_, backups_to_delete[id_], 'volume backup')
+ volume.delete_backup(id_)
+ volume.wait_for_delete(backup_obj)
+
+
def cleanup_volume_group_types():
group_types = volume.group_types()
group_types_to_delete = _filter_test_resources(group_types, 'name')
@@ -378,6 +393,7 @@
cleanup_stacks(stacks_alt=args.stacks_alt)
cleanup_servers()
cleanup_flavors()
+ cleanup_volume_backups()
cleanup_snapshots()
cleanup_volumes()
cleanup_volume_groups()