mirror of https://github.com/docker/compose.git
Add support for enable_ipv6 in network definition.
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
8f636d8279
commit
e5ded6ff9b
|
@ -246,7 +246,8 @@
|
|||
"name": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"enable_ipv6": {"type": "boolean"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
},
|
||||
|
|
|
@ -15,7 +15,7 @@ log = logging.getLogger(__name__)
|
|||
|
||||
class Network(object):
|
||||
def __init__(self, client, project, name, driver=None, driver_opts=None,
|
||||
ipam=None, external_name=None, internal=False):
|
||||
ipam=None, external_name=None, internal=False, enable_ipv6=False):
|
||||
self.client = client
|
||||
self.project = project
|
||||
self.name = name
|
||||
|
@ -24,6 +24,7 @@ class Network(object):
|
|||
self.ipam = create_ipam_config_from_dict(ipam)
|
||||
self.external_name = external_name
|
||||
self.internal = internal
|
||||
self.enable_ipv6 = enable_ipv6
|
||||
|
||||
def ensure(self):
|
||||
if self.external_name:
|
||||
|
@ -70,6 +71,7 @@ class Network(object):
|
|||
options=self.driver_opts,
|
||||
ipam=self.ipam,
|
||||
internal=self.internal,
|
||||
enable_ipv6=self.enable_ipv6
|
||||
)
|
||||
|
||||
def remove(self):
|
||||
|
@ -118,6 +120,7 @@ def build_networks(name, config_data, client):
|
|||
ipam=data.get('ipam'),
|
||||
external_name=data.get('external_name'),
|
||||
internal=data.get('internal'),
|
||||
enable_ipv6=data.get('enable_ipv6'),
|
||||
)
|
||||
for network_name, data in network_config.items()
|
||||
}
|
||||
|
|
|
@ -721,6 +721,51 @@ class ProjectTest(DockerClientTestCase):
|
|||
assert IPAMConfig.get('IPv4Address') == '172.16.100.100'
|
||||
assert IPAMConfig.get('IPv6Address') == 'fe80::1001:102'
|
||||
|
||||
@v2_1_only()
|
||||
def test_up_with_enable_ipv6(self):
|
||||
self.require_api_version('1.23')
|
||||
config_data = config.Config(
|
||||
version=V2_0,
|
||||
services=[{
|
||||
'name': 'web',
|
||||
'image': 'busybox:latest',
|
||||
'command': 'top',
|
||||
'networks': {
|
||||
'static_test': {
|
||||
'ipv6_address': 'fe80::1001:102'
|
||||
}
|
||||
},
|
||||
}],
|
||||
volumes={},
|
||||
networks={
|
||||
'static_test': {
|
||||
'driver': 'bridge',
|
||||
'enable_ipv6': True,
|
||||
'ipam': {
|
||||
'driver': 'default',
|
||||
'config': [
|
||||
{"subnet": "fe80::/64",
|
||||
"gateway": "fe80::1001:1"}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
project = Project.from_config(
|
||||
client=self.client,
|
||||
name='composetest',
|
||||
config_data=config_data,
|
||||
)
|
||||
project.up(detached=True)
|
||||
network = self.client.networks(names=['static_test'])[0]
|
||||
service_container = project.get_service('web').containers()[0]
|
||||
|
||||
assert network['EnableIPv6'] is True
|
||||
ipam_config = (service_container.inspect().get('NetworkSettings', {}).
|
||||
get('Networks', {}).get('composetest_static_test', {}).
|
||||
get('IPAMConfig', {}))
|
||||
assert ipam_config.get('IPv6Address') == 'fe80::1001:102'
|
||||
|
||||
@v2_only()
|
||||
def test_up_with_network_static_addresses_missing_subnet(self):
|
||||
config_data = config.Config(
|
||||
|
|
Loading…
Reference in New Issue