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
672a9ee6
Kaydet (Commit)
672a9ee6
authored
Şub 08, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add service_logs command to APIClient and logs command to models.Service
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
80046f1f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
0 deletions
+77
-0
service.py
docker/api/service.py
+49
-0
services.py
docker/models/services.py
+28
-0
No files found.
docker/api/service.py
Dosyayı görüntüle @
672a9ee6
...
...
@@ -166,6 +166,55 @@ class ServiceApiMixin(object):
url
=
self
.
_url
(
'/services'
)
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.minimum_version
(
'1.25'
)
def
service_logs
(
self
,
service
,
details
=
False
,
follow
=
False
,
stdout
=
False
,
stderr
=
False
,
since
=
0
,
timestamps
=
False
,
tail
=
'all'
,
is_tty
=
None
):
"""
Get log stream for a service.
Note: This endpoint works only for services with the ``json-file``
or ``journald`` logging drivers.
Args:
service (str): ID or name of the container
details (bool): Show extra details provided to logs.
Default: ``False``
follow (bool): Keep connection open to read logs as they are
sent by the Engine. Default: ``False``
stdout (bool): Return logs from ``stdout``. Default: ``False``
stderr (bool): Return logs from ``stderr``. Default: ``False``
since (int): UNIX timestamp for the logs staring point.
Default: 0
timestamps (bool): Add timestamps to every log line.
tail (string or int): Number of log lines to be returned,
counting from the current end of the logs. Specify an
integer or ``'all'`` to output all log lines.
Default: ``all``
is_tty (bool): Whether the service's :py:class:`ContainerSpec`
enables the TTY option. If omitted, the method will query
the Engine for the information, causing an additional
roundtrip.
Returns (generator): Logs for the service.
"""
params
=
{
'details'
:
details
,
'follow'
:
follow
,
'stdout'
:
stdout
,
'stderr'
:
stderr
,
'since'
:
since
,
'timestamps'
:
timestamps
,
'tail'
:
tail
}
url
=
self
.
_url
(
'/services/{0}/logs'
,
service
)
res
=
self
.
_get
(
url
,
params
=
params
,
stream
=
True
)
if
is_tty
is
None
:
is_tty
=
self
.
inspect_service
(
service
)[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
]
.
get
(
'TTY'
,
False
)
return
self
.
_get_result_tty
(
True
,
res
,
is_tty
)
@utils.minimum_version
(
'1.24'
)
def
tasks
(
self
,
filters
=
None
):
"""
...
...
docker/models/services.py
Dosyayı görüntüle @
672a9ee6
...
...
@@ -77,6 +77,34 @@ class Service(Model):
**
create_kwargs
)
def
logs
(
self
,
**
kwargs
):
"""
Get log stream for the service.
Note: This method works only for services with the ``json-file``
or ``journald`` logging drivers.
Args:
details (bool): Show extra details provided to logs.
Default: ``False``
follow (bool): Keep connection open to read logs as they are
sent by the Engine. Default: ``False``
stdout (bool): Return logs from ``stdout``. Default: ``False``
stderr (bool): Return logs from ``stderr``. Default: ``False``
since (int): UNIX timestamp for the logs staring point.
Default: 0
timestamps (bool): Add timestamps to every log line.
tail (string or int): Number of log lines to be returned,
counting from the current end of the logs. Specify an
integer or ``'all'`` to output all log lines.
Default: ``all``
Returns (generator): Logs for the service.
"""
is_tty
=
self
.
attrs
[
'Spec'
][
'TaskTemplate'
][
'ContainerSpec'
]
.
get
(
'TTY'
,
False
)
return
self
.
client
.
api
.
service_logs
(
self
.
id
,
is_tty
=
is_tty
,
**
kwargs
)
class
ServiceCollection
(
Collection
):
"""Services on the Docker server."""
...
...
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