Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
docker-py
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
docker-py
Commits
8d35ae69
Kaydet (Commit)
8d35ae69
authored
Agu 03, 2018
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge branch 'knackworks-service-create-placement-preferences'
üst
64a1d8c6
c28ff855
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
6 deletions
+23
-6
services.py
docker/models/services.py
+16
-5
models_services_test.py
tests/unit/models_services_test.py
+7
-1
No files found.
docker/models/services.py
Dosyayı görüntüle @
8d35ae69
import
copy
from
docker.errors
import
create_unexpected_kwargs_error
,
InvalidArgument
from
docker.types
import
TaskTemplate
,
ContainerSpec
,
ServiceMode
from
docker.types
import
TaskTemplate
,
ContainerSpec
,
Placement
,
ServiceMode
from
.resource
import
Model
,
Collection
...
...
@@ -153,6 +153,9 @@ class ServiceCollection(Collection):
command (list of str or str): Command to run.
args (list of str): Arguments to the command.
constraints (list of str): Placement constraints.
preferences (list of str): Placement preferences.
platforms (list of tuple): A list of platforms constraints
expressed as ``(arch, os)`` tuples
container_labels (dict): Labels to apply to the container.
endpoint_spec (EndpointSpec): Properties that can be configured to
access and load balance a service. Default: ``None``.
...
...
@@ -302,6 +305,12 @@ CREATE_SERVICE_KWARGS = [
'endpoint_spec'
,
]
PLACEMENT_KWARGS
=
[
'constraints'
,
'preferences'
,
'platforms'
,
]
def
_get_create_service_kwargs
(
func_name
,
kwargs
):
# Copy over things which can be copied directly
...
...
@@ -321,10 +330,12 @@ def _get_create_service_kwargs(func_name, kwargs):
if
'container_labels'
in
kwargs
:
container_spec_kwargs
[
'labels'
]
=
kwargs
.
pop
(
'container_labels'
)
if
'constraints'
in
kwargs
:
task_template_kwargs
[
'placement'
]
=
{
'Constraints'
:
kwargs
.
pop
(
'constraints'
)
}
placement
=
{}
for
key
in
copy
.
copy
(
kwargs
):
if
key
in
PLACEMENT_KWARGS
:
placement
[
key
]
=
kwargs
.
pop
(
key
)
placement
=
Placement
(
**
placement
)
task_template_kwargs
[
'placement'
]
=
placement
if
'log_driver'
in
kwargs
:
task_template_kwargs
[
'log_driver'
]
=
{
...
...
tests/unit/models_services_test.py
Dosyayı görüntüle @
8d35ae69
...
...
@@ -26,6 +26,8 @@ class CreateServiceKwargsTest(unittest.TestCase):
'mounts'
:
[{
'some'
:
'mounts'
}],
'stop_grace_period'
:
5
,
'constraints'
:
[
'foo=bar'
],
'preferences'
:
[
'bar=baz'
],
'platforms'
:
[(
'x86_64'
,
'linux'
)],
})
task_template
=
kwargs
.
pop
(
'task_template'
)
...
...
@@ -41,7 +43,11 @@ class CreateServiceKwargsTest(unittest.TestCase):
'ContainerSpec'
,
'Resources'
,
'RestartPolicy'
,
'Placement'
,
'LogDriver'
,
'Networks'
])
assert
task_template
[
'Placement'
]
==
{
'Constraints'
:
[
'foo=bar'
]}
assert
task_template
[
'Placement'
]
==
{
'Constraints'
:
[
'foo=bar'
],
'Preferences'
:
[
'bar=baz'
],
'Platforms'
:
[{
'Architecture'
:
'x86_64'
,
'OS'
:
'linux'
}],
}
assert
task_template
[
'LogDriver'
]
==
{
'Name'
:
'logdriver'
,
'Options'
:
{
'foo'
:
'bar'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment