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
c239e405
Kaydet (Commit)
c239e405
authored
Ara 05, 2016
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Implement swarm node removal
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
d56b2d3d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
0 deletions
+64
-0
swarm.py
docker/api/swarm.py
+28
-0
nodes.py
docker/models/nodes.py
+19
-0
api_swarm_test.py
tests/integration/api_swarm_test.py
+17
-0
No files found.
docker/api/swarm.py
Dosyayı görüntüle @
c239e405
...
...
@@ -224,6 +224,33 @@ class SwarmApiMixin(object):
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.check_resource
@utils.minimum_version
(
'1.24'
)
def
remove_node
(
self
,
node_id
,
force
=
False
):
"""
Remove a node from the swarm.
Args:
node_id (string): ID of the node to be removed.
force (bool): Force remove an active node. Default: `False`
Raises:
:py:class:`docker.errors.NotFound`
If the node referenced doesn't exist in the swarm.
:py:class:`docker.errors.APIError`
If the server returns an error.
Returns:
`True` if the request was successful.
"""
url
=
self
.
_url
(
'/nodes/{0}'
,
node_id
)
params
=
{
'force'
:
force
}
res
=
self
.
_delete
(
url
,
params
=
params
)
self
.
_raise_for_status
(
res
)
return
True
@utils.minimum_version
(
'1.24'
)
def
update_node
(
self
,
node_id
,
version
,
node_spec
=
None
):
"""
...
...
@@ -231,6 +258,7 @@ class SwarmApiMixin(object):
Args:
node_id (string): ID of the node to be updated.
version (int): The version number of the node object being
updated. This is required to avoid conflicting writes.
node_spec (dict): Configuration settings to update. Any values
...
...
docker/models/nodes.py
Dosyayı görüntüle @
c239e405
...
...
@@ -41,6 +41,25 @@ class Node(Model):
"""
return
self
.
client
.
api
.
update_node
(
self
.
id
,
self
.
version
,
node_spec
)
def
remove
(
self
,
force
=
False
):
"""
Remove this node from the swarm.
Args:
force (bool): Force remove an active node. Default: `False`
Returns:
`True` if the request was successful.
Raises:
:py:class:`docker.errors.NotFound`
If the node doesn't exist in the swarm.
:py:class:`docker.errors.APIError`
If the server returns an error.
"""
return
self
.
client
.
api
.
remove_node
(
self
.
id
,
force
=
force
)
class
NodeCollection
(
Collection
):
"""Nodes on the Docker server."""
...
...
tests/integration/api_swarm_test.py
Dosyayı görüntüle @
c239e405
...
...
@@ -159,3 +159,20 @@ class SwarmTest(BaseAPIIntegrationTest):
node_spec
=
orig_spec
)
reverted_node
=
self
.
client
.
inspect_node
(
node
[
'ID'
])
assert
orig_spec
==
reverted_node
[
'Spec'
]
@requires_api_version
(
'1.24'
)
def
test_remove_main_node
(
self
):
assert
self
.
client
.
init_swarm
(
'eth0'
)
nodes_list
=
self
.
client
.
nodes
()
node_id
=
nodes_list
[
0
][
'ID'
]
with
pytest
.
raises
(
docker
.
errors
.
NotFound
):
self
.
client
.
remove_node
(
'foobar01'
)
with
pytest
.
raises
(
docker
.
errors
.
APIError
)
as
e
:
self
.
client
.
remove_node
(
node_id
)
assert
e
.
value
.
response
.
status_code
==
500
with
pytest
.
raises
(
docker
.
errors
.
APIError
)
as
e
:
self
.
client
.
remove_node
(
node_id
,
True
)
assert
e
.
value
.
response
.
status_code
==
500
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