From eb183fdf6da6a245da4d0f69c84e6d48163ad719 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 10 May 2023 20:01:39 +0200 Subject: [PATCH 1/4] DASDDiscoverTask: use consolidated device configuration with zdev (#1802482,#1937049) Implements the dasd part of referenced bugs. This allows to delegate s390-specifics to zdev from s390-tools and to subsequently remove s390-specific code here. Additionally, the change supports to subsequently solely rely on the zdev persistent device configuration "database". Create entries on activating devices. Simply copy the persistent device configuration to sysroot finally without having to deal with device properties. The spec file update reflects the new dependency on `chzdev` from the s390 architecture specific sub-package s390utils-core. Actually, this commit here only depends on `chzdev` in older versions already packaged and shipped, so no version comparison necessary here. Regarding unit test: As blockdev was already mocked it's not clear how the test would mock that sanitize_dev_input would actually canonicalize a DASD device bus-ID. Also, the argument to execWithRedirect() is much more involved than just the device bus-ID previously. It does not make sense for the unit test to hard code the full argument of how execWithRedirect() is currently invoked in the code. So just check that the new code calls execWithRedirect() exactly once and ignore the arguments. It would be a separate fix patch to improve a fake sanitize unit test. I suppose it would need to start with a DASD device bus-ID that is not yet canonical/sanitized, e.g. something along the lines of: DASDDiscoverTask("A100").run() blockdev.s390.sanitize_dev_input.return_value = "0.0.A100" blockdev.s390.sanitize_dev_input.assert_called_once_with("A100") sanitized_input = blockdev.s390.sanitize_dev_input.return_value execWithRedirect.assert_called_once_with(...) It's unclear how much value that would have, though. Signed-off-by: Steffen Maier --- anaconda.spec.in | 1 + pyanaconda/modules/storage/dasd/discover.py | 11 +++++++++-- .../modules/storage/test_module_dasd.py | 7 ++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/anaconda.spec.in b/anaconda.spec.in index c87f5437899..24f82053d54 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -125,6 +125,7 @@ Requires: NetworkManager-team %endif %ifarch s390 s390x Requires: openssh +Requires: s390utils-core %endif Requires: NetworkManager >= %{nmver} Requires: NetworkManager-libnm >= %{nmver} diff --git a/pyanaconda/modules/storage/dasd/discover.py b/pyanaconda/modules/storage/dasd/discover.py index 392aeecef66..e848da99bc0 100644 --- a/pyanaconda/modules/storage/dasd/discover.py +++ b/pyanaconda/modules/storage/dasd/discover.py @@ -22,6 +22,7 @@ from pyanaconda.core.regexes import DASD_DEVICE_NUMBER from pyanaconda.modules.common.task import Task from pyanaconda.modules.common.errors.configuration import StorageDiscoveryError +from pyanaconda.core.util import execWithRedirect class DASDDiscoverTask(Task): @@ -58,6 +59,12 @@ def _discover_device(self): """Discover the device.""" # pylint: disable=try-except-raise try: - blockdev.s390.dasd_online(self._device_number) - except blockdev.S390Error as e: + rc = execWithRedirect("chzdev", + ["--enable", "dasd", self._device_number, + "--active", "--persistent", + "--yes", "--no-root-update", "--force"]) + except RuntimeError as e: raise StorageDiscoveryError(str(e)) from e + if rc != 0: + raise StorageDiscoveryError( + "Could not set the device online. It might not exist.") diff --git a/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py b/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py index ed5c40ce9e9..54b86a6d33c 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py +++ b/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py @@ -123,14 +123,15 @@ def test_discovery_fails(self): with pytest.raises(StorageDiscoveryError): DASDDiscoverTask("x.y.z").run() + @patch('pyanaconda.modules.storage.dasd.discover.execWithRedirect') @patch('pyanaconda.modules.storage.dasd.discover.blockdev') - def test_discovery(self, blockdev): + def test_discovery(self, blockdev, execWithRedirect): """Test the discovery task.""" + execWithRedirect.return_value = 0 DASDDiscoverTask("0.0.A100").run() blockdev.s390.sanitize_dev_input.assert_called_once_with("0.0.A100") - sanitized_input = blockdev.s390.sanitize_dev_input.return_value - blockdev.s390.dasd_online.assert_called_once_with(sanitized_input) + execWithRedirect.assert_called_once() @patch('pyanaconda.modules.storage.dasd.format.blockdev') def test_format(self, blockdev): From 81fbcb5c459131f722fc65fc0b974eaf3183cae9 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 10 May 2023 18:55:36 +0200 Subject: [PATCH 2/4] write persistent config of any (dasd,zfcp,znet) s390 devices to sysroot (#1802482,#1937049) Implements a part of the referenced bugs. Depends on https://github.com/ibm-s390-linux/s390-tools/commit/bc4f4551512c324915564e3898e9d7fd3401e6eb ("zdev/dracut: retain early persistent config over switch root"). The spec file update reflects this new dependency on the new v2.31.0 of the s390 architecture specific sub-package s390utils-core. A new s390-tools zdev dracut module hook retain-zdev.sh copies the zdev persistent configuration from the initrd into /run/zdev.initrd.config. Import that persistent device configuration. It can be used: * to transfer the configuration into the installed system. * by python-blivet ZFCPDiskDevice.dracut_setup_args(), Any s390 device configuration in the installer user interface produces persistent zdev config entries. Instead of treating each s390 device type differently, simply transfer the entire combined resulting zdev persistent config into the installed system. The import above also fixes the problem that installations, which got zfcp paths activated by means of rd.zfcp= dracut cmdline arguments, were missing those paths in the installed system. Since commit 87ab1ab2a3aa ("Support cio_ignore functionality for zFCP devices (#533492)"), /etc/zfcp.conf replaced /tmp/fcpconfig. Since commit 011ea0a17794 ("Remove linuxrc.s390"), /etc/zfcp.conf only exists if the user specified dracut cmdline parameter rd.zfcp=. https://github.com/ibm-s390-linux/s390-tools/tree/master/zdev/ handles parsing of rd.zfcp= without /etc/zfcp.conf as of commit 06a30ae529a5 ("zdev/dracut: add rd.zfcp cmdline option handling"). https://src.fedoraproject.org/rpms/s390utils.git no longer writes /etc/zfcp.conf during deprecated parsing of rd.zfcp= as of commit ("zfcp: migrate to consolidated persistent device config with zdev") Hence, nothing populates /etc/zfcp.conf during installer boot anymore. So python-blivet has no more initial import input to carry forward. Signed-off-by: Steffen Maier --- anaconda.spec.in | 3 +- data/systemd/Makefile.am | 1 + ...anaconda-s390-device-config-import.service | 21 +++++++ data/systemd/anaconda.target | 1 + dracut/Makefile.am | 1 - dracut/anaconda-copy-s390ccwconf.sh | 3 - dracut/module-setup.sh | 1 - pyanaconda/modules/storage/installation.py | 62 +++++-------------- 8 files changed, 42 insertions(+), 51 deletions(-) create mode 100644 data/systemd/anaconda-s390-device-config-import.service delete mode 100755 dracut/anaconda-copy-s390ccwconf.sh diff --git a/anaconda.spec.in b/anaconda.spec.in index 24f82053d54..6e3a5ae69e2 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -46,6 +46,7 @@ Source0: https://github.com/rhinstaller/%{name}/releases/download/%{name}-%{vers %define subscriptionmanagerver 1.26 %define utillinuxver 2.15.1 %define rpmostreever 2023.2 +%define s390utilscorever 2.31.0 BuildRequires: libtool BuildRequires: gettext-devel >= %{gettextver} @@ -125,7 +126,7 @@ Requires: NetworkManager-team %endif %ifarch s390 s390x Requires: openssh -Requires: s390utils-core +Requires: s390utils-core >= %{s390utilscorever} %endif Requires: NetworkManager >= %{nmver} Requires: NetworkManager-libnm >= %{nmver} diff --git a/data/systemd/Makefile.am b/data/systemd/Makefile.am index 8c30b393ccd..023a644be32 100644 --- a/data/systemd/Makefile.am +++ b/data/systemd/Makefile.am @@ -29,6 +29,7 @@ dist_systemd_DATA = anaconda.service \ anaconda-nm-config.service \ anaconda-nm-disable-autocons.service \ anaconda-pre.service \ + anaconda-s390-device-config-import.service \ anaconda-fips.service dist_generator_SCRIPTS = anaconda-generator diff --git a/data/systemd/anaconda-s390-device-config-import.service b/data/systemd/anaconda-s390-device-config-import.service new file mode 100644 index 00000000000..d3234767bea --- /dev/null +++ b/data/systemd/anaconda-s390-device-config-import.service @@ -0,0 +1,21 @@ +[Unit] +# This service is to be run before anaconda starts and log data before anaconda changes them +# Import persistent config of any s390 devices (dasd, zfcp, znet) from +# initrd to retain user choices made with rd.dasd, rd.zfcp, rd.znet. +Description=pre-anaconda s390 device persistent config import +ConditionArchitecture=s390x +Requires=basic.target +After=basic.target +Before=anaconda.target +Wants=rsyslog.service +Wants=systemd-udev-settle.service +Wants=plymouth-quit.service plymouth-quit-wait.service +Wants=systemd-logind.service + +[Service] +Type=oneshot +ExecStart=-/sbin/chzdev --import /run/zdev.initrd.config --persistent --yes --no-root-update --force --verbose +StandardInput=tty +StandardOutput=journal+console +StandardError=journal+console +TimeoutSec=0 diff --git a/data/systemd/anaconda.target b/data/systemd/anaconda.target index 07d3e16e08a..4fb0d11573f 100644 --- a/data/systemd/anaconda.target +++ b/data/systemd/anaconda.target @@ -12,6 +12,7 @@ Wants=anaconda-direct.service anaconda.service Wants=anaconda-sshd.service Wants=anaconda-pre.service Wants=anaconda-fips.service +Wants=anaconda-s390-device-config-import.service Wants=systemd-logind.service Wants=brltty.service Wants=rhsm.service diff --git a/dracut/Makefile.am b/dracut/Makefile.am index dc303b5240d..b3e2a9d760d 100644 --- a/dracut/Makefile.am +++ b/dracut/Makefile.am @@ -37,7 +37,6 @@ dist_dracut_SCRIPTS = module-setup.sh \ anaconda-copy-cmdline.sh \ anaconda-copy-dhclient.sh \ anaconda-copy-prefixdevname.sh \ - anaconda-copy-s390ccwconf.sh \ anaconda-ifcfg.sh \ anaconda-set-kernel-hung-timeout.sh \ anaconda-error-reporting.sh \ diff --git a/dracut/anaconda-copy-s390ccwconf.sh b/dracut/anaconda-copy-s390ccwconf.sh deleted file mode 100755 index 0074720d576..00000000000 --- a/dracut/anaconda-copy-s390ccwconf.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Copy over s390 config /etc/ccw.conf for anaconda before pivot -[ -e /etc/ccw.conf ] && cp /etc/ccw.conf /run/install diff --git a/dracut/module-setup.sh b/dracut/module-setup.sh index b1972e9b316..fff1288254a 100755 --- a/dracut/module-setup.sh +++ b/dracut/module-setup.sh @@ -48,7 +48,6 @@ install() { inst "$moddir/anaconda-diskroot" "/sbin/anaconda-diskroot" inst_hook pre-pivot 50 "$moddir/anaconda-copy-ks.sh" inst_hook pre-pivot 50 "$moddir/anaconda-copy-cmdline.sh" - inst_hook pre-pivot 50 "$moddir/anaconda-copy-s390ccwconf.sh" inst_hook pre-pivot 90 "$moddir/anaconda-copy-dhclient.sh" inst_hook pre-pivot 91 "$moddir/anaconda-copy-prefixdevname.sh" inst_hook pre-pivot 95 "$moddir/anaconda-set-kernel-hung-timeout.sh" diff --git a/pyanaconda/modules/storage/installation.py b/pyanaconda/modules/storage/installation.py index d3a90d26d6c..9889589e7a8 100644 --- a/pyanaconda/modules/storage/installation.py +++ b/pyanaconda/modules/storage/installation.py @@ -32,10 +32,10 @@ from pyanaconda.anaconda_loggers import get_module_logger from pyanaconda.core.i18n import _ -from pyanaconda.core.util import join_paths +from pyanaconda.core.util import join_paths, execWithRedirect from pyanaconda.core.path import make_directories from pyanaconda.core.configuration.anaconda import conf -from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, ZFCP, NVME +from pyanaconda.modules.common.constants.objects import ISCSI, FCOE, NVME from pyanaconda.modules.common.constants.services import STORAGE from pyanaconda.modules.common.errors.installation import StorageInstallationError from pyanaconda.modules.common.task import Task @@ -290,13 +290,10 @@ def _write_storage_configuration(self, storage, sysroot=None): fcoe_proxy = STORAGE.get_proxy(FCOE) fcoe_proxy.WriteConfiguration() - zfcp_proxy = STORAGE.get_proxy(ZFCP) - zfcp_proxy.WriteConfiguration() - nvme_proxy = STORAGE.get_proxy(NVME) nvme_proxy.WriteConfiguration() - self._write_dasd_conf(storage, sysroot) + self._write_s390_device_config(sysroot) def _write_escrow_packets(self, storage, sysroot): """Write the escrow packets. @@ -361,46 +358,21 @@ def _write_lvm_devices_file(storage, sysroot): make_directories(os.path.dirname(out_filename)) shutil.copyfile(in_filename, out_filename) - def _write_dasd_conf(self, storage, sysroot): - """Write DASD configuration to sysroot. + def _write_s390_device_config(self, sysroot): + """Copy entire persistent config of any s390 devices to sysroot. - Write /etc/dasd.conf to target system for all DASD devices - configured during installation. + This includes config imported from initrd as well as anything the user + configured via the installer user interface. - :param storage: the storage object :param sysroot: a path to the target OS installation """ - dasds = [d for d in storage.devices if d.type == "dasd"] - dasds.sort(key=lambda d: d.name) - if not (arch.is_s390() and dasds): - return - - with open(os.path.realpath(sysroot + "/etc/dasd.conf"), "w") as f: - for dasd in dasds: - fields = [dasd.busid] + dasd.get_opts() - f.write("%s\n" % " ".join(fields),) - - # check for hyper PAV aliases; they need to get added to dasd.conf as well - sysfs = "/sys/bus/ccw/drivers/dasd-eckd" - - # in the case that someone is installing with *only* FBA DASDs,the above - # sysfs path will not exist; so check for it and just bail out of here if - # that's the case - if not os.path.exists(sysfs): - return - - # this does catch every DASD, even non-aliases, but we're only going to be - # checking for a very specific flag, so there won't be any duplicate entries - # in dasd.conf - devs = [d for d in os.listdir(sysfs) if d.startswith("0.0")] - with open(os.path.realpath(sysroot + "/etc/dasd.conf"), "a") as f: - for d in devs: - aliasfile = "%s/%s/alias" % (sysfs, d) - with open(aliasfile, "r") as falias: - alias = falias.read().strip() - - # if alias == 1, then the device is an alias; otherwise it is a - # normal dasd (alias == 0) and we can skip it, since it will have - # been added to dasd.conf in the above block of code - if alias == "1": - f.write("%s\n" % d) + if arch.is_s390(): + execWithRedirect("chzdev", + ["--export", "/tmp/zdev.config", + "--all", "--type", "--persistent", + "--verbose"]) + execWithRedirect("chzdev", + ["--import", "/tmp/zdev.config", + "--persistent", + "--yes", "--no-root-update", "--force", "--verbose", + "--base", "/etc=%s/etc" % sysroot]) From cc387aaad5915dcaa13fad87555f92d0516ad9b7 Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 6 Sep 2023 18:20:12 +0200 Subject: [PATCH 3/4] network: use consolidated s390 device configuration (#1802482,#1937049) Implements the znet part of referenced bugs. Depends on https://github.com/ibm-s390-linux/s390-tools/commit/73f51e45a8c41df2db524a728fd865d555d02489 ("zdev: add helper to convert from zdev config to rd.znet"). The spec file already reflects the new dependency on `zdev-to-rd.znet` in the new v2.31.0 of the s390 architecture specific sub-package s390utils-core. Dracut commit ("feat(znet): use zdev for consolidated device configuration"), replaces the distribution-specific persistent configuration of s390 (channel-attached) network devices with a common consolidated mechanism using chzdev from s390-tools. So there is no more ccw.conf nor s390-specific low-level network config in NetworkManager connections nor ifcfg files. The spec file update reflects this new dependency on the updated dracut module "znet" in a new version of the dracut-network sub-package. Therefore, drop NETTYPE and OPTIONS. Keep SUBCHANNELS nonetheless because it can still serve as a matching key for NM connections. Delegate the generation of rd.znet statements to a helper tool from s390-tools, which gets its low-level config information from the consolidated mechanism using chzdev. There are two different code paths involved: * Root-fs on something (such as iSCSI or NFS) that depends on znet =>_get_dracut_znet_argument_from_connection(). Related earlier commits: commit fa174ab0e7b1 ("Write rd_CCW when root fs is on a network device on s390x (#577193)") and lately replacing former code: commit f85682f4b6b4 ("network module: add support for getting dracut arguments") commit 7cf4d6492f4c ("network module: use network module to get dracut arguments") and finally replacing initscripts ifcfg by NetworkManager connection: commit 840c984fca65 ("network: generate dracut arguments from connections (#1751189)") (Note that this generated rd.znet is independent of the (last) one just inherited from the boot parameters between commit 64fb10673441 ("Preserve network args on s390x.") and commit a4ba9aec1031 ("Do not pass rd.znet on to installed system unconditionally").) * Configure znet on boot with rd.znet= but without any corresponding ip= and instead use the kickstart command "network" to perform high-level configuration of the network interface created with rd.znet. This creates a non-initramfs NM connection. => pyanaconda.modules.network.initialization.ApplyKickstartTask.run => pyanaconda.modules.network.nm_client.add_connection_from_ksdata => pyanaconda.modules.network.nm_client.create_connections_from_ksdata => get_s390_settings() and _update_wired_connection_with_s390_settings() (In contrast, early initrd network setups get both the low-level s390 config and high-level interface config via nm-initrd-generator, which parses rd.znet= as well as ip=.) Signed-off-by: Steffen Maier --- anaconda.spec.in | 3 +- pyanaconda/modules/network/nm_client.py | 20 ++++--------- pyanaconda/modules/network/utils.py | 19 ------------ .../network/test_module_network_nm_client.py | 30 +++++++++---------- 4 files changed, 21 insertions(+), 51 deletions(-) diff --git a/anaconda.spec.in b/anaconda.spec.in index 6e3a5ae69e2..62045938434 100644 --- a/anaconda.spec.in +++ b/anaconda.spec.in @@ -27,7 +27,7 @@ Source0: https://github.com/rhinstaller/%{name}/releases/download/%{name}-%{vers %define dasbusver 1.3 %define dbusver 1.2.3 %define dnfver 3.6.0 -%define dracutver 034-7 +%define dracutver 102-3 %define fcoeutilsver 1.0.12-3.20100323git %define gettextver 0.19.8 %define gtk3ver 3.22.17 @@ -127,6 +127,7 @@ Requires: NetworkManager-team %ifarch s390 s390x Requires: openssh Requires: s390utils-core >= %{s390utilscorever} +Requires: dracut-network >= %{dracutver} %endif Requires: NetworkManager >= %{nmver} Requires: NetworkManager-libnm >= %{nmver} diff --git a/pyanaconda/modules/network/nm_client.py b/pyanaconda/modules/network/nm_client.py index 446a56ca775..5c2012ee7ce 100644 --- a/pyanaconda/modules/network/nm_client.py +++ b/pyanaconda/modules/network/nm_client.py @@ -35,6 +35,7 @@ from pyanaconda.modules.network.utils import get_s390_settings, netmask2prefix, prefix2netmask from pyanaconda.modules.network.config_file import is_config_file_for_system from pyanaconda.core.dbus import SystemBus +from pyanaconda.core import util from pyanaconda.anaconda_loggers import get_module_logger log = get_module_logger(__name__) @@ -437,12 +438,6 @@ def _update_wired_connection_with_s390_settings(connection, s390cfg): if s390cfg['SUBCHANNELS']: subchannels = s390cfg['SUBCHANNELS'].split(",") s_wired.props.s390_subchannels = subchannels - if s390cfg['NETTYPE']: - s_wired.props.s390_nettype = s390cfg['NETTYPE'] - if s390cfg['OPTIONS']: - opts = s390cfg['OPTIONS'].split(" ") - opts_dict = {k: v for k, v in (o.split("=") for o in opts)} - s_wired.props.s390_options = opts_dict def _create_new_connection(network_data, device_name): @@ -1379,15 +1374,10 @@ def _get_dracut_znet_argument_from_connection(connection): argument = "" wired_setting = connection.get_setting_wired() if wired_setting and is_s390(): - nettype = wired_setting.get_s390_nettype() - # get_s390_subchannels() returns a list of subchannels - subchannels = wired_setting.get_s390_subchannels() - if nettype and subchannels: - argument = "rd.znet={},{}".format(nettype, ",".join(subchannels)) - options = wired_setting.get_property(NM.SETTING_WIRED_S390_OPTIONS) - if options: - options_string = ','.join("{}={}".format(key, val) for key, val in options.items()) - argument += ",{}".format(options_string) + devspec = util.execWithCapture("/lib/s390-tools/zdev-to-rd.znet", + ["persistent", + connection.get_interface_name()]).strip() + argument = "rd.znet={}".format(devspec) return argument diff --git a/pyanaconda/modules/network/utils.py b/pyanaconda/modules/network/utils.py index 6d113a7a88d..445c05ef33b 100644 --- a/pyanaconda/modules/network/utils.py +++ b/pyanaconda/modules/network/utils.py @@ -35,8 +35,6 @@ def get_s390_settings(devname): cfg = { 'SUBCHANNELS': '', - 'NETTYPE': '', - 'OPTIONS': '' } subchannels = [] @@ -46,23 +44,6 @@ def get_s390_settings(devname): return cfg cfg['SUBCHANNELS'] = ','.join(subchannels) - # Example of the ccw.conf file content: - # qeth,0.0.0900,0.0.0901,0.0.0902,layer2=0,portname=FOOBAR,portno=0 - # - # SUBCHANNELS="0.0.0900,0.0.0901,0.0.0902" - # NETTYPE="qeth" - # OPTIONS="layer2=1 portname=FOOBAR portno=0" - if not os.path.exists('/run/install/ccw.conf'): - return cfg - with open('/run/install/ccw.conf') as f: - # pylint: disable=redefined-outer-name - for line in f: - if cfg['SUBCHANNELS'] in line: - items = line.strip().split(',') - cfg['NETTYPE'] = items[0] - cfg['OPTIONS'] = " ".join(i for i in items[1:] if '=' in i) - break - return cfg diff --git a/tests/unit_tests/pyanaconda_tests/modules/network/test_module_network_nm_client.py b/tests/unit_tests/pyanaconda_tests/modules/network/test_module_network_nm_client.py index 71abfbe747d..76762d36f8d 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/network/test_module_network_nm_client.py +++ b/tests/unit_tests/pyanaconda_tests/modules/network/test_module_network_nm_client.py @@ -116,17 +116,20 @@ def test_get_ports_from_connections(self, get_iface_from_connection): assert get_ports_from_connections(nm_client, "team", [TEAM1_UUID]) == \ set([("ens11", "ens11", ENS11_UUID)]) + @patch("pyanaconda.modules.network.nm_client._get_dracut_znet_argument_from_connection") @patch("pyanaconda.modules.network.nm_client.get_connections_available_for_iface") @patch("pyanaconda.modules.network.nm_client.get_ports_from_connections") @patch("pyanaconda.modules.network.nm_client.is_s390") def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_connections_mock, - get_connections_available_for_iface): + get_connections_available_for_iface, + _get_dracut_znet_argument_from_connection): nm_client = Mock() CON_UUID = "44755f4c-ee12-45b4-ba5e-e10f83de51af" # IPv4 config auto, IPv6 config auto, mac address specified is_s390.return_value = False + _get_dracut_znet_argument_from_connection.return_value = "" ip4_config_attrs = { "get_method.return_value": NM.SETTING_IP4_CONFIG_METHOD_AUTO, } @@ -162,6 +165,8 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv4 config static, mac address not specified, s390 is_s390.return_value = True + _get_dracut_znet_argument_from_connection.return_value = \ + "rd.znet=qeth,0.0.0900,0.0.0901,0.0.0902,layer2=1,portname=FOOBAR,portno=0" address_attrs = { "get_address.return_value": "10.34.39.44", "get_prefix.return_value": 24, @@ -176,11 +181,6 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn ip4_config = self._get_mock_objects_from_attrs([ip4_config_attrs])[0] wired_setting_attrs = { "get_mac_address.return_value": None, - "get_s390_nettype.return_value": "qeth", - "get_s390_subchannels.return_value": ["0.0.0900", "0.0.0901", "0.0.0902"], - "get_property.return_value": {"layer2": "1", - "portname": "FOOBAR", - "portno": "0"}, } wired_setting = self._get_mock_objects_from_attrs([wired_setting_attrs])[0] cons_attrs = [ @@ -199,6 +199,7 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv6 config dhcp is_s390.return_value = False + _get_dracut_znet_argument_from_connection.return_value = "" ip6_config_attrs = { "get_method.return_value": NM.SETTING_IP6_CONFIG_METHOD_DHCP, } @@ -222,6 +223,7 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv6 config manual is_s390.return_value = False + _get_dracut_znet_argument_from_connection.return_value = "" address_attrs = { "get_address.return_value": "2001::5", "get_prefix.return_value": 64, @@ -253,6 +255,7 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv4 config auto, team is_s390.return_value = False + _get_dracut_znet_argument_from_connection.return_value = "" ip4_config_attrs = { "get_method.return_value": NM.SETTING_IP4_CONFIG_METHOD_AUTO, } @@ -279,6 +282,8 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv4 config auto, vlan, s390, parent specified by interface name is_s390.return_value = True + _get_dracut_znet_argument_from_connection.return_value = \ + "rd.znet=qeth,0.0.0900,0.0.0901,0.0.0902,layer2=1,portname=FOOBAR,portno=0" ip4_config_attrs = { "get_method.return_value": NM.SETTING_IP4_CONFIG_METHOD_AUTO, } @@ -300,11 +305,6 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # Mock parent connection wired_setting_attrs = { "get_mac_address.return_value": None, - "get_s390_nettype.return_value": "qeth", - "get_s390_subchannels.return_value": ["0.0.0900", "0.0.0901", "0.0.0902"], - "get_property.return_value": {"layer2": "1", - "portname": "FOOBAR", - "portno": "0"}, } wired_setting = self._get_mock_objects_from_attrs([wired_setting_attrs])[0] parent_cons_attrs = [ @@ -326,6 +326,7 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv4 config auto, vlan, parent specified by connection uuid VLAN_PARENT_UUID = "5e6ead30-d133-4c8c-ba59-818c5ced6a7c" is_s390.return_value = False + _get_dracut_znet_argument_from_connection.return_value = "" ip4_config_attrs = { "get_method.return_value": NM.SETTING_IP4_CONFIG_METHOD_AUTO, } @@ -361,6 +362,8 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # IPv4 config auto, vlan, parent specified by connection uuid, s390 (we # need the parent connection in s390 case, not only parent iface) is_s390.return_value = True + _get_dracut_znet_argument_from_connection.return_value = \ + "rd.znet=qeth,0.0.0900,0.0.0901,0.0.0902,layer2=1,portname=FOOBAR,portno=0" ip4_config_attrs = { "get_method.return_value": NM.SETTING_IP4_CONFIG_METHOD_AUTO, } @@ -382,11 +385,6 @@ def test_get_dracut_arguments_from_connection(self, is_s390, get_ports_from_conn # Mock parent connection wired_setting_attrs = { "get_mac_address.return_value": None, - "get_s390_nettype.return_value": "qeth", - "get_s390_subchannels.return_value": ["0.0.0900", "0.0.0901", "0.0.0902"], - "get_property.return_value": {"layer2": "1", - "portname": "FOOBAR", - "portno": "0"}, } wired_setting = self._get_mock_objects_from_attrs([wired_setting_attrs])[0] parent_cons_attrs = [ From 9e3cb46a24b5e82c26ee2053a112cc158ad102ff Mon Sep 17 00:00:00 2001 From: Steffen Maier Date: Wed, 15 Nov 2023 14:00:16 +0100 Subject: [PATCH 4/4] unit_tests: drop DASDDevice.opts like in related blivet change https://github.com/storaged-project/blivet/pull/1162#issuecomment-1771443131 removes DASDDevice.opts. Anticipating that blivet change, update the anaconda unit tests making use of DASDDevice. Signed-off-by: Steffen Maier --- .../pyanaconda_tests/modules/storage/test_module_dasd.py | 3 +-- .../modules/storage/test_module_device_tree.py | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py b/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py index 54b86a6d33c..c6ff5ca7911 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py +++ b/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_dasd.py @@ -83,8 +83,7 @@ def test_find_formattable(self, blockdev): "dev1", fmt=get_format("ext4"), size=Size("10 GiB"), - busid="0.0.0201", - opts={} + busid="0.0.0201" ) ) diff --git a/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_device_tree.py b/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_device_tree.py index 4d8bf0d7a60..5858a5b4a4f 100644 --- a/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_device_tree.py +++ b/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_device_tree.py @@ -220,8 +220,7 @@ def test_get_dasd_device_data(self): "dev1", fmt=get_format("ext4"), size=Size("10 GiB"), - busid="0.0.0201", - opts={} + busid="0.0.0201" )) data = self.interface.GetDeviceData("dev1")