Skip to content

Commit

Permalink
Re-apply "net: allow dhcp6 configuration from generate_fallback_confi…
Browse files Browse the repository at this point in the history
…guration()" (#4607)

This reverts commit 29ed5f5 and therefore,
re-applies the commit 518047a .

The issue that caused the reversal of 518047a
is fixed by the earlier commit:
a8da6df ("net/network_manager: do not set "may-fail" to False for both ipv4 and ipv6")

Signed-off-by: Ani Sinha <anisinha@redhat.com>
  • Loading branch information
ani-sinha committed Nov 29, 2023
1 parent 65f6bb1 commit d1dff82
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
7 changes: 6 additions & 1 deletion cloudinit/net/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,12 @@ def generate_fallback_config(config_driver=None):
match = {
"macaddress": read_sys_net_safe(target_name, "address").lower()
}
cfg = {"dhcp4": True, "set-name": target_name, "match": match}
cfg = {
"dhcp4": True,
"dhcp6": True,
"set-name": target_name,
"match": match,
}
if config_driver:
driver = device_driver(target_name)
if driver:
Expand Down
4 changes: 4 additions & 0 deletions tests/unittests/net/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ def test_generate_fallback_finds_connected_eth_with_mac(self):
"eth1": {
"match": {"macaddress": mac},
"dhcp4": True,
"dhcp6": True,
"set-name": "eth1",
}
},
Expand All @@ -278,6 +279,7 @@ def test_generate_fallback_finds_dormant_eth_with_mac(self):
"eth0": {
"match": {"macaddress": mac},
"dhcp4": True,
"dhcp6": True,
"set-name": "eth0",
}
},
Expand All @@ -293,6 +295,7 @@ def test_generate_fallback_finds_eth_by_operstate(self):
"ethernets": {
"eth0": {
"dhcp4": True,
"dhcp6": True,
"match": {"macaddress": mac},
"set-name": "eth0",
}
Expand Down Expand Up @@ -359,6 +362,7 @@ def is_netfail_master(iface, _driver=None):
"ethernets": {
"ens3": {
"dhcp4": True,
"dhcp6": True,
"match": {"name": "ens3"},
"set-name": "ens3",
}
Expand Down
24 changes: 21 additions & 3 deletions tests/unittests/test_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -4287,6 +4287,7 @@ def test_device_driver_v2(
"ethernets": {
"eth0": {
"dhcp4": True,
"dhcp6": True,
"set-name": "eth0",
"match": {
"macaddress": "00:11:22:33:44:55",
Expand Down Expand Up @@ -4371,6 +4372,9 @@ def test_device_driver(
auto eth0
iface eth0 inet dhcp
# control-alias eth0
iface eth0 inet6 dhcp
"""
self.assertEqual(expected.lstrip(), contents.lstrip())

Expand Down Expand Up @@ -4460,6 +4464,9 @@ def test_hv_netvsc_vf_filter(
auto eth1
iface eth1 inet dhcp
# control-alias eth1
iface eth1 inet6 dhcp
"""
self.assertEqual(expected.lstrip(), contents.lstrip())

Expand Down Expand Up @@ -4683,7 +4690,9 @@ def test_default_generation(
#
BOOTPROTO=dhcp
DEVICE=eth1000
DHCPV6C=yes
HWADDR=07-1c-c6-75-a4-be
IPV6INIT=yes
NM_CONTROLLED=no
ONBOOT=yes
TYPE=Ethernet
Expand Down Expand Up @@ -5594,7 +5603,8 @@ def test_default_generation(
expected_content = """
# Created by cloud-init automatically, do not edit.
#
BOOTPROTO=dhcp4
BOOTPROTO=dhcp
DHCLIENT6_MODE=managed
LLADDR=07-1c-c6-75-a4-be
STARTMODE=auto
""".lstrip()
Expand Down Expand Up @@ -5974,7 +5984,11 @@ def test_default_generation(
[ipv4]
method=auto
may-fail=false
may-fail=true
[ipv6]
method=auto
may-fail=true
"""
),
Expand Down Expand Up @@ -6240,6 +6254,9 @@ def test_default_generation(
auto eth1000
iface eth1000 inet dhcp
# control-alias eth1000
iface eth1000 inet6 dhcp
"""
self.assertEqual(expected.lstrip(), contents.lstrip())

Expand Down Expand Up @@ -6299,6 +6316,7 @@ class TestNetplanNetRendering:
ethernets:
eth1000:
dhcp4: true
dhcp6: true
match:
macaddress: 07-1c-c6-75-a4-be
set-name: eth1000
Expand Down Expand Up @@ -7798,7 +7816,7 @@ def test_networkd_default_generation(
Name=eth1000
MACAddress=07-1c-c6-75-a4-be
[Network]
DHCP=ipv4"""
DHCP=yes"""
).rstrip(" ")

expected = self.create_conf_dict(expected.splitlines())
Expand Down

0 comments on commit d1dff82

Please sign in to comment.