mirror of https://github.com/docker/docker-py.git
Add swarm support for data_addr_path
Signed-off-by: Hannes Ljungberg <hannes@5monkeys.se>
This commit is contained in:
parent
992e0dcdfb
commit
c7b9cae0a0
|
|
@ -84,7 +84,8 @@ class SwarmApiMixin(object):
|
||||||
@utils.minimum_version('1.24')
|
@utils.minimum_version('1.24')
|
||||||
def init_swarm(self, advertise_addr=None, listen_addr='0.0.0.0:2377',
|
def init_swarm(self, advertise_addr=None, listen_addr='0.0.0.0:2377',
|
||||||
force_new_cluster=False, swarm_spec=None,
|
force_new_cluster=False, swarm_spec=None,
|
||||||
default_addr_pool=None, subnet_size=None):
|
default_addr_pool=None, subnet_size=None,
|
||||||
|
data_path_addr=None):
|
||||||
"""
|
"""
|
||||||
Initialize a new Swarm using the current connected engine as the first
|
Initialize a new Swarm using the current connected engine as the first
|
||||||
node.
|
node.
|
||||||
|
|
@ -115,6 +116,8 @@ class SwarmApiMixin(object):
|
||||||
Default: None
|
Default: None
|
||||||
subnet_size (int): SubnetSize specifies the subnet size of the
|
subnet_size (int): SubnetSize specifies the subnet size of the
|
||||||
networks created from the default subnet pool. Default: None
|
networks created from the default subnet pool. Default: None
|
||||||
|
data_path_addr (string): Address or interface to use for data path
|
||||||
|
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``True`` if successful.
|
``True`` if successful.
|
||||||
|
|
@ -154,6 +157,15 @@ class SwarmApiMixin(object):
|
||||||
'ForceNewCluster': force_new_cluster,
|
'ForceNewCluster': force_new_cluster,
|
||||||
'Spec': swarm_spec,
|
'Spec': swarm_spec,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data_path_addr is not None:
|
||||||
|
if utils.version_lt(self._version, '1.30'):
|
||||||
|
raise errors.InvalidVersion(
|
||||||
|
'Data address path is only available for '
|
||||||
|
'API version >= 1.30'
|
||||||
|
)
|
||||||
|
data['DataPathAddr'] = data_path_addr
|
||||||
|
|
||||||
response = self._post_json(url, data=data)
|
response = self._post_json(url, data=data)
|
||||||
self._raise_for_status(response)
|
self._raise_for_status(response)
|
||||||
return True
|
return True
|
||||||
|
|
@ -194,7 +206,7 @@ class SwarmApiMixin(object):
|
||||||
|
|
||||||
@utils.minimum_version('1.24')
|
@utils.minimum_version('1.24')
|
||||||
def join_swarm(self, remote_addrs, join_token, listen_addr='0.0.0.0:2377',
|
def join_swarm(self, remote_addrs, join_token, listen_addr='0.0.0.0:2377',
|
||||||
advertise_addr=None):
|
advertise_addr=None, data_path_addr=None):
|
||||||
"""
|
"""
|
||||||
Make this Engine join a swarm that has already been created.
|
Make this Engine join a swarm that has already been created.
|
||||||
|
|
||||||
|
|
@ -213,6 +225,8 @@ class SwarmApiMixin(object):
|
||||||
the port number from the listen address is used. If
|
the port number from the listen address is used. If
|
||||||
AdvertiseAddr is not specified, it will be automatically
|
AdvertiseAddr is not specified, it will be automatically
|
||||||
detected when possible. Default: ``None``
|
detected when possible. Default: ``None``
|
||||||
|
data_path_addr (string): Address or interface to use for data path
|
||||||
|
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
``True`` if the request went through.
|
``True`` if the request went through.
|
||||||
|
|
@ -222,11 +236,20 @@ class SwarmApiMixin(object):
|
||||||
If the server returns an error.
|
If the server returns an error.
|
||||||
"""
|
"""
|
||||||
data = {
|
data = {
|
||||||
"RemoteAddrs": remote_addrs,
|
'RemoteAddrs': remote_addrs,
|
||||||
"ListenAddr": listen_addr,
|
'ListenAddr': listen_addr,
|
||||||
"JoinToken": join_token,
|
'JoinToken': join_token,
|
||||||
"AdvertiseAddr": advertise_addr,
|
'AdvertiseAddr': advertise_addr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data_path_addr is not None:
|
||||||
|
if utils.version_lt(self._version, '1.30'):
|
||||||
|
raise errors.InvalidVersion(
|
||||||
|
'Data address path is only available for '
|
||||||
|
'API version >= 1.30'
|
||||||
|
)
|
||||||
|
data['DataPathAddr'] = data_path_addr
|
||||||
|
|
||||||
url = self._url('/swarm/join')
|
url = self._url('/swarm/join')
|
||||||
response = self._post_json(url, data=data)
|
response = self._post_json(url, data=data)
|
||||||
self._raise_for_status(response)
|
self._raise_for_status(response)
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ class Swarm(Model):
|
||||||
|
|
||||||
def init(self, advertise_addr=None, listen_addr='0.0.0.0:2377',
|
def init(self, advertise_addr=None, listen_addr='0.0.0.0:2377',
|
||||||
force_new_cluster=False, default_addr_pool=None,
|
force_new_cluster=False, default_addr_pool=None,
|
||||||
subnet_size=None, **kwargs):
|
subnet_size=None, data_path_addr=None, **kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize a new swarm on this Engine.
|
Initialize a new swarm on this Engine.
|
||||||
|
|
||||||
|
|
@ -63,6 +63,8 @@ class Swarm(Model):
|
||||||
Default: None
|
Default: None
|
||||||
subnet_size (int): SubnetSize specifies the subnet size of the
|
subnet_size (int): SubnetSize specifies the subnet size of the
|
||||||
networks created from the default subnet pool. Default: None
|
networks created from the default subnet pool. Default: None
|
||||||
|
data_path_addr (string): Address or interface to use for data path
|
||||||
|
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
||||||
task_history_retention_limit (int): Maximum number of tasks
|
task_history_retention_limit (int): Maximum number of tasks
|
||||||
history stored.
|
history stored.
|
||||||
snapshot_interval (int): Number of logs entries between snapshot.
|
snapshot_interval (int): Number of logs entries between snapshot.
|
||||||
|
|
@ -117,7 +119,8 @@ class Swarm(Model):
|
||||||
'listen_addr': listen_addr,
|
'listen_addr': listen_addr,
|
||||||
'force_new_cluster': force_new_cluster,
|
'force_new_cluster': force_new_cluster,
|
||||||
'default_addr_pool': default_addr_pool,
|
'default_addr_pool': default_addr_pool,
|
||||||
'subnet_size': subnet_size
|
'subnet_size': subnet_size,
|
||||||
|
'data_path_addr': data_path_addr,
|
||||||
}
|
}
|
||||||
init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)
|
init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)
|
||||||
self.client.api.init_swarm(**init_kwargs)
|
self.client.api.init_swarm(**init_kwargs)
|
||||||
|
|
|
||||||
|
|
@ -233,3 +233,7 @@ class SwarmTest(BaseAPIIntegrationTest):
|
||||||
self.client.remove_node(node_id, True)
|
self.client.remove_node(node_id, True)
|
||||||
|
|
||||||
assert e.value.response.status_code >= 400
|
assert e.value.response.status_code >= 400
|
||||||
|
|
||||||
|
@requires_api_version('1.30')
|
||||||
|
def test_init_swarm_data_path_addr(self):
|
||||||
|
assert self.init_swarm(data_path_addr='eth0')
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue