mirror of https://github.com/docker/docker-py.git
Add support for custom name in SwarmSpec
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
fdfe582b76
commit
0f70b6a38b
|
@ -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):
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in New Issue