Move container listing to utils module for each mocking
This commit is contained in:
parent
cf76803d3f
commit
97ed56feb9
|
@ -3,6 +3,8 @@ import docker
|
||||||
import json
|
import json
|
||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
|
from restic_volume_backup import utils
|
||||||
|
|
||||||
DOCKER_BASE_URL = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock"
|
DOCKER_BASE_URL = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock"
|
||||||
VOLUME_TYPE_BIND = "bind"
|
VOLUME_TYPE_BIND = "bind"
|
||||||
VOLUME_TYPE_VOLUME = "volume"
|
VOLUME_TYPE_VOLUME = "volume"
|
||||||
|
@ -121,10 +123,7 @@ class Mount:
|
||||||
class RunningContainers:
|
class RunningContainers:
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
client = docker.Client(base_url=DOCKER_BASE_URL)
|
all_containers = utils.list_containers()
|
||||||
all_containers = client.containers()
|
|
||||||
client.close()
|
|
||||||
|
|
||||||
self.containers = []
|
self.containers = []
|
||||||
self.this_container = None
|
self.this_container = None
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
import docker
|
||||||
|
|
||||||
|
|
||||||
|
def list_containers():
|
||||||
|
client = docker.Client(base_url=DOCKER_BASE_URL)
|
||||||
|
all_containers = client.containers()
|
||||||
|
client.close()
|
||||||
|
return all_containers
|
Loading…
Reference in New Issue