add ipam-driver support

Signed-off-by: Benedikt Braunger <bb@emlix.com>
This commit is contained in:
Benedikt Braunger 2023-02-07 19:17:38 +01:00 committed by Muayyad Alsadi
parent 016c97fd1e
commit 8625d7a4e8

View File

@ -746,7 +746,7 @@ def assert_cnt_nets(compose, cnt):
"--label", "--label",
f"com.docker.compose.project={proj_name}", f"com.docker.compose.project={proj_name}",
] ]
# TODO: add more options here, like driver, internal, ..etc # TODO: add more options here, like dns, ipv6, etc.
labels = net_desc.get("labels", None) or [] labels = net_desc.get("labels", None) or []
for item in norm_as_list(labels): for item in norm_as_list(labels):
args.extend(["--label", item]) args.extend(["--label", item])
@ -758,15 +758,17 @@ def assert_cnt_nets(compose, cnt):
driver_opts = net_desc.get("driver_opts", None) or {} driver_opts = net_desc.get("driver_opts", None) or {}
for key, value in driver_opts.items(): for key, value in driver_opts.items():
args.extend(("--opt", f"{key}={value}")) args.extend(("--opt", f"{key}={value}"))
ipam_config_ls = (net_desc.get("ipam", None) or {}).get( ipam = (net_desc.get("ipam", None) or {})
"config", None ipam_driver = ipam.get("driver", None)
) or [] if ipam_driver:
args.extend(("--ipam-driver", ipam_driver))
ipam_config_ls = ipam.get("config", None) or []
if is_dict(ipam_config_ls): if is_dict(ipam_config_ls):
ipam_config_ls = [ipam_config_ls] ipam_config_ls = [ipam_config_ls]
for ipam in ipam_config_ls: for ipam_config in ipam_config_ls:
subnet = ipam.get("subnet", None) subnet = ipam_config.get("subnet", None)
ip_range = ipam.get("ip_range", None) ip_range = ipam_config.get("ip_range", None)
gateway = ipam.get("gateway", None) gateway = ipam_config.get("gateway", None)
if subnet: if subnet:
args.extend(("--subnet", subnet)) args.extend(("--subnet", subnet))
if ip_range: if ip_range: