mirror of https://github.com/docker/docker-py.git
swarm: add support for DataPathPort on init (#2987)
Adds support for setting the UDP port used for VXLAN traffic between swarm nodes Signed-off-by: Chris Hand <dexteradeus@users.noreply.github.com>
This commit is contained in:
parent
45bf9f9115
commit
fc86ab0d85
|
@ -85,7 +85,7 @@ class SwarmApiMixin:
|
||||||
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):
|
data_path_addr=None, data_path_port=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.
|
||||||
|
@ -118,6 +118,9 @@ class SwarmApiMixin:
|
||||||
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
|
data_path_addr (string): Address or interface to use for data path
|
||||||
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
||||||
|
data_path_port (int): Port number to use for data path traffic.
|
||||||
|
Acceptable port range is 1024 to 49151. If set to ``None`` or
|
||||||
|
0, the default port 4789 will be used. Default: None
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
(str): The ID of the created node.
|
(str): The ID of the created node.
|
||||||
|
@ -166,6 +169,14 @@ class SwarmApiMixin:
|
||||||
)
|
)
|
||||||
data['DataPathAddr'] = data_path_addr
|
data['DataPathAddr'] = data_path_addr
|
||||||
|
|
||||||
|
if data_path_port is not None:
|
||||||
|
if utils.version_lt(self._version, '1.40'):
|
||||||
|
raise errors.InvalidVersion(
|
||||||
|
'Data path port is only available for '
|
||||||
|
'API version >= 1.40'
|
||||||
|
)
|
||||||
|
data['DataPathPort'] = data_path_port
|
||||||
|
|
||||||
response = self._post_json(url, data=data)
|
response = self._post_json(url, data=data)
|
||||||
return self._result(response, json=True)
|
return self._result(response, json=True)
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,8 @@ 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, data_path_addr=None, **kwargs):
|
subnet_size=None, data_path_addr=None, data_path_port=None,
|
||||||
|
**kwargs):
|
||||||
"""
|
"""
|
||||||
Initialize a new swarm on this Engine.
|
Initialize a new swarm on this Engine.
|
||||||
|
|
||||||
|
@ -65,6 +66,9 @@ class Swarm(Model):
|
||||||
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
|
data_path_addr (string): Address or interface to use for data path
|
||||||
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
traffic. For example, 192.168.1.1, or an interface, like eth0.
|
||||||
|
data_path_port (int): Port number to use for data path traffic.
|
||||||
|
Acceptable port range is 1024 to 49151. If set to ``None`` or
|
||||||
|
0, the default port 4789 will be used. Default: None
|
||||||
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.
|
||||||
|
@ -121,6 +125,7 @@ class Swarm(Model):
|
||||||
'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,
|
'data_path_addr': data_path_addr,
|
||||||
|
'data_path_port': data_path_port,
|
||||||
}
|
}
|
||||||
init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)
|
init_kwargs['swarm_spec'] = self.client.api.create_swarm_spec(**kwargs)
|
||||||
node_id = self.client.api.init_swarm(**init_kwargs)
|
node_id = self.client.api.init_swarm(**init_kwargs)
|
||||||
|
|
|
@ -253,3 +253,8 @@ class SwarmTest(BaseAPIIntegrationTest):
|
||||||
@pytest.mark.xfail(reason='Can fail if eth0 has multiple IP addresses')
|
@pytest.mark.xfail(reason='Can fail if eth0 has multiple IP addresses')
|
||||||
def test_init_swarm_data_path_addr(self):
|
def test_init_swarm_data_path_addr(self):
|
||||||
assert self.init_swarm(data_path_addr='eth0')
|
assert self.init_swarm(data_path_addr='eth0')
|
||||||
|
|
||||||
|
@requires_api_version('1.40')
|
||||||
|
def test_init_swarm_data_path_port(self):
|
||||||
|
assert self.init_swarm(data_path_port=4242)
|
||||||
|
assert self.client.inspect_swarm()['DataPathPort'] == 4242
|
||||||
|
|
Loading…
Reference in New Issue