From 678f0fa9995f5b65044ee9485d869f520411a258 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 9 Jan 2024 18:25:18 +0100 Subject: [PATCH] Restructured code --- roles/storage/files/optimize.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/roles/storage/files/optimize.py b/roles/storage/files/optimize.py index 85194922..a398441a 100644 --- a/roles/storage/files/optimize.py +++ b/roles/storage/files/optimize.py @@ -6,13 +6,6 @@ def run_command(command): """ Run a shell command and return its output """ return subprocess.check_output(command, shell=True).decode('utf-8').strip() -# Path on the SSD where data will be moved -ssd_path = "/path/to/ssd" -hdd_path = "/path/to/hdd" - -# List all Docker volumes -volumes = run_command("docker volume ls -q").splitlines() - def stop_containers(containers): """Stop a list of containers.""" container_list = ' '.join(containers) @@ -52,6 +45,13 @@ def pause_and_move(storage_path,volume): start_containers(containers) +# Path on the SSD where data will be moved +ssd_path = "/path/to/ssd" +hdd_path = "/path/to/hdd" + +# List all Docker volumes +volumes = run_command("docker volume ls -q").splitlines() + for volume in volumes: # List all containers using this volume containers = run_command(f"docker ps -q --filter volume={volume}").splitlines()