summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAron Parsons <aron@knackworks.com>2018-07-18 19:02:44 -0400
committerJoffrey F <joffrey@docker.com>2018-08-09 17:11:47 -0700
commitdac943a91dfc6622ff77bae5521214a4faaa3f02 (patch)
tree8c04b47d883e42bc7ba29f0671a18e96e481b20d
parent29dee5ac2e6a952b4d66090549a5a443e15c29d6 (diff)
downloaddocker-py-dac943a91dfc6622ff77bae5521214a4faaa3f02.tar.gz
honor placement preferences via services.create()
this allows creating a service with placement preferences when calling services.create(). only constraints were being honored before. related to https://github.com/docker/docker-py/pull/1615 Signed-off-by: Aron Parsons <aron@knackworks.com>
-rw-r--r--docker/models/services.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/docker/models/services.py b/docker/models/services.py
index 458d2c8..612f345 100644
--- a/docker/models/services.py
+++ b/docker/models/services.py
@@ -321,10 +321,15 @@ def _get_create_service_kwargs(func_name, kwargs):
if 'container_labels' in kwargs:
container_spec_kwargs['labels'] = kwargs.pop('container_labels')
+ placement = {}
+
if 'constraints' in kwargs:
- task_template_kwargs['placement'] = {
- 'Constraints': kwargs.pop('constraints')
- }
+ placement['Constraints'] = kwargs.pop('constraints')
+
+ if 'preferences' in kwargs:
+ placement['Preferences'] = kwargs.pop('preferences')
+
+ task_template_kwargs['placement'] = placement
if 'log_driver' in kwargs:
task_template_kwargs['log_driver'] = {