Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

network: enable dnsconfd service on installed system if required #6186

Open
wants to merge 1 commit into
base: rhel-10
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pyanaconda/modules/network/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import os
import shutil

from pyanaconda.core import service
from pyanaconda.core.kernel import kernel_arguments
from pyanaconda.core.path import make_directories, join_paths
from pyanaconda.modules.common.errors.installation import NetworkInstallationError
from pyanaconda.modules.common.task import Task
Expand Down Expand Up @@ -115,6 +117,7 @@ class NetworkInstallationTask(Task):
[Link]
Name={}
""".strip()
DNSCONFD_SERVICE = "dnsconfd"

def __init__(self, sysroot, disable_ipv6, overwrite,
network_ifaces, ifname_option_values,
Expand Down Expand Up @@ -158,6 +161,7 @@ def run(self):
if self._configure_persistent_device_names:
self._copy_prefixdevname_files(self._sysroot)
self._copy_global_dns_config(self._sysroot)
self._enable_dnsconfd(self._sysroot)

def _write_sysconfig_network(self, root, overwrite):
"""Write empty /etc/sysconfig/network target system configuration file.
Expand Down Expand Up @@ -295,6 +299,13 @@ def _copy_global_dns_config(self, root):
if os.path.isfile(src):
shutil.copy(src, dst)

def _enable_dnsconfd(self, root):
"""Enable dnsconfd service if dnsconfd backend is used."""
if kernel_arguments.get("rd.net.dns-backend") == "dnsconfd":
if not service.is_service_installed(self.DNSCONFD_SERVICE, root=root):
log.debug("The dnsconfd service is not installed.")
return
service.enable_service(self.DNSCONFD_SERVICE, root=root)

class ConfigureActivationOnBootTask(Task):
"""Task for configuration of automatic activation of devices on boot"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1608,6 +1608,30 @@ def _create_config_files_to_check_overwrite(self):
(("71-net-ifnames-prefix-XYZ", "installer environment content"),)
)

@patch("pyanaconda.modules.network.installation.service")
def test_network_installation_task_dnsconfd_enablement(self, mocked_service):
"""Test the task for network installation dnsconfd enablement."""

self._create_all_expected_dirs()
task = NetworkInstallationTask(
sysroot=self._target_root,
disable_ipv6=False,
overwrite=True,
network_ifaces=["ens3", "ens7", "ens10"],
ifname_option_values=["ens3:00:15:17:96:75:0a"],
configure_persistent_device_names=False,
)
self._mock_task_paths(task)

kernel_args = KernelArguments.from_string("rd.net.dns-backend=dnsconfd")
with patch("pyanaconda.modules.network.installation.kernel_arguments", kernel_args):
mocked_service.is_service_installed.return_value = False
task.run()
mocked_service.enable_service.assert_not_called()
mocked_service.is_service_installed.return_value = True
task.run()
mocked_service.enable_service.assert_called_once()

def test_network_installation_task_overwrite(self):
"""Test the task for network installation with overwrite."""

Expand Down
Loading