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
aa3c4f02
Kaydet (Commit)
aa3c4f02
authored
Kas 07, 2017
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add unlock_swarm and get_unlock_key to APIClient
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
f238fe55
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
1 deletion
+59
-1
swarm.py
docker/api/swarm.py
+49
-1
api_swarm_test.py
tests/integration/api_swarm_test.py
+10
-0
No files found.
docker/api/swarm.py
Dosyayı görüntüle @
aa3c4f02
import
logging
from
six.moves
import
http_client
from
..
import
errors
from
..
import
types
from
..
import
utils
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -68,6 +70,16 @@ class SwarmApiMixin(object):
kwargs
[
'external_cas'
]
=
[
ext_ca
]
return
types
.
SwarmSpec
(
self
.
_version
,
*
args
,
**
kwargs
)
@utils.minimum_version
(
'1.24'
)
def
get_unlock_key
(
self
):
"""
Get the unlock key for this Swarm manager.
Returns:
A ``dict`` containing an ``UnlockKey`` member
"""
return
self
.
_result
(
self
.
_get
(
self
.
_url
(
'/swarm/unlockkey'
)),
True
)
@utils.minimum_version
(
'1.24'
)
def
init_swarm
(
self
,
advertise_addr
=
None
,
listen_addr
=
'0.0.0.0:2377'
,
force_new_cluster
=
False
,
swarm_spec
=
None
):
...
...
@@ -270,10 +282,46 @@ class SwarmApiMixin(object):
self
.
_raise_for_status
(
res
)
return
True
@utils.minimum_version
(
'1.24'
)
def
unlock_swarm
(
self
,
key
):
"""
Unlock a locked swarm.
Args:
key (string): The unlock key as provided by
:py:meth:`get_unlock_key`
Raises:
:py:class:`docker.errors.InvalidArgument`
If the key argument is in an incompatible format
:py:class:`docker.errors.APIError`
If the server returns an error.
Returns:
`True` if the request was successful.
Example:
>>> key = client.get_unlock_key()
>>> client.unlock_node(key)
"""
if
isinstance
(
key
,
dict
):
if
'UnlockKey'
not
in
key
:
raise
errors
.
InvalidArgument
(
'Invalid unlock key format'
)
else
:
key
=
{
'UnlockKey'
:
key
}
url
=
self
.
_url
(
'/swarm/unlock'
)
res
=
self
.
_post_json
(
url
,
data
=
key
)
self
.
_raise_for_status
(
res
)
return
True
@utils.minimum_version
(
'1.24'
)
def
update_node
(
self
,
node_id
,
version
,
node_spec
=
None
):
"""
Update the
N
ode's configuration
Update the
n
ode's configuration
Args:
...
...
tests/integration/api_swarm_test.py
Dosyayı görüntüle @
aa3c4f02
...
...
@@ -13,6 +13,13 @@ class SwarmTest(BaseAPIIntegrationTest):
def
tearDown
(
self
):
super
(
SwarmTest
,
self
)
.
tearDown
()
try
:
unlock_key
=
self
.
client
.
get_unlock_key
()
if
unlock_key
.
get
(
'UnlockKey'
):
self
.
unlock_swarm
(
unlock_key
)
except
docker
.
errors
.
APIError
:
pass
force_leave_swarm
(
self
.
client
)
@requires_api_version
(
'1.24'
)
...
...
@@ -70,6 +77,9 @@ class SwarmTest(BaseAPIIntegrationTest):
swarm_info
[
'Spec'
][
'EncryptionConfig'
][
'AutoLockManagers'
]
is
True
)
unlock_key
=
self
.
get_unlock_key
()
assert
unlock_key
.
get
(
'UnlockKey'
)
@requires_api_version
(
'1.25'
)
@pytest.mark.xfail
(
reason
=
"This doesn't seem to be taken into account by the engine"
...
...
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