mirror of
https://github.com/containers/podman-compose.git
synced 2025-02-14 17:30:45 +01:00
Simplify ip address processing in get_net_args_from_networks()
Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
This commit is contained in:
parent
2dfbb59097
commit
16196a1f6d
@ -942,8 +942,6 @@ def get_net_args_from_networks(compose, cnt):
|
|||||||
# NOTE: A container will only have access to aliases on the first network
|
# NOTE: A container will only have access to aliases on the first network
|
||||||
# that it joins. This is a limitation that will be removed in a later
|
# that it joins. This is a limitation that will be removed in a later
|
||||||
# release.
|
# release.
|
||||||
ip = None
|
|
||||||
ip6 = None
|
|
||||||
if cnt.get("_aliases"):
|
if cnt.get("_aliases"):
|
||||||
aliases.extend(cnt.get("_aliases"))
|
aliases.extend(cnt.get("_aliases"))
|
||||||
|
|
||||||
@ -981,10 +979,6 @@ def get_net_args_from_networks(compose, cnt):
|
|||||||
net_value = net_value or {}
|
net_value = net_value or {}
|
||||||
aliases.extend(norm_as_list(net_value.get("aliases")))
|
aliases.extend(norm_as_list(net_value.get("aliases")))
|
||||||
|
|
||||||
if not ip:
|
|
||||||
ip = net_value.get("ipv4_address")
|
|
||||||
if not ip6:
|
|
||||||
ip6 = net_value.get("ipv6_address")
|
|
||||||
net_priority = net_value.get("priority", 0)
|
net_priority = net_value.get("priority", 0)
|
||||||
prioritized_cnt_nets.append((
|
prioritized_cnt_nets.append((
|
||||||
net_priority,
|
net_priority,
|
||||||
@ -1042,10 +1036,16 @@ def get_net_args_from_networks(compose, cnt):
|
|||||||
net_args.append(f"--network={net_names_str}")
|
net_args.append(f"--network={net_names_str}")
|
||||||
else:
|
else:
|
||||||
net_args.append("--network=bridge")
|
net_args.append("--network=bridge")
|
||||||
if ip:
|
ipv4 = None
|
||||||
net_args.append(f"--ip={ip}")
|
ipv6 = None
|
||||||
if ip6:
|
if multiple_nets:
|
||||||
net_args.append(f"--ip6={ip6}")
|
net_config = list(multiple_nets.values())[0]
|
||||||
|
ipv4 = net_config.get("ipv4_address")
|
||||||
|
ipv6 = net_config.get("ipv6_address")
|
||||||
|
if ipv4:
|
||||||
|
net_args.append(f"--ip={ipv4}")
|
||||||
|
if ipv6:
|
||||||
|
net_args.append(f"--ip6={ipv6}")
|
||||||
if mac_address:
|
if mac_address:
|
||||||
net_args.append(f"--mac-address={mac_address}")
|
net_args.append(f"--mac-address={mac_address}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user