Kaydet (Commit) 98b41fee authored tarafından Jonathan Giannuzzi's avatar Jonathan Giannuzzi

Add support for creating internal networks

Signed-off-by: 's avatarJonathan Giannuzzi <jonathan@giannuzzi.be>
üst 966dfac3
......@@ -22,7 +22,7 @@ class NetworkApiMixin(object):
@minimum_version('1.21')
def create_network(self, name, driver=None, options=None, ipam=None,
check_duplicate=None):
check_duplicate=None, internal=False):
if options is not None and not isinstance(options, dict):
raise TypeError('options must be a dictionary')
......@@ -33,6 +33,13 @@ class NetworkApiMixin(object):
'IPAM': ipam,
'CheckDuplicate': check_duplicate
}
if internal:
if version_lt(self._version, '1.22'):
raise InvalidVersion('Internal networks are not '
'supported in API version < 1.22')
data['Internal'] = True
url = self._url("/networks/create")
res = self._post_json(url, data=data)
return self._result(res, json=True)
......
......@@ -18,3 +18,10 @@ ipam_config = docker.utils.create_ipam_config(subnet='192.168.52.0/24', gateway=
docker_client.create_network("network1", driver="bridge", ipam=ipam_config)
```
With Docker 1.10 you can now also create internal networks
```python
docker_client.create_network("network1", driver="bridge", internal=True)
```
......@@ -298,3 +298,9 @@ class TestNetworks(helpers.BaseTestCase):
self.assertEqual(
net_data['IPAMConfig']['IPv6Address'], '2001:389::f00d'
)
@requires_api_version('1.23')
def test_create_internal_networks(self):
_, net_id = self.create_network(internal=True)
net = self.client.inspect_network(net_id)
assert net['Internal'] is True
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