Kaydet (Commit) 68a271ce authored tarafından Hannes Ljungberg's avatar Hannes Ljungberg
üst d6cc972c
...@@ -83,8 +83,8 @@ class SwarmApiMixin(object): ...@@ -83,8 +83,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',
default_addr_pool=None, subnet_size=None, force_new_cluster=False, swarm_spec=None,
force_new_cluster=False, swarm_spec=None): default_addr_pool=None, subnet_size=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.
...@@ -104,17 +104,17 @@ class SwarmApiMixin(object): ...@@ -104,17 +104,17 @@ class SwarmApiMixin(object):
or an interface followed by a port number, like ``eth0:4567``. or an interface followed by a port number, like ``eth0:4567``.
If the port number is omitted, the default swarm listening port If the port number is omitted, the default swarm listening port
is used. Default: '0.0.0.0:2377' is used. Default: '0.0.0.0:2377'
default_addr_pool (list of strings): Default Address Pool specifies
default subnet pools for global scope networks. Each pool
should be specified as a CIDR block, like '10.0.0.0/16'.
Default: None
subnet_size (int): SubnetSize specifies the subnet size of the
networks created from the default subnet pool. Default: None
force_new_cluster (bool): Force creating a new Swarm, even if force_new_cluster (bool): Force creating a new Swarm, even if
already part of one. Default: False already part of one. Default: False
swarm_spec (dict): Configuration settings of the new Swarm. Use swarm_spec (dict): Configuration settings of the new Swarm. Use
``APIClient.create_swarm_spec`` to generate a valid ``APIClient.create_swarm_spec`` to generate a valid
configuration. Default: None configuration. Default: None
default_addr_pool (list of strings): Default Address Pool specifies
default subnet pools for global scope networks. Each pool
should be specified as a CIDR block, like '10.0.0.0/8'.
Default: None
subnet_size (int): SubnetSize specifies the subnet size of the
networks created from the default subnet pool. Default: None
Returns: Returns:
``True`` if successful. ``True`` if successful.
...@@ -125,7 +125,6 @@ class SwarmApiMixin(object): ...@@ -125,7 +125,6 @@ class SwarmApiMixin(object):
""" """
url = self._url('/swarm/init') url = self._url('/swarm/init')
if swarm_spec is not None and not isinstance(swarm_spec, dict): if swarm_spec is not None and not isinstance(swarm_spec, dict):
raise TypeError('swarm_spec must be a dictionary') raise TypeError('swarm_spec must be a dictionary')
......
...@@ -34,8 +34,8 @@ class Swarm(Model): ...@@ -34,8 +34,8 @@ class Swarm(Model):
get_unlock_key.__doc__ = APIClient.get_unlock_key.__doc__ get_unlock_key.__doc__ = APIClient.get_unlock_key.__doc__
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',
default_addr_pool=None, subnet_size=None, force_new_cluster=False, default_addr_pool=None,
force_new_cluster=False, **kwargs): subnet_size=None, **kwargs):
""" """
Initialize a new swarm on this Engine. Initialize a new swarm on this Engine.
...@@ -55,14 +55,14 @@ class Swarm(Model): ...@@ -55,14 +55,14 @@ class Swarm(Model):
or an interface followed by a port number, like ``eth0:4567``. or an interface followed by a port number, like ``eth0:4567``.
If the port number is omitted, the default swarm listening port If the port number is omitted, the default swarm listening port
is used. Default: ``0.0.0.0:2377`` is used. Default: ``0.0.0.0:2377``
force_new_cluster (bool): Force creating a new Swarm, even if
already part of one. Default: False
default_addr_pool (list of str): Default Address Pool specifies default_addr_pool (list of str): Default Address Pool specifies
default subnet pools for global scope networks. Each pool default subnet pools for global scope networks. Each pool
should be specified as a CIDR block, like '10.0.0.0/16'. should be specified as a CIDR block, like '10.0.0.0/8'.
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
force_new_cluster (bool): Force creating a new Swarm, even if
already part of one. Default: False
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.
...@@ -106,8 +106,8 @@ class Swarm(Model): ...@@ -106,8 +106,8 @@ class Swarm(Model):
>>> client.swarm.init( >>> client.swarm.init(
advertise_addr='eth0', listen_addr='0.0.0.0:5000', advertise_addr='eth0', listen_addr='0.0.0.0:5000',
default_addr_pool=['10.20.0.0/16], subnet_size=24, force_new_cluster=False, default_addr_pool=['10.20.0.0/16],
force_new_cluster=False, snapshot_interval=5000, subnet_size=24, snapshot_interval=5000,
log_entries_for_slow_followers=1200 log_entries_for_slow_followers=1200
) )
...@@ -115,9 +115,9 @@ class Swarm(Model): ...@@ -115,9 +115,9 @@ class Swarm(Model):
init_kwargs = { init_kwargs = {
'advertise_addr': advertise_addr, 'advertise_addr': advertise_addr,
'listen_addr': listen_addr, 'listen_addr': listen_addr,
'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
'force_new_cluster': force_new_cluster
} }
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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment