Skip to content

Commit

Permalink
Merge pull request #5841 from rvykydal/nbft-ignore-ifname-rhel-9
Browse files Browse the repository at this point in the history
Nbft ignore ifname rhel 9
  • Loading branch information
M4rtinK authored Aug 21, 2024
2 parents 0af4444 + bfa144b commit 14b135d
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 7 deletions.
9 changes: 4 additions & 5 deletions pyanaconda/modules/network/device_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import copy

from pyanaconda.core.regexes import IBFT_CONFIGURED_DEVICE_NAME
from pyanaconda.core.signal import Signal
from pyanaconda.modules.network.nm_client import get_iface_from_connection, \
get_vlan_interface_name_from_connection, get_config_file_connection_of_device, \
Expand All @@ -29,6 +28,7 @@
from pyanaconda.modules.network.constants import NM_CONNECTION_TYPE_WIFI, \
NM_CONNECTION_TYPE_ETHERNET, NM_CONNECTION_TYPE_VLAN, NM_CONNECTION_TYPE_BOND, \
NM_CONNECTION_TYPE_TEAM, NM_CONNECTION_TYPE_BRIDGE, NM_CONNECTION_TYPE_INFINIBAND
from pyanaconda.modules.network.utils import is_ibft_configured_device, is_nbft_device

import gi
gi.require_version("NM", "1.0")
Expand Down Expand Up @@ -335,6 +335,9 @@ def _should_add_connection(self, connection):
elif is_ibft_configured_device(iface or ""):
decline_reason = "configured from iBFT"

elif is_nbft_device(iface or ""):
decline_reason = "nBFT device"

# Ignore unsupported device types
elif device_type not in supported_device_types:
decline_reason = "unsupported type"
Expand Down Expand Up @@ -519,7 +522,3 @@ def __repr__(self):

def is_libvirt_device(iface):
return iface.startswith("virbr")


def is_ibft_configured_device(iface):
return IBFT_CONFIGURED_DEVICE_NAME.match(iface)
10 changes: 9 additions & 1 deletion pyanaconda/modules/network/initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
is_bootif_connection
from pyanaconda.modules.network.device_configuration import supported_wired_device_types, \
virtual_device_types
from pyanaconda.modules.network.utils import guard_by_system_configuration
from pyanaconda.modules.network.utils import guard_by_system_configuration, is_nbft_device

log = get_module_logger(__name__)

Expand Down Expand Up @@ -102,6 +102,10 @@ def _run(self, nm_client):
log.warning("%s: --device %s not found", self.name, network_data.device)
continue

if is_nbft_device(device_name):
log.debug("Ignoring nBFT device %s", device_name)
continue

applied_devices.append(device_name)

connection = self._find_initramfs_connection_of_iface(nm_client, device_name)
Expand Down Expand Up @@ -232,6 +236,10 @@ def _run(self, nm_client):

iface = device.get_iface()

if is_nbft_device(iface or ""):
log.debug("Ignoring nBFT device %s", iface)
continue

if get_config_file_connection_of_device(nm_client, iface):
continue

Expand Down
6 changes: 5 additions & 1 deletion pyanaconda/modules/network/installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from pyanaconda.anaconda_loggers import get_module_logger
from pyanaconda.modules.network.nm_client import update_connection_values, \
commit_changes_with_autoconnection_blocked, nm_client_in_thread
from pyanaconda.modules.network.utils import guard_by_system_configuration
from pyanaconda.modules.network.utils import guard_by_system_configuration, is_nbft_device
from pyanaconda.modules.network.nm_client import get_config_file_connection_of_device
from pyanaconda.modules.network.config_file import IFCFG_DIR, KEYFILE_DIR

Expand Down Expand Up @@ -182,6 +182,10 @@ def _write_interface_rename_config(self, root, ifname_option_values, overwrite):
:type overwrite: bool
"""

# Avoid link files for 'nbft' interfaces as it breaks Boot from NVM over TCP
ifname_option_values = [value for value in ifname_option_values
if not is_nbft_device(value.split(':')[0])]

if ifname_option_values:
target_system_dir = util.join_paths(root, self.SYSTEMD_NETWORK_CONFIG_DIR)
util.mkdirChain(target_system_dir)
Expand Down
9 changes: 9 additions & 0 deletions pyanaconda/modules/network/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from pyanaconda.core import util
from pyanaconda.core.configuration.anaconda import conf
from pyanaconda.core.regexes import IBFT_CONFIGURED_DEVICE_NAME

from pyanaconda.anaconda_loggers import get_module_logger
log = get_module_logger(__name__)
Expand Down Expand Up @@ -130,3 +131,11 @@ def wrapped(*args, **kwargs):
return function(*args, **kwargs)
return wrapped
return wrap


def is_ibft_configured_device(iface):
return IBFT_CONFIGURED_DEVICE_NAME.match(iface)


def is_nbft_device(iface):
return iface.startswith("nbft")
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,45 @@ def _create_all_expected_dirs(self):
]
)

def test_network_instalation_ignore_ifname_nbft(self):
"""Test the task for network installation with an ifname=nbft* argument."""

self._create_all_expected_dirs()

# Create files that will be copied from installer
# No files

# Create files existing on target system (could be used to test overwrite
# parameter.
# No files

# Create the task
task = NetworkInstallationTask(
sysroot=self._target_root,
disable_ipv6=True,
overwrite=True,
network_ifaces=["ens3", "ens7", "nbft0"],
ifname_option_values=["ens3:00:15:17:96:75:0a",
"nbft0:00:15:17:96:75:0b"],
# Perhaps does not make sense together with ifname option, but for
# test it is fine
configure_persistent_device_names=True,
)
self._mock_task_paths(task)
task.run()
content_template = NetworkInstallationTask.INTERFACE_RENAME_FILE_CONTENT_TEMPLATE
self._check_config_file(
self._systemd_network_dir,
"10-anaconda-ifname-ens3.link",
content_template.format("00:15:17:96:75:0a", "ens3")
)
# nbft* devices should be ignored when renaming devices based on
# ifname= option
self._check_config_file_does_not_exist(
self._systemd_network_dir,
"10-anaconda-ifname-nbft0.link"
)

def test_network_instalation_task_no_src_files(self):
"""Test the task for network installation with no src files."""

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright (C) 2024 Red Hat, Inc.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions of
# the GNU General Public License v.2, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY expressed or implied, including the implied warranties of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details. You should have received a copy of the
# GNU General Public License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
# source code or documentation are not subject to the GNU General Public
# License and may only be used or replicated with the express permission of
# Red Hat, Inc.
#
import unittest

from pyanaconda.modules.network.utils import is_nbft_device, is_ibft_configured_device


class NetworkUtilsTestCase(unittest.TestCase):
"""Test the network utils."""

def test_is_nbft_device(self):
"""Test the is_nbft_device function."""
assert is_nbft_device("nbft0")
assert is_nbft_device("nbft55")
assert not is_nbft_device("")
assert not is_nbft_device("eth0")
assert not is_nbft_device("mynbft")

def test_is_ibft_configured_device(self):
"""Test the is_ibft_configured_device function."""
assert is_ibft_configured_device("ibft0")
assert is_ibft_configured_device("ibft1")
assert is_ibft_configured_device("ibft11")
assert not is_ibft_configured_device("myibft0")
assert not is_ibft_configured_device("ibft")
assert not is_ibft_configured_device("ibftfirst")
assert not is_ibft_configured_device("ibgt0")

0 comments on commit 14b135d

Please sign in to comment.