Resolves #1066, use labels to identify containers
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
This commit is contained in:
parent
28d2aff8b8
commit
ed50a0a3a0
9 changed files with 138 additions and 102 deletions
|
|
@ -4,6 +4,7 @@ import logging
|
|||
|
||||
from functools import reduce
|
||||
from .config import get_service_name_from_net, ConfigurationError
|
||||
from .const import LABEL_PROJECT, LABEL_ONE_OFF
|
||||
from .service import Service
|
||||
from .container import Container
|
||||
from docker.errors import APIError
|
||||
|
|
@ -60,6 +61,12 @@ class Project(object):
|
|||
self.services = services
|
||||
self.client = client
|
||||
|
||||
def labels(self, one_off=False):
|
||||
return [
|
||||
'{0}={1}'.format(LABEL_PROJECT, self.name),
|
||||
'{0}={1}'.format(LABEL_ONE_OFF, "True" if one_off else "False"),
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def from_dicts(cls, name, service_dicts, client):
|
||||
"""
|
||||
|
|
@ -224,9 +231,9 @@ class Project(object):
|
|||
|
||||
def containers(self, service_names=None, stopped=False, one_off=False):
|
||||
return [Container.from_ps(self.client, container)
|
||||
for container in self.client.containers(all=stopped)
|
||||
for service in self.get_services(service_names)
|
||||
if service.has_container(container, one_off=one_off)]
|
||||
for container in self.client.containers(
|
||||
all=stopped,
|
||||
filters={'label': self.labels(one_off=one_off)})]
|
||||
|
||||
def _inject_deps(self, acc, service):
|
||||
net_name = service.get_net_name()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue