mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 04:31:13 +01:00
Optimized code
This commit is contained in:
parent
135838173c
commit
9f50c9e5b9
@ -73,17 +73,16 @@ if __name__ == "__main__":
|
|||||||
volumes = run_command("docker volume ls -q").splitlines()
|
volumes = run_command("docker volume ls -q").splitlines()
|
||||||
|
|
||||||
for volume in volumes:
|
for volume in volumes:
|
||||||
# List all containers using this volume
|
|
||||||
containers = run_command(f"docker ps -q --filter volume={volume}").splitlines()
|
containers = run_command(f"docker ps -q --filter volume={volume}").splitlines()
|
||||||
volume_path = get_volume_path(volume)
|
volume_path = get_volume_path(volume)
|
||||||
if is_symbolic_link(volume_path):
|
if is_symbolic_link(volume_path):
|
||||||
print(f"Skipped Volume {volume}. The storage path {volume_path} is a symbolic link.")
|
print(f"Skipped Volume {volume}. The storage path {volume_path} is a symbolic link.")
|
||||||
elif has_container_with_database(containers):
|
elif has_container_with_database(containers):
|
||||||
print(f"Container {container} with database image found. Safing volume {volume} on SSD.")
|
print(f"Safing volume {volume} on SSD.")
|
||||||
pause_and_move(ssd_path,volume,containers)
|
pause_and_move(ssd_path, volume, volume_path, containers)
|
||||||
else:
|
else:
|
||||||
print(f"Container {container} with file image found. Safing volume {volume} on HDD.")
|
print(f"Safing volume {volume} on HDD.")
|
||||||
pause_and_move(hdd_path,volume,containers)
|
pause_and_move(hdd_path, volume, volume_path, containers)
|
||||||
|
|
||||||
print("Operation completed.")
|
print("Operation completed.")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user