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
a75553b3
Kaydet (Commit)
a75553b3
authored
Agu 12, 2016
tarafından
Joffrey F
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add `nodes` and `inspect_node` methods
Signed-off-by:
Joffrey F
<
joffrey@docker.com
>
üst
e1774c4c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
1 deletion
+104
-1
swarm.py
docker/api/swarm.py
+15
-0
api.md
docs/api.md
+9
-0
swarm.md
docs/swarm.md
+51
-1
swarm_test.py
tests/integration/swarm_test.py
+29
-0
No files found.
docker/api/swarm.py
Dosyayı görüntüle @
a75553b3
...
...
@@ -29,6 +29,12 @@ class SwarmApiMixin(object):
url
=
self
.
_url
(
'/swarm'
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.check_resource
@utils.minimum_version
(
'1.24'
)
def
inspect_node
(
self
,
node_id
):
url
=
self
.
_url
(
'/nodes/{0}'
,
node_id
)
return
self
.
_result
(
self
.
_get
(
url
),
True
)
@utils.minimum_version
(
'1.24'
)
def
join_swarm
(
self
,
remote_addrs
,
join_token
,
listen_addr
=
None
,
advertise_addr
=
None
):
...
...
@@ -50,6 +56,15 @@ class SwarmApiMixin(object):
self
.
_raise_for_status
(
response
)
return
True
@utils.minimum_version
(
'1.24'
)
def
nodes
(
self
,
filters
=
None
):
url
=
self
.
_url
(
'/nodes'
)
params
=
{}
if
filters
:
params
[
'filters'
]
=
utils
.
convert_filters
(
filters
)
return
self
.
_result
(
self
.
_get
(
url
,
params
=
params
),
True
)
@utils.minimum_version
(
'1.24'
)
def
update_swarm
(
self
,
version
,
swarm_spec
=
None
,
rotate_worker_token
=
False
,
rotate_manager_token
=
False
):
...
...
docs/api.md
Dosyayı görüntüle @
a75553b3
...
...
@@ -646,6 +646,11 @@ Retrieve network info by id.
**Returns**
(dict): Network information dictionary
## inspect_node
Retrieve low-level information about a Swarm node.
See the
[
Swarm documentation
](
swarm.md#clientinspect_node
)
.
## inspect_swarm
Retrieve information about the current Swarm.
...
...
@@ -742,6 +747,10 @@ The above are combined to create a filters dict.
**Returns**
(dict): List of network objects.
## nodes
List Swarm nodes. See the
[
Swarm documentation
](
swarm.md#clientnodes
)
.
## pause
Pauses all processes within a container.
...
...
docs/swarm.md
Dosyayı görüntüle @
a75553b3
...
...
@@ -47,7 +47,6 @@ you will need to specify `force=True` to be able to leave.
client
.
leave_swarm
(
force
=
False
)
```
## Retrieving Swarm status
You can retrieve information about your current Swarm status by calling
...
...
@@ -57,6 +56,15 @@ You can retrieve information about your current Swarm status by calling
client
.
inspect_swarm
()
```
## Listing Swarm nodes
List all nodes that are part of the current Swarm using
`Client.nodes`
.
The
`filters`
argument allows to filter the results.
```
python
client
.
nodes
(
filters
=
{
'role'
:
'manager'
})
```
## Swarm API documentation
### Client.init_swarm
...
...
@@ -123,6 +131,37 @@ Create a configuration dictionary for the `external_ca` argument in a
*
options (dict): An object with key/value pairs that are interpreted as
protocol-specific options for the external CA driver.
### Client.inspect_node
Retrieve low-level information about a Swarm node
**Params:**
*
node_id (string): ID of the node to be inspected.
**Returns:**
A dictionary containing data about this node. See sample below.
```
python
{
u'CreatedAt'
:
u'2016-08-11T23:28:39.695834296Z'
,
u'Description'
:
{
u'Engine'
:
{
u'EngineVersion'
:
u'1.12.0'
,
u'Plugins'
:
[{
u'Name'
:
u'bridge'
,
u'Type'
:
u'Network'
},
{
u'Name'
:
u'host'
,
u'Type'
:
u'Network'
},
{
u'Name'
:
u'null'
,
u'Type'
:
u'Network'
},
{
u'Name'
:
u'overlay'
,
u'Type'
:
u'Network'
},
{
u'Name'
:
u'local'
,
u'Type'
:
u'Volume'
}]},
u'Hostname'
:
u'dockerserv-1.local.net'
,
u'Platform'
:
{
u'Architecture'
:
u'x86_64'
,
u'OS'
:
u'linux'
},
u'Resources'
:
{
u'MemoryBytes'
:
8052109312
,
u'NanoCPUs'
:
4000000000
}},
u'ID'
:
u'1kqami616p23dz4hd7km35w63'
,
u'ManagerStatus'
:
{
u'Addr'
:
u'10.0.131.127:2377'
,
u'Leader'
:
True
,
u'Reachability'
:
u'reachable'
},
u'Spec'
:
{
u'Availability'
:
u'active'
,
u'Role'
:
u'manager'
},
u'Status'
:
{
u'State'
:
u'ready'
},
u'UpdatedAt'
:
u'2016-08-11T23:28:39.979829529Z'
,
u'Version'
:
{
u'Index'
:
9
}}
``
`
### Client.inspect_swarm
Retrieve
information
about
the
current
Swarm
.
...
...
@@ -182,6 +221,17 @@ Leave a Swarm.
**Returns:**
`True`
if the request went through. Raises an
`APIError`
if it
fails.
### Client.nodes
List Swarm nodes
**Params:**
*
filters (dict): Filters to process on the nodes list. Valid filters:
`id`
,
`name`
,
`membership`
and
`role`
. Default:
`None`
**Returns:**
A list of dictionaries containing data about each swarm node.
### Client.update_swarm
Update the Swarm's configuration
...
...
tests/integration/swarm_test.py
Dosyayı görüntüle @
a75553b3
...
...
@@ -114,3 +114,32 @@ class SwarmTest(helpers.BaseTestCase):
swarm_info_2
[
'Version'
][
'Index'
]
)
assert
swarm_info_2
[
'Spec'
][
'Name'
]
==
'reimuhakurei'
@requires_api_version
(
'1.24'
)
def
test_list_nodes
(
self
):
assert
self
.
client
.
init_swarm
(
'eth0'
)
nodes_list
=
self
.
client
.
nodes
()
assert
len
(
nodes_list
)
==
1
node
=
nodes_list
[
0
]
assert
'ID'
in
node
assert
'Spec'
in
node
assert
node
[
'Spec'
][
'Role'
]
==
'manager'
filtered_list
=
self
.
client
.
nodes
(
filters
=
{
'id'
:
node
[
'ID'
]
})
assert
len
(
filtered_list
)
==
1
filtered_list
=
self
.
client
.
nodes
(
filters
=
{
'role'
:
'worker'
})
assert
len
(
filtered_list
)
==
0
@requires_api_version
(
'1.24'
)
def
test_inspect_node
(
self
):
assert
self
.
client
.
init_swarm
(
'eth0'
)
nodes_list
=
self
.
client
.
nodes
()
assert
len
(
nodes_list
)
==
1
node
=
nodes_list
[
0
]
node_data
=
self
.
client
.
inspect_node
(
node
[
'ID'
])
assert
node
[
'ID'
]
==
node_data
[
'ID'
]
assert
node
[
'Version'
]
==
node_data
[
'Version'
]
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