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
39f6a89b
Kaydet (Commit)
39f6a89b
authored
Şub 04, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add plugin API implementation to DockerClient
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
9296971e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
182 additions
and
0 deletions
+182
-0
client.py
docker/client.py
+9
-0
plugins.py
docker/models/plugins.py
+173
-0
No files found.
docker/client.py
Dosyayı görüntüle @
39f6a89b
...
@@ -3,6 +3,7 @@ from .models.containers import ContainerCollection
...
@@ -3,6 +3,7 @@ from .models.containers import ContainerCollection
from
.models.images
import
ImageCollection
from
.models.images
import
ImageCollection
from
.models.networks
import
NetworkCollection
from
.models.networks
import
NetworkCollection
from
.models.nodes
import
NodeCollection
from
.models.nodes
import
NodeCollection
from
.models.plugins
import
PluginCollection
from
.models.services
import
ServiceCollection
from
.models.services
import
ServiceCollection
from
.models.swarm
import
Swarm
from
.models.swarm
import
Swarm
from
.models.volumes
import
VolumeCollection
from
.models.volumes
import
VolumeCollection
...
@@ -109,6 +110,14 @@ class DockerClient(object):
...
@@ -109,6 +110,14 @@ class DockerClient(object):
"""
"""
return
NodeCollection
(
client
=
self
)
return
NodeCollection
(
client
=
self
)
@property
def
plugins
(
self
):
"""
An object for managing plugins on the server. See the
:doc:`plugins documentation <plugins>` for full details.
"""
return
PluginCollection
(
client
=
self
)
@property
@property
def
services
(
self
):
def
services
(
self
):
"""
"""
...
...
docker/models/plugins.py
0 → 100644
Dosyayı görüntüle @
39f6a89b
from
.resource
import
Collection
,
Model
class
Plugin
(
Model
):
"""
A plugin on the server.
"""
def
__repr__
(
self
):
return
"<
%
s: '
%
s'>"
%
(
self
.
__class__
.
__name__
,
self
.
name
)
@property
def
name
(
self
):
"""
The plugin's name.
"""
return
self
.
attrs
.
get
(
'Name'
)
@property
def
enabled
(
self
):
"""
Whether the plugin is enabled.
"""
return
self
.
attrs
.
get
(
'Enabled'
)
@property
def
settings
(
self
):
"""
A dictionary representing the plugin's configuration.
"""
return
self
.
attrs
.
get
(
'Settings'
)
def
configure
(
self
,
options
):
"""
Update the plugin's settings.
Args:
options (dict): A key-value mapping of options.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
self
.
client
.
api
.
configure_plugin
(
self
.
name
,
options
)
self
.
reload
()
def
disable
(
self
):
"""
Disable the plugin.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
self
.
client
.
api
.
disable_plugin
(
self
.
name
)
self
.
reload
()
def
enable
(
self
,
timeout
=
0
):
"""
Enable the plugin.
Args:
timeout (int): Timeout in seconds. Default: 0
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
self
.
client
.
api
.
enable_plugin
(
self
.
name
,
timeout
)
self
.
reload
()
def
push
(
self
):
"""
Push the plugin to a remote registry.
Returns:
A dict iterator streaming the status of the upload.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
return
self
.
client
.
api
.
push_plugin
(
self
.
name
)
def
remove
(
self
,
force
=
False
):
"""
Remove the plugin from the server.
Args:
force (bool): Remove even if the plugin is enabled.
Default: False
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
return
self
.
client
.
api
.
remove_plugin
(
self
.
name
,
force
=
force
)
class
PluginCollection
(
Collection
):
model
=
Plugin
def
create
(
self
,
name
,
rootfs
,
manifest
):
"""
Create a new plugin.
Args:
name (string): The name of the plugin. The ``:latest`` tag is
optional, and is the default if omitted.
rootfs (string): Path to the plugin's ``rootfs``
manifest (string): Path to the plugin's manifest file
Returns:
(:py:class:`Plugin`): The newly created plugin.
"""
self
.
client
.
api
.
create_plugin
(
name
,
rootfs
,
manifest
)
return
self
.
get
(
name
)
def
get
(
self
,
name
):
"""
Gets a plugin.
Args:
name (str): The name of the plugin.
Returns:
(:py:class:`Plugin`): The plugin.
Raises:
:py:class:`docker.errors.NotFound` If the plugin does not
exist.
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
return
self
.
prepare_model
(
self
.
client
.
api
.
inspect_plugin
(
name
))
def
install
(
self
,
remote_name
,
local_name
=
None
):
"""
Pull and install a plugin.
Args:
remote_name (string): Remote reference for the plugin to
install. The ``:latest`` tag is optional, and is the
default if omitted.
local_name (string): Local name for the pulled plugin.
The ``:latest`` tag is optional, and is the default if
omitted. Optional.
Returns:
(:py:class:`Plugin`): The installed plugin
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
privileges
=
self
.
client
.
api
.
plugin_privileges
(
remote_name
)
it
=
self
.
client
.
api
.
pull_plugin
(
remote_name
,
privileges
,
local_name
)
for
data
in
it
:
pass
return
self
.
get
(
local_name
or
remote_name
)
def
list
(
self
):
"""
List plugins installed on the server.
Returns:
(list of :py:class:`Plugin`): The plugins.
Raises:
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
resp
=
self
.
client
.
api
.
plugins
()
return
[
self
.
prepare_model
(
r
)
for
r
in
resp
]
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