diff options
author | Joffrey F <joffrey@docker.com> | 2017-01-11 18:07:25 -0800 |
---|---|---|
committer | Joffrey F <joffrey@docker.com> | 2017-01-19 16:23:32 -0800 |
commit | 06e808179991612b604ef1cecc776843df8aceac (patch) | |
tree | d6459bb77e2837deecce77e4ec704b1c60114c74 /docker/api | |
parent | 5f0b469a09421b0d6140661de9466af74ac3e9ec (diff) | |
download | docker-py-1388-format-service-mode.tar.gz |
Convert mode argument to valid structure in create_service1388-format-service-mode
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker/api')
-rw-r--r-- | docker/api/service.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/docker/api/service.py b/docker/api/service.py index 0d8421e..d2621e6 100644 --- a/docker/api/service.py +++ b/docker/api/service.py @@ -1,5 +1,6 @@ import warnings from .. import auth, errors, utils +from ..types import ServiceMode class ServiceApiMixin(object): @@ -18,8 +19,8 @@ class ServiceApiMixin(object): name (string): User-defined name for the service. Optional. labels (dict): A map of labels to associate with the service. Optional. - mode (string): Scheduling mode for the service (``replicated`` or - ``global``). Defaults to ``replicated``. + mode (ServiceMode): Scheduling mode for the service (replicated + or global). Defaults to replicated. update_config (UpdateConfig): Specification for the update strategy of the service. Default: ``None`` networks (:py:class:`list`): List of network names or IDs to attach @@ -49,6 +50,9 @@ class ServiceApiMixin(object): raise errors.DockerException( 'Missing mandatory Image key in ContainerSpec' ) + if mode and not isinstance(mode, dict): + mode = ServiceMode(mode) + registry, repo_name = auth.resolve_repository_name(image) auth_header = auth.get_config_header(self, registry) if auth_header: @@ -191,8 +195,8 @@ class ServiceApiMixin(object): name (string): New name for the service. Optional. labels (dict): A map of labels to associate with the service. Optional. - mode (string): Scheduling mode for the service (``replicated`` or - ``global``). Defaults to ``replicated``. + mode (ServiceMode): Scheduling mode for the service (replicated + or global). Defaults to replicated. update_config (UpdateConfig): Specification for the update strategy of the service. Default: ``None``. networks (:py:class:`list`): List of network names or IDs to attach @@ -222,6 +226,8 @@ class ServiceApiMixin(object): if labels is not None: data['Labels'] = labels if mode is not None: + if not isinstance(mode, dict): + mode = ServiceMode(mode) data['Mode'] = mode if task_template is not None: image = task_template.get('ContainerSpec', {}).get('Image', None) |