mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-22 04:31:13 +01:00
Restructured code
This commit is contained in:
parent
4820f2468c
commit
678f0fa999
@ -6,13 +6,6 @@ def run_command(command):
|
|||||||
""" Run a shell command and return its output """
|
""" Run a shell command and return its output """
|
||||||
return subprocess.check_output(command, shell=True).decode('utf-8').strip()
|
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):
|
def stop_containers(containers):
|
||||||
"""Stop a list of containers."""
|
"""Stop a list of containers."""
|
||||||
container_list = ' '.join(containers)
|
container_list = ' '.join(containers)
|
||||||
@ -52,6 +45,13 @@ def pause_and_move(storage_path,volume):
|
|||||||
|
|
||||||
start_containers(containers)
|
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:
|
for volume in volumes:
|
||||||
# List all containers using this volume
|
# 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()
|
||||||
|
Loading…
Reference in New Issue
Block a user