mirror of
https://github.com/docker/compose.git
synced 2025-07-21 04:34:38 +02:00
Add support for IPAM options in v2 format
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
ce44c865e5
commit
843a0d82a0
@ -253,6 +253,13 @@
|
|||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"type": "object",
|
||||||
|
"patternProperties": {
|
||||||
|
"^.+$": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
@ -298,6 +298,13 @@
|
|||||||
"driver": {"type": "string"},
|
"driver": {"type": "string"},
|
||||||
"config": {
|
"config": {
|
||||||
"type": "array"
|
"type": "array"
|
||||||
|
},
|
||||||
|
"options": {
|
||||||
|
"type": "object",
|
||||||
|
"patternProperties": {
|
||||||
|
"^.+$": {"type": "string"}
|
||||||
|
},
|
||||||
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
@ -123,6 +123,7 @@ def create_ipam_config_from_dict(ipam_dict):
|
|||||||
)
|
)
|
||||||
for config in ipam_dict.get('config', [])
|
for config in ipam_dict.get('config', [])
|
||||||
],
|
],
|
||||||
|
options=ipam_dict.get('options')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -157,6 +158,12 @@ def check_remote_ipam_config(remote, local):
|
|||||||
if sorted(lc.get('AuxiliaryAddresses')) != sorted(rc.get('AuxiliaryAddresses')):
|
if sorted(lc.get('AuxiliaryAddresses')) != sorted(rc.get('AuxiliaryAddresses')):
|
||||||
raise NetworkConfigChangedError(local.full_name, 'IPAM config aux_addresses')
|
raise NetworkConfigChangedError(local.full_name, 'IPAM config aux_addresses')
|
||||||
|
|
||||||
|
remote_opts = remote_ipam.get('Options', {})
|
||||||
|
local_opts = local.ipam.get('options', {})
|
||||||
|
for k in set.union(set(remote_opts.keys()), set(local_opts.keys())):
|
||||||
|
if remote_opts.get(k) != local_opts.get(k):
|
||||||
|
raise NetworkConfigChangedError(local.full_name, 'IPAM option "{}"'.format(k))
|
||||||
|
|
||||||
|
|
||||||
def check_remote_network_config(remote, local):
|
def check_remote_network_config(remote, local):
|
||||||
if local.driver and remote.get('Driver') != local.driver:
|
if local.driver and remote.get('Driver') != local.driver:
|
||||||
|
@ -681,6 +681,41 @@ class ProjectTest(DockerClientTestCase):
|
|||||||
}],
|
}],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@v2_only()
|
||||||
|
def test_up_with_ipam_options(self):
|
||||||
|
config_data = build_config(
|
||||||
|
version=V2_0,
|
||||||
|
services=[{
|
||||||
|
'name': 'web',
|
||||||
|
'image': 'busybox:latest',
|
||||||
|
'networks': {'front': None},
|
||||||
|
}],
|
||||||
|
networks={
|
||||||
|
'front': {
|
||||||
|
'driver': 'bridge',
|
||||||
|
'ipam': {
|
||||||
|
'driver': 'default',
|
||||||
|
'options': {
|
||||||
|
"com.docker.compose.network.test": "9-29-045"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
project = Project.from_config(
|
||||||
|
client=self.client,
|
||||||
|
name='composetest',
|
||||||
|
config_data=config_data,
|
||||||
|
)
|
||||||
|
project.up()
|
||||||
|
|
||||||
|
network = self.client.networks(names=['composetest_front'])[0]
|
||||||
|
|
||||||
|
assert network['IPAM']['Options'] == {
|
||||||
|
"com.docker.compose.network.test": "9-29-045"
|
||||||
|
}
|
||||||
|
|
||||||
@v2_only()
|
@v2_only()
|
||||||
def test_up_with_network_static_addresses(self):
|
def test_up_with_network_static_addresses(self):
|
||||||
config_data = build_config(
|
config_data = build_config(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user