diff options
author | Alexander Gerasiov <gerasiov@yandex-team.ru> | 2018-07-10 14:38:19 +0300 |
---|---|---|
committer | Alexander Gerasiov <gerasiov@yandex-team.ru> | 2018-07-10 14:38:19 +0300 |
commit | 598a95848dfa5d5ba13c99741bb54310697a2e78 (patch) | |
tree | 9f2131841870ebe4b43b61c9c65ec545178ceba8 /docker/models | |
parent | fa27a6cfe201f8d4241fff59aaa0867cb238122f (diff) |
New upstream version 3.4.1
Diffstat (limited to 'docker/models')
-rw-r--r-- | docker/models/containers.py | 18 | ||||
-rw-r--r-- | docker/models/images.py | 4 | ||||
-rw-r--r-- | docker/models/networks.py | 2 | ||||
-rw-r--r-- | docker/models/services.py | 4 |
4 files changed, 22 insertions, 6 deletions
diff --git a/docker/models/containers.py b/docker/models/containers.py index 1e06ed6..b33a718 100644 --- a/docker/models/containers.py +++ b/docker/models/containers.py @@ -6,7 +6,7 @@ from ..api import APIClient from ..constants import DEFAULT_DATA_CHUNK_SIZE from ..errors import ( ContainerError, DockerException, ImageNotFound, - create_unexpected_kwargs_error + NotFound, create_unexpected_kwargs_error ) from ..types import HostConfig from ..utils import version_gte @@ -844,7 +844,7 @@ class ContainerCollection(Collection): return self.prepare_model(resp) def list(self, all=False, before=None, filters=None, limit=-1, since=None, - sparse=False): + sparse=False, ignore_removed=False): """ List containers. Similar to the ``docker ps`` command. @@ -882,6 +882,10 @@ class ContainerCollection(Collection): information, but guaranteed not to block. Use :py:meth:`Container.reload` on resulting objects to retrieve all attributes. Default: ``False`` + ignore_removed (bool): Ignore failures due to missing containers + when attempting to inspect containers from the original list. + Set to ``True`` if race conditions are likely. Has no effect + if ``sparse=True``. Default: ``False`` Returns: (list of :py:class:`Container`) @@ -896,7 +900,15 @@ class ContainerCollection(Collection): if sparse: return [self.prepare_model(r) for r in resp] else: - return [self.get(r['Id']) for r in resp] + containers = [] + for r in resp: + try: + containers.append(self.get(r['Id'])) + # a container may have been removed while iterating + except NotFound: + if not ignore_removed: + raise + return containers def prune(self, filters=None): return self.client.api.prune_containers(filters=filters) diff --git a/docker/models/images.py b/docker/models/images.py index d4893bb..41632c6 100644 --- a/docker/models/images.py +++ b/docker/models/images.py @@ -432,6 +432,10 @@ class ImageCollection(Collection): return self.client.api.prune_images(filters=filters) prune.__doc__ = APIClient.prune_images.__doc__ + def prune_builds(self, *args, **kwargs): + return self.client.api.prune_builds(*args, **kwargs) + prune_builds.__doc__ = APIClient.prune_builds.__doc__ + def normalize_platform(platform, engine_info): if platform is None: diff --git a/docker/models/networks.py b/docker/models/networks.py index 1c2fbf2..be3291a 100644 --- a/docker/models/networks.py +++ b/docker/models/networks.py @@ -211,5 +211,5 @@ class NetworkCollection(Collection): return networks def prune(self, filters=None): - self.client.api.prune_networks(filters=filters) + return self.client.api.prune_networks(filters=filters) prune.__doc__ = APIClient.prune_networks.__doc__ diff --git a/docker/models/services.py b/docker/models/services.py index 125896b..458d2c8 100644 --- a/docker/models/services.py +++ b/docker/models/services.py @@ -126,7 +126,7 @@ class Service(Model): service_mode = ServiceMode('replicated', replicas) return self.client.api.update_service(self.id, self.version, - service_mode, + mode=service_mode, fetch_current_spec=True) def force_update(self): @@ -276,7 +276,7 @@ CONTAINER_SPEC_KWARGS = [ 'labels', 'mounts', 'open_stdin', - 'privileges' + 'privileges', 'read_only', 'secrets', 'stop_grace_period', |