forked from rpms/leapp-repository
214 lines
9.0 KiB
Diff
214 lines
9.0 KiB
Diff
From 57dce775de28615260189a6612fe65e44a7d3bc9 Mon Sep 17 00:00:00 2001
|
|
From: Michal Hecko <mhecko@redhat.com>
|
|
Date: Sat, 29 Mar 2025 21:41:48 +0100
|
|
Subject: [PATCH 15/37] feat(ipuconfig): provide info about supported upgrade
|
|
paths
|
|
|
|
At the moment, information about supported upgrade paths is provided via
|
|
a deprecated IPUPaths message. The current solution is temporary.
|
|
This patch introduces new field in IPUConfig called
|
|
'supported_upgrade_paths' that contains a "compressed", pre-filtered,
|
|
list of upgrade paths. The decision to introduce this new field is
|
|
because we want to refactor the config.version library to not contain
|
|
its own supported upgrade paths definitions. Instead, we want to have the
|
|
information represented only once. Therefore, in order to refactor
|
|
config.version to use the information received by a message, we need
|
|
the new field on IPUConfig as we cannot force already-written actors
|
|
using config.version to add some message to their 'consumes' list.
|
|
|
|
Jira-ref: RHEL-80550
|
|
---
|
|
.../libraries/ipuworkflowconfig.py | 28 ++++++++++++++++++-
|
|
.../common/libraries/config/mock_configs.py | 14 +++++++++-
|
|
.../common/libraries/testutils.py | 20 +++++++++----
|
|
.../system_upgrade/common/models/ipuconfig.py | 22 +++++++++++++++
|
|
4 files changed, 77 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
|
|
index 749b3347..86df709e 100644
|
|
--- a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
|
|
+++ b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
|
|
@@ -85,6 +85,27 @@ def check_target_major_version(curr_version, target_version):
|
|
)
|
|
|
|
|
|
+def load_raw_upgrade_paths_for_flavour(flavour='default', paths_definition_file='upgrade_paths.json'):
|
|
+ with open(api.get_common_file_path(paths_definition_file)) as fp:
|
|
+ data = json.loads(fp.read())
|
|
+
|
|
+ raw_upgrade_paths = data.get(flavour, {})
|
|
+
|
|
+ if not raw_upgrade_paths:
|
|
+ api.current_logger().warning('Cannot discover any upgrade paths for flavour: {}'.format(flavour))
|
|
+
|
|
+ return raw_upgrade_paths
|
|
+
|
|
+
|
|
+def construct_models_for_paths_matching_source_major(raw_paths, src_major_version):
|
|
+ multipaths_matching_source = []
|
|
+ for src_version, target_versions in ipu_paths.items():
|
|
+ if src_version.split('.')[0] == src_major_version:
|
|
+ source_to_targets = IPUSourceToPossibleTargets(source_version=src_version, target_versions=target_versions)
|
|
+ multipaths_matching_source.append()
|
|
+ return multipaths_matching_source
|
|
+
|
|
+
|
|
def produce_ipu_config(actor):
|
|
flavour = os.environ.get('LEAPP_UPGRADE_PATH_FLAVOUR')
|
|
target_version = os.environ.get('LEAPP_UPGRADE_PATH_TARGET_RELEASE')
|
|
@@ -93,6 +114,10 @@ def produce_ipu_config(actor):
|
|
|
|
check_target_major_version(source_version, target_version)
|
|
|
|
+ raw_upgrade_paths = load_raw_upgrade_paths_for_flavour(flavour)
|
|
+ source_major_version = source_version.split('.')[0]
|
|
+ exposed_supported_paths = construct_models_for_paths_matching_source_major(raw_upgrade_paths, source_major_version)
|
|
+
|
|
actor.produce(IPUConfig(
|
|
leapp_env_vars=get_env_vars(),
|
|
os_release=os_release,
|
|
@@ -102,5 +127,6 @@ def produce_ipu_config(actor):
|
|
target=target_version
|
|
),
|
|
kernel=get_booted_kernel(),
|
|
- flavour=flavour
|
|
+ flavour=flavour,
|
|
+ supported_upgrade_paths=exposed_supported_paths
|
|
))
|
|
diff --git a/repos/system_upgrade/common/libraries/config/mock_configs.py b/repos/system_upgrade/common/libraries/config/mock_configs.py
|
|
index ee9dd760..a1c9c0fd 100644
|
|
--- a/repos/system_upgrade/common/libraries/config/mock_configs.py
|
|
+++ b/repos/system_upgrade/common/libraries/config/mock_configs.py
|
|
@@ -6,7 +6,7 @@ The library is supposed to be used only for testing purposes. Import of the
|
|
library is expected only inside test files.
|
|
"""
|
|
|
|
-from leapp.models import EnvVar, IPUConfig, OSRelease, Version
|
|
+from leapp.models import EnvVar, IPUConfig, IPUSourceToPossibleTargets, OSRelease, Version
|
|
|
|
CONFIG = IPUConfig(
|
|
leapp_env_vars=[EnvVar(name='LEAPP_DEVEL', value='0')],
|
|
@@ -23,6 +23,9 @@ CONFIG = IPUConfig(
|
|
),
|
|
architecture='x86_64',
|
|
kernel='3.10.0-957.43.1.el7.x86_64',
|
|
+ supported_upgrade_paths=[
|
|
+ IPUSourceToPossibleTargets(source_version='7.6', target_versions=['8.0'])
|
|
+ ]
|
|
)
|
|
|
|
CONFIG_NO_NETWORK_RENAMING = IPUConfig(
|
|
@@ -40,6 +43,9 @@ CONFIG_NO_NETWORK_RENAMING = IPUConfig(
|
|
),
|
|
architecture='x86_64',
|
|
kernel='3.10.0-957.43.1.el7.x86_64',
|
|
+ supported_upgrade_paths=[
|
|
+ IPUSourceToPossibleTargets(source_version='7.6', target_versions=['8.0'])
|
|
+ ]
|
|
)
|
|
|
|
CONFIG_ALL_SIGNED = IPUConfig(
|
|
@@ -57,6 +63,9 @@ CONFIG_ALL_SIGNED = IPUConfig(
|
|
),
|
|
architecture='x86_64',
|
|
kernel='3.10.0-957.43.1.el7.x86_64',
|
|
+ supported_upgrade_paths=[
|
|
+ IPUSourceToPossibleTargets(source_version='7.6', target_versions=['8.0'])
|
|
+ ]
|
|
)
|
|
|
|
CONFIG_S390X = IPUConfig(
|
|
@@ -73,4 +82,7 @@ CONFIG_S390X = IPUConfig(
|
|
),
|
|
architecture='s390x',
|
|
kernel='3.10.0-957.43.1.el7.x86_64',
|
|
+ supported_upgrade_paths=[
|
|
+ IPUSourceToPossibleTargets(source_version='7.6', target_versions=['8.0'])
|
|
+ ]
|
|
)
|
|
diff --git a/repos/system_upgrade/common/libraries/testutils.py b/repos/system_upgrade/common/libraries/testutils.py
|
|
index afeb360a..1b3c3683 100644
|
|
--- a/repos/system_upgrade/common/libraries/testutils.py
|
|
+++ b/repos/system_upgrade/common/libraries/testutils.py
|
|
@@ -6,7 +6,7 @@ from collections import namedtuple
|
|
from leapp import reporting
|
|
from leapp.actors.config import _normalize_config, normalize_schemas
|
|
from leapp.libraries.common.config import architecture
|
|
-from leapp.models import EnvVar
|
|
+from leapp.models import EnvVar, IPUSourceToPossibleTargets
|
|
from leapp.utils.deprecation import deprecated
|
|
|
|
|
|
@@ -76,7 +76,11 @@ def _make_default_config(actor_config_schema):
|
|
|
|
class CurrentActorMocked(object): # pylint:disable=R0904
|
|
def __init__(self, arch=architecture.ARCH_X86_64, envars=None, kernel='3.10.0-957.43.1.el7.x86_64',
|
|
- release_id='rhel', src_ver='7.8', dst_ver='8.1', msgs=None, flavour='default', config=None):
|
|
+ release_id='rhel', src_ver='7.8', dst_ver='8.1', msgs=None, flavour='default', config=None,
|
|
+ supported_upgrade_paths=None):
|
|
+ """
|
|
+ :param List[IPUSourceToPossibleTargets] supported_upgrade_paths: List of supported upgrade paths.
|
|
+ """
|
|
envarsList = [EnvVar(name=k, value=v) for k, v in envars.items()] if envars else []
|
|
version = namedtuple('Version', ['source', 'target'])(src_ver, dst_ver)
|
|
release = namedtuple('OS_release', ['release_id', 'version_id'])(release_id, src_ver)
|
|
@@ -85,9 +89,15 @@ class CurrentActorMocked(object): # pylint:disable=R0904
|
|
self._common_tools_folder = '../../tools'
|
|
self._actor_folder = 'files'
|
|
self._actor_tools_folder = 'tools'
|
|
- self.configuration = namedtuple(
|
|
- 'configuration', ['architecture', 'kernel', 'leapp_env_vars', 'os_release', 'version', 'flavour']
|
|
- )(arch, kernel, envarsList, release, version, flavour)
|
|
+
|
|
+ if not supported_upgrade_paths:
|
|
+ supported_upgrade_paths = [IPUSourceToPossibleTargets(source_version=src_ver, target_versions=[dst_ver])]
|
|
+
|
|
+ ipu_conf_fields = ['architecture', 'kernel', 'leapp_env_vars', 'os_release',
|
|
+ 'version', 'flavour', 'supported_upgrade_paths']
|
|
+ config_type = namedtuple('configuration', ipu_conf_fields)
|
|
+ self.configuration = config_type(arch, kernel, envarsList, release, version, flavour, supported_upgrade_paths)
|
|
+
|
|
self._msgs = msgs or []
|
|
self.config = {} if config is None else config
|
|
|
|
diff --git a/repos/system_upgrade/common/models/ipuconfig.py b/repos/system_upgrade/common/models/ipuconfig.py
|
|
index 6e7e21b5..0a16b603 100644
|
|
--- a/repos/system_upgrade/common/models/ipuconfig.py
|
|
+++ b/repos/system_upgrade/common/models/ipuconfig.py
|
|
@@ -34,6 +34,21 @@ class Version(Model):
|
|
"""Version of the target system. E.g. '8.2.'."""
|
|
|
|
|
|
+class IPUSourceToPossibleTargets(Model):
|
|
+ """
|
|
+ Represents upgrade paths from a source system version.
|
|
+
|
|
+ This model is not supposed to be produced nor consumed directly by any actor.
|
|
+ """
|
|
+ topic = SystemInfoTopic
|
|
+
|
|
+ source_version = fields.String()
|
|
+ """Source system version."""
|
|
+
|
|
+ target_versions = fields.List(fields.String())
|
|
+ """List of defined target system versions for the `source_version` system."""
|
|
+
|
|
+
|
|
class IPUConfig(Model):
|
|
"""
|
|
IPU workflow configuration model
|
|
@@ -59,3 +74,10 @@ class IPUConfig(Model):
|
|
|
|
flavour = fields.StringEnum(('default', 'saphana'), default='default')
|
|
"""Flavour of the upgrade - Used to influence changes in supported source/target release"""
|
|
+
|
|
+ supported_upgrade_paths = fields.List(fields.Model(IPUSourceToPossibleTargets))
|
|
+ """
|
|
+ List of supported upgrade paths.
|
|
+
|
|
+ The list contains only upgrade paths for the `flavour` of the source system.
|
|
+ """
|
|
--
|
|
2.49.0
|
|
|