Skip to content

Commit 5dc7425

Browse files
dnephinshin-
authored andcommitted
Add attachable.
Signed-off-by: Daniel Nephin <[email protected]>
1 parent 4669b24 commit 5dc7425

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

docker/api/network.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def networks(self, names=None, ids=None):
3838
@minimum_version('1.21')
3939
def create_network(self, name, driver=None, options=None, ipam=None,
4040
check_duplicate=None, internal=False, labels=None,
41-
enable_ipv6=False):
41+
enable_ipv6=False, attachable=None):
4242
"""
4343
Create a network. Similar to the ``docker network create``.
4444
@@ -54,6 +54,9 @@ def create_network(self, name, driver=None, options=None, ipam=None,
5454
labels (dict): Map of labels to set on the network. Default
5555
``None``.
5656
enable_ipv6 (bool): Enable IPv6 on the network. Default ``False``.
57+
attachable (bool): If enabled, and the network is in the global
58+
scope, non-service containers on worker nodes will be able to
59+
connect to the network.
5760
5861
Returns:
5962
(dict): The created network reference object
@@ -91,7 +94,7 @@ def create_network(self, name, driver=None, options=None, ipam=None,
9194
'Driver': driver,
9295
'Options': options,
9396
'IPAM': ipam,
94-
'CheckDuplicate': check_duplicate
97+
'CheckDuplicate': check_duplicate,
9598
}
9699

97100
if labels is not None:
@@ -116,6 +119,12 @@ def create_network(self, name, driver=None, options=None, ipam=None,
116119
'supported in API version < 1.22')
117120
data['Internal'] = True
118121

122+
if attachable is not None
123+
if version_lt(self._version, '1.24'):
124+
raise InvalidVersion('Attachable is not '
125+
'supported in API version < 1.24')
126+
data['Attachable'] = attachable
127+
119128
url = self._url("/networks/create")
120129
res = self._post_json(url, data=data)
121130
return self._result(res, json=True)

tests/unit/api_network_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def test_create_network(self):
105105
}
106106
})
107107

108+
@requires_api_version('1.24')
109+
def test_create_network_with_attachable(self):
110+
pass
111+
108112
@requires_api_version('1.21')
109113
def test_remove_network(self):
110114
network_id = 'abc12345'

0 commit comments

Comments
 (0)