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
21d80b16
Kaydet (Commit)
21d80b16
authored
Nis 24, 2015
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added log_config support in host config
üst
8316fa4e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
7 deletions
+72
-7
__init__.py
docker/utils/__init__.py
+2
-2
types.py
docker/utils/types.py
+51
-0
utils.py
docker/utils/utils.py
+14
-3
hostconfig.md
docs/hostconfig.md
+5
-2
No files found.
docker/utils/__init__.py
Dosyayı görüntüle @
21d80b16
...
...
@@ -5,4 +5,4 @@ from .utils import (
create_container_config
,
parse_bytes
,
ping_registry
)
# flake8: noqa
from
.types
import
Ulimit
# flake8: noqa
\ No newline at end of file
from
.types
import
Ulimit
,
LogConfig
# flake8: noqa
\ No newline at end of file
docker/utils/types.py
Dosyayı görüntüle @
21d80b16
import
six
class
LogConfigTypesEnum
(
object
):
_values
=
(
'json-file'
,
'syslog'
,
'none'
)
JSON
,
SYSLOG
,
NONE
=
_values
class
DictType
(
dict
):
def
__init__
(
self
,
init
):
for
k
,
v
in
six
.
iteritems
(
init
):
self
[
k
]
=
v
class
LogConfig
(
DictType
):
types
=
LogConfigTypesEnum
def
__init__
(
self
,
**
kwargs
):
type_
=
kwargs
.
get
(
'type'
,
kwargs
.
get
(
'Type'
))
config
=
kwargs
.
get
(
'config'
,
kwargs
.
get
(
'Config'
))
if
type_
not
in
self
.
types
.
_values
:
raise
ValueError
(
"LogConfig.type must be one of ({0})"
.
format
(
', '
.
join
(
self
.
types
.
_values
)
))
if
config
and
not
isinstance
(
config
,
dict
):
raise
ValueError
(
"LogConfig.config must be a dictionary"
)
super
(
LogConfig
,
self
)
.
__init__
({
'Type'
:
type_
,
'Config'
:
config
or
{}
})
@property
def
type
(
self
):
return
self
[
'Type'
]
@type.setter
def
type
(
self
,
value
):
if
value
not
in
self
.
types
.
_values
:
raise
ValueError
(
"LogConfig.type must be one of {0}"
.
format
(
', '
.
join
(
self
.
types
.
_values
)
))
self
[
'Type'
]
=
value
@property
def
config
(
self
):
return
self
[
'Config'
]
def
set_config_value
(
self
,
key
,
value
):
self
.
config
[
key
]
=
value
def
unset_config
(
self
,
key
):
if
key
in
self
.
config
:
del
self
.
config
[
key
]
class
Ulimit
(
DictType
):
def
__init__
(
self
,
**
kwargs
):
name
=
kwargs
.
get
(
'name'
,
kwargs
.
get
(
'Name'
))
...
...
docker/utils/utils.py
Dosyayı görüntüle @
21d80b16
...
...
@@ -28,7 +28,7 @@ import six
from
..
import
errors
from
..
import
tls
from
.types
import
Ulimit
from
.types
import
Ulimit
,
LogConfig
DEFAULT_HTTP_HOST
=
"127.0.0.1"
...
...
@@ -359,7 +359,7 @@ def create_host_config(
dns
=
None
,
dns_search
=
None
,
volumes_from
=
None
,
network_mode
=
None
,
restart_policy
=
None
,
cap_add
=
None
,
cap_drop
=
None
,
devices
=
None
,
extra_hosts
=
None
,
read_only
=
None
,
pid_mode
=
None
,
ipc_mode
=
None
,
security_opt
=
None
,
ulimits
=
None
security_opt
=
None
,
ulimits
=
None
,
log_config
=
None
):
host_config
=
{}
...
...
@@ -456,13 +456,24 @@ def create_host_config(
if
not
isinstance
(
ulimits
,
list
):
raise
errors
.
DockerException
(
'Invalid type for ulimits param: expected list but found'
' {0}'
.
format
(
type
(
ulimits
)))
' {0}'
.
format
(
type
(
ulimits
))
)
host_config
[
'Ulimits'
]
=
[]
for
l
in
ulimits
:
if
not
isinstance
(
l
,
Ulimit
):
l
=
Ulimit
(
**
l
)
host_config
[
'Ulimits'
]
.
append
(
l
)
if
log_config
is
not
None
:
if
not
isinstance
(
log_config
,
LogConfig
):
if
not
isinstance
(
log_config
,
dict
):
raise
errors
.
DockerException
(
'Invalid type for log_config param: expected LogConfig but'
' found {0}'
.
format
(
type
(
log_config
))
)
log_config
=
LogConfig
(
**
log_config
)
host_config
[
'LogConfig'
]
=
log_config
return
host_config
...
...
docs/hostconfig.md
Dosyayı görüntüle @
21d80b16
...
...
@@ -85,8 +85,11 @@ for example:
*
read_only (bool): mount the container's root filesystem as read only
*
pid_mode (str): if set to "host", use the host PID namespace inside the
container
*
security_opt (list): A list of string values to customize labels for MLS systems, such as SELinux.
*
ulimits (list): A list of dicts or
`docker.utils.Ulimit`
objects.
*
security_opt (list): A list of string values to customize labels for MLS
systems, such as SELinux.
*
ulimits (list): A list of dicts or
`docker.utils.Ulimit`
objects. A list
of ulimits to be set in the container.
*
log_config (
`docker.utils.LogConfig`
or dict): Logging configuration to container
**Returns**
(dict) HostConfig dictionary
...
...
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