sp-rand: break "remove this and that" into separate functions.

Change-Id: Ic94c6e5ac4e0ccb8bfdc837766c3af48b9124463
diff --git a/tools/sp-rand/src/sp_rand/cleanup.py b/tools/sp-rand/src/sp_rand/cleanup.py
index 80ff052..767762b 100644
--- a/tools/sp-rand/src/sp_rand/cleanup.py
+++ b/tools/sp-rand/src/sp_rand/cleanup.py
@@ -106,8 +106,8 @@
         print("No iSCSI targets to remove, not looking for exports at all")
 
 
-def remove_volumes(cfg: Config, api: spapi.Api, prefix: str) -> None:
-    """Detach and remove any pertinent StorPool volumes and snapshots."""
+def remove_attachments(cfg: Config, api: spapi.Api, prefix: str) -> None:
+    """Detach StorPool volumes and snapshots from the test hosts."""
     print("Querying the StorPool API for attached volumes and snapshots")
     to_detach = []
     for desc in api.attachmentsList():  # pylint: disable=not-callable
@@ -135,8 +135,9 @@
                 sptypes.VolumesReassignWaitDesc(reassign=to_detach)
             )
 
-    remove_iscsi_targets_and_exports(cfg, api, prefix)
 
+def remove_volumes_and_snapshots(cfg: Config, api: spapi.Api, prefix: str) -> None:
+    """Actually delete the StorPool volumes and snapshots."""
     print("Querying the StorPool API for existing volumes")
     for name in [vol.name for vol in api.volumesList()]:
         if not name.startswith(prefix):
@@ -154,6 +155,13 @@
             api.snapshotDelete(name)
 
 
+def remove_volumes(cfg: Config, api: spapi.Api, prefix: str) -> None:
+    """Detach and remove any pertinent StorPool volumes and snapshots."""
+    remove_attachments(cfg, api, prefix)
+    remove_iscsi_targets_and_exports(cfg, api, prefix)
+    remove_volumes_and_snapshots(cfg, api, prefix)
+
+
 def remove_file(cfg: Config, conffile: pathlib.Path) -> None:
     """Remove the StorPool configuration file."""
     print(f"Removing {conffile}")