summaryrefslogtreecommitdiff
path: root/docker/api/service.py
diff options
context:
space:
mode:
Diffstat (limited to 'docker/api/service.py')
-rw-r--r--docker/api/service.py14
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)