241 lines
11 KiB
Diff
241 lines
11 KiB
Diff
From 3b5f7416d5f680cbeb777ba4ba33a4bd4787d6f6 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
|
|
Date: Mon, 7 Nov 2022 09:26:45 +0100
|
|
Subject: [PATCH 23/32] Add the scanzfcp actor handling the IPU with ZFCP
|
|
(s390x)
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
When having systems configured with ZFCP instead of DASD, the disks
|
|
are not seen while rebooting because `/etc/zfcp.conf` is missing
|
|
in the initramfs.
|
|
|
|
When the file exists, it's copied inside the userspace container
|
|
and installed in the upgrade initramfs, producing
|
|
TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks
|
|
messages.
|
|
|
|
pstodulk: updated unit-tests in the scanzfcp and scandasd actors
|
|
|
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2140563
|
|
|
|
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
|
|
---
|
|
.../actors/scandasd/libraries/scandasd.py | 4 +-
|
|
.../scandasd/tests/unit_test_scandasd.py | 23 +++++---
|
|
.../common/actors/scanzfcp/actor.py | 24 ++++++++
|
|
.../actors/scanzfcp/libraries/scanzfcp.py | 25 ++++++++
|
|
.../scanzfcp/tests/unit_test_scanzfcp.py | 59 +++++++++++++++++++
|
|
5 files changed, 124 insertions(+), 11 deletions(-)
|
|
create mode 100644 repos/system_upgrade/common/actors/scanzfcp/actor.py
|
|
create mode 100644 repos/system_upgrade/common/actors/scanzfcp/libraries/scanzfcp.py
|
|
create mode 100644 repos/system_upgrade/common/actors/scanzfcp/tests/unit_test_scanzfcp.py
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/scandasd/libraries/scandasd.py b/repos/system_upgrade/common/actors/scandasd/libraries/scandasd.py
|
|
index 3e1cba66..ff3104d4 100644
|
|
--- a/repos/system_upgrade/common/actors/scandasd/libraries/scandasd.py
|
|
+++ b/repos/system_upgrade/common/actors/scandasd/libraries/scandasd.py
|
|
@@ -18,8 +18,8 @@ def process():
|
|
copy_files = [CopyFile(src=DASD_CONF)]
|
|
api.produce(UpgradeInitramfsTasks(include_files=[DASD_CONF]))
|
|
else:
|
|
- api.current_logger().warning(
|
|
- "The {} file has not been discovered. DASD not used?"
|
|
+ api.current_logger().info(
|
|
+ "The {} file has not been discovered. DASD not used."
|
|
.format(DASD_CONF)
|
|
)
|
|
api.produce(TargetUserSpaceUpgradeTasks(copy_files=copy_files, install_rpms=['s390utils-core']))
|
|
diff --git a/repos/system_upgrade/common/actors/scandasd/tests/unit_test_scandasd.py b/repos/system_upgrade/common/actors/scandasd/tests/unit_test_scandasd.py
|
|
index e4eea10c..af8f951b 100644
|
|
--- a/repos/system_upgrade/common/actors/scandasd/tests/unit_test_scandasd.py
|
|
+++ b/repos/system_upgrade/common/actors/scandasd/tests/unit_test_scandasd.py
|
|
@@ -3,18 +3,18 @@ import os
|
|
import pytest
|
|
|
|
from leapp.libraries.actor import scandasd
|
|
-from leapp.libraries.common.config.architecture import ARCH_S390X
|
|
-from leapp.libraries.common.testutils import logger_mocked, produce_mocked
|
|
+from leapp.libraries.common.config import architecture
|
|
+from leapp.libraries.common.testutils import CurrentActorMocked, logger_mocked, produce_mocked
|
|
from leapp.models import CopyFile, TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks
|
|
|
|
|
|
def test_dasd_exists(monkeypatch):
|
|
- monkeypatch.setattr(scandasd.architecture, 'matches_architecture', lambda dummy: True)
|
|
+ monkeypatch.setattr(scandasd.api, 'current_actor', CurrentActorMocked(arch=architecture.ARCH_S390X))
|
|
monkeypatch.setattr(scandasd.api, 'current_logger', logger_mocked())
|
|
monkeypatch.setattr(scandasd.api, 'produce', produce_mocked())
|
|
monkeypatch.setattr(os.path, 'isfile', lambda dummy: True)
|
|
scandasd.process()
|
|
- assert not scandasd.api.current_logger.warnmsg
|
|
+ assert not scandasd.api.current_logger.infomsg
|
|
assert scandasd.api.produce.called == 2
|
|
tusut_flag = False
|
|
uit_flag = False
|
|
@@ -30,12 +30,12 @@ def test_dasd_exists(monkeypatch):
|
|
|
|
|
|
def test_dasd_not_found(monkeypatch):
|
|
- monkeypatch.setattr(scandasd.architecture, 'matches_architecture', lambda dummy: True)
|
|
+ monkeypatch.setattr(scandasd.api, 'current_actor', CurrentActorMocked(arch=architecture.ARCH_S390X))
|
|
monkeypatch.setattr(scandasd.api, 'current_logger', logger_mocked())
|
|
monkeypatch.setattr(os.path, 'isfile', lambda dummy: False)
|
|
monkeypatch.setattr(scandasd.api, 'produce', produce_mocked())
|
|
scandasd.process()
|
|
- assert scandasd.api.current_logger.warnmsg
|
|
+ assert scandasd.api.current_logger.infomsg
|
|
assert scandasd.api.produce.called == 1
|
|
assert len(scandasd.api.produce.model_instances) == 1
|
|
assert isinstance(scandasd.api.produce.model_instances[0], TargetUserSpaceUpgradeTasks)
|
|
@@ -44,11 +44,16 @@ def test_dasd_not_found(monkeypatch):
|
|
|
|
|
|
@pytest.mark.parametrize('isfile', [True, False])
|
|
-def test_non_ibmz_arch(monkeypatch, isfile):
|
|
- monkeypatch.setattr(scandasd.architecture, 'matches_architecture', lambda dummy: False)
|
|
+@pytest.mark.parametrize('arch', [
|
|
+ architecture.ARCH_X86_64,
|
|
+ architecture.ARCH_ARM64,
|
|
+ architecture.ARCH_PPC64LE,
|
|
+])
|
|
+def test_non_ibmz_arch(monkeypatch, isfile, arch):
|
|
+ monkeypatch.setattr(scandasd.api, 'current_actor', CurrentActorMocked(arch=arch))
|
|
monkeypatch.setattr(scandasd.api, 'current_logger', logger_mocked())
|
|
monkeypatch.setattr(scandasd.api, 'produce', produce_mocked())
|
|
monkeypatch.setattr(os.path, 'isfile', lambda dummy: isfile)
|
|
scandasd.process()
|
|
- assert not scandasd.api.current_logger.warnmsg
|
|
+ assert not scandasd.api.current_logger.infomsg
|
|
assert not scandasd.api.produce.called
|
|
diff --git a/repos/system_upgrade/common/actors/scanzfcp/actor.py b/repos/system_upgrade/common/actors/scanzfcp/actor.py
|
|
new file mode 100644
|
|
index 00000000..9817fdc8
|
|
--- /dev/null
|
|
+++ b/repos/system_upgrade/common/actors/scanzfcp/actor.py
|
|
@@ -0,0 +1,24 @@
|
|
+
|
|
+from leapp.actors import Actor
|
|
+from leapp.libraries.actor import scanzfcp
|
|
+from leapp.models import TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks
|
|
+from leapp.tags import FactsPhaseTag, IPUWorkflowTag
|
|
+
|
|
+
|
|
+class ScanZFCP(Actor):
|
|
+ """
|
|
+ In case of s390x architecture, check whether ZFCP is used.
|
|
+
|
|
+ The current check is based just on existence of the /etc/zfcp.conf file.
|
|
+ If it exists, produce UpgradeInitramfsTasks msg to ensure the file
|
|
+ is available inside the target userspace to be able to generate the
|
|
+ upgrade init ramdisk correctly.
|
|
+ """
|
|
+
|
|
+ name = 'scanzfcp'
|
|
+ consumes = ()
|
|
+ produces = (TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks)
|
|
+ tags = (IPUWorkflowTag, FactsPhaseTag)
|
|
+
|
|
+ def process(self):
|
|
+ scanzfcp.process()
|
|
diff --git a/repos/system_upgrade/common/actors/scanzfcp/libraries/scanzfcp.py b/repos/system_upgrade/common/actors/scanzfcp/libraries/scanzfcp.py
|
|
new file mode 100644
|
|
index 00000000..72f83f8f
|
|
--- /dev/null
|
|
+++ b/repos/system_upgrade/common/actors/scanzfcp/libraries/scanzfcp.py
|
|
@@ -0,0 +1,25 @@
|
|
+import os
|
|
+
|
|
+from leapp.libraries.common.config import architecture
|
|
+from leapp.libraries.stdlib import api
|
|
+from leapp.models import CopyFile, TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks
|
|
+
|
|
+ZFCP_CONF = '/etc/zfcp.conf'
|
|
+
|
|
+
|
|
+def process():
|
|
+ if not architecture.matches_architecture(architecture.ARCH_S390X):
|
|
+ return
|
|
+ copy_files = []
|
|
+ if os.path.isfile(ZFCP_CONF):
|
|
+ # the file has to be copied into the targetuserspace container first,
|
|
+ # then it can be included into the initramfs ==> both messages are
|
|
+ # needed to be produced
|
|
+ copy_files = [CopyFile(src=ZFCP_CONF)]
|
|
+ api.produce(UpgradeInitramfsTasks(include_files=[ZFCP_CONF]))
|
|
+ else:
|
|
+ api.current_logger().info(
|
|
+ "The {} file has not been discovered. ZFCP not used."
|
|
+ .format(ZFCP_CONF)
|
|
+ )
|
|
+ api.produce(TargetUserSpaceUpgradeTasks(copy_files=copy_files, install_rpms=['s390utils-core']))
|
|
diff --git a/repos/system_upgrade/common/actors/scanzfcp/tests/unit_test_scanzfcp.py b/repos/system_upgrade/common/actors/scanzfcp/tests/unit_test_scanzfcp.py
|
|
new file mode 100644
|
|
index 00000000..1b1f840c
|
|
--- /dev/null
|
|
+++ b/repos/system_upgrade/common/actors/scanzfcp/tests/unit_test_scanzfcp.py
|
|
@@ -0,0 +1,59 @@
|
|
+import os
|
|
+
|
|
+import pytest
|
|
+
|
|
+from leapp.libraries.actor import scanzfcp
|
|
+from leapp.libraries.common.config import architecture
|
|
+from leapp.libraries.common.testutils import CurrentActorMocked, logger_mocked, produce_mocked
|
|
+from leapp.models import CopyFile, TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks
|
|
+
|
|
+
|
|
+def test_zfcp_exists(monkeypatch):
|
|
+ monkeypatch.setattr(scanzfcp.api, 'current_actor', CurrentActorMocked(arch=architecture.ARCH_S390X))
|
|
+ monkeypatch.setattr(scanzfcp.api, 'current_logger', logger_mocked())
|
|
+ monkeypatch.setattr(scanzfcp.api, 'produce', produce_mocked())
|
|
+ monkeypatch.setattr(os.path, 'isfile', lambda dummy: True)
|
|
+ scanzfcp.process()
|
|
+ assert not scanzfcp.api.current_logger.infomsg
|
|
+ assert scanzfcp.api.produce.called == 2
|
|
+ tusut_flag = False
|
|
+ uit_flag = False
|
|
+ for msg in scanzfcp.api.produce.model_instances:
|
|
+ if isinstance(msg, TargetUserSpaceUpgradeTasks):
|
|
+ assert [CopyFile(src=scanzfcp.ZFCP_CONF)] == msg.copy_files
|
|
+ assert msg.install_rpms == ['s390utils-core']
|
|
+ tusut_flag = True
|
|
+ elif isinstance(msg, UpgradeInitramfsTasks):
|
|
+ assert [scanzfcp.ZFCP_CONF] == msg.include_files
|
|
+ uit_flag = True
|
|
+ assert tusut_flag and uit_flag
|
|
+
|
|
+
|
|
+def test_zfcp_not_found(monkeypatch):
|
|
+ monkeypatch.setattr(scanzfcp.api, 'current_actor', CurrentActorMocked(arch=architecture.ARCH_S390X))
|
|
+ monkeypatch.setattr(scanzfcp.api, 'current_logger', logger_mocked())
|
|
+ monkeypatch.setattr(scanzfcp.os.path, 'isfile', lambda dummy: False)
|
|
+ monkeypatch.setattr(scanzfcp.api, 'produce', produce_mocked())
|
|
+ scanzfcp.process()
|
|
+ assert scanzfcp.api.current_logger.infomsg
|
|
+ assert scanzfcp.api.produce.called == 1
|
|
+ assert len(scanzfcp.api.produce.model_instances) == 1
|
|
+ assert isinstance(scanzfcp.api.produce.model_instances[0], TargetUserSpaceUpgradeTasks)
|
|
+ assert scanzfcp.api.produce.model_instances[0].install_rpms == ['s390utils-core']
|
|
+ assert not scanzfcp.api.produce.model_instances[0].copy_files
|
|
+
|
|
+
|
|
+@pytest.mark.parametrize('isfile', [True, False])
|
|
+@pytest.mark.parametrize('arch', [
|
|
+ architecture.ARCH_X86_64,
|
|
+ architecture.ARCH_ARM64,
|
|
+ architecture.ARCH_PPC64LE,
|
|
+])
|
|
+def test_non_ibmz_arch(monkeypatch, isfile, arch):
|
|
+ monkeypatch.setattr(scanzfcp.api, 'current_actor', CurrentActorMocked(arch=arch))
|
|
+ monkeypatch.setattr(scanzfcp.api, 'current_logger', logger_mocked())
|
|
+ monkeypatch.setattr(scanzfcp.api, 'produce', produce_mocked())
|
|
+ monkeypatch.setattr(os.path, 'isfile', lambda dummy: isfile)
|
|
+ scanzfcp.process()
|
|
+ assert not scanzfcp.api.current_logger.infomsg
|
|
+ assert not scanzfcp.api.produce.called
|
|
--
|
|
2.38.1
|
|
|