summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2016-08-04 16:48:21 -0700
committerJoffrey F <joffrey@docker.com>2016-08-04 16:48:21 -0700
commit0f70b6a38b80133e6df29c9cb007bc2c709db8ec (patch)
treed58d4a49aa284dbf6a3314b167dd0b10b9040a78
parentfdfe582b764ab5a194f147b9d8efa04e7ae43f1c (diff)
downloaddocker-py-0f70b6a38b80133e6df29c9cb007bc2c709db8ec.tar.gz
Add support for custom name in SwarmSpec
Signed-off-by: Joffrey F <joffrey@docker.com>
-rw-r--r--docker/utils/types.py5
-rw-r--r--docs/swarm.md4
-rw-r--r--tests/integration/swarm_test.py18
3 files changed, 26 insertions, 1 deletions
diff --git a/docker/utils/types.py b/docker/utils/types.py
index 92faaa8..d778b90 100644
--- a/docker/utils/types.py
+++ b/docker/utils/types.py
@@ -101,7 +101,7 @@ class SwarmSpec(DictType):
snapshot_interval=None, keep_old_snapshots=None,
log_entries_for_slow_followers=None, heartbeat_tick=None,
election_tick=None, dispatcher_heartbeat_period=None,
- node_cert_expiry=None, external_ca=None):
+ node_cert_expiry=None, external_ca=None, name=None):
if task_history_retention_limit is not None:
self['Orchestration'] = {
'TaskHistoryRetentionLimit': task_history_retention_limit
@@ -127,6 +127,9 @@ class SwarmSpec(DictType):
'ExternalCA': external_ca
}
+ if name is not None:
+ self['Name'] = name
+
class SwarmExternalCA(DictType):
def __init__(self, url, protocol=None, options=None):
diff --git a/docs/swarm.md b/docs/swarm.md
index 2c87702..a9a1d1f 100644
--- a/docs/swarm.md
+++ b/docs/swarm.md
@@ -106,6 +106,7 @@ argument in `Client.init_swarm`.
* node_cert_expiry (int): Automatic expiry for nodes certificates.
* external_ca (dict): Configuration for forwarding signing requests to an
external certificate authority. Use `docker.utils.SwarmExternalCA`.
+* name (string): Swarm's name
**Returns:** `docker.utils.SwarmSpec` instance.
@@ -194,3 +195,6 @@ Update the Swarm's configuration
Default: `None`.
* rotate_worker_token (bool): Rotate the worker join token. Default: `False`.
* rotate_manager_token (bool): Rotate the manager join token. Default: `False`.
+
+**Returns:** `True` if the request went through. Raises an `APIError` if it
+ fails.
diff --git a/tests/integration/swarm_test.py b/tests/integration/swarm_test.py
index 226689b..b73f81c 100644
--- a/tests/integration/swarm_test.py
+++ b/tests/integration/swarm_test.py
@@ -96,3 +96,21 @@ class SwarmTest(helpers.BaseTestCase):
swarm_info_1['JoinTokens']['Worker'] !=
swarm_info_2['JoinTokens']['Worker']
)
+
+ @requires_api_version('1.24')
+ def test_update_swarm_name(self):
+ assert self.client.init_swarm('eth0')
+ swarm_info_1 = self.client.inspect_swarm()
+ spec = self.client.create_swarm_spec(
+ node_cert_expiry=7776000000000000, name='reimuhakurei'
+ )
+ assert self.client.update_swarm(
+ version=swarm_info_1['Version']['Index'], swarm_spec=spec
+ )
+ swarm_info_2 = self.client.inspect_swarm()
+
+ assert (
+ swarm_info_1['Version']['Index'] !=
+ swarm_info_2['Version']['Index']
+ )
+ assert swarm_info_2['Spec']['Name'] == 'reimuhakurei'