Last active
November 6, 2023 12:58
-
-
Save abadger/2f04378c477dc3af20c47f4f3bbe5a31 to your computer and use it in GitHub Desktop.
Early code for Actor-side implementation of configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/actor.py b/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/actor.py | |
index 4ef726f5..e85240be 100644 | |
--- a/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/actor.py | |
+++ b/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/actor.py | |
@@ -6,6 +6,94 @@ from leapp.tags import FactsPhaseTag, IPUWorkflowTag | |
CONFIGURATION_BASE_PATH = '/etc/leapp/transaction' | |
+import abc | |
+import six | |
+ | |
+try: import yaml | |
+from leapp.fields import List, | |
+ | |
+ | |
+ | |
+""" | |
+Example config file, can be generated programmatically: | |
+ | |
+transaction: | |
+ to_install_description__: | | |
+ List of packages to be added to the upgrade transaction. | |
+ Signed packages which are already installed will be skipped. | |
+ to_remove_description__: | | |
+ List of packages to be removed from the upgrade transaction | |
+ initial-setup should be removed to avoid it asking for EULA acceptance during upgrade | |
+ to_remove: | |
+ - initial-setup | |
+ to_keep_description__: | | |
+ List of packages to be kept in the upgrade transaction | |
+ to_keep: | |
+ - leapp | |
+ - python2-leapp | |
+ - python3-leapp | |
+ - leapp-repository | |
+ - snactor | |
+""" | |
[email protected]_metaclass(abc.ABCMeta) | |
+class Config: | |
+ @abc.abstractproperty | |
+ def section(): | |
+ pass | |
+ | |
+ @abc.abstractproperty | |
+ def name(): | |
+ pass | |
+ | |
+ @abc.abstractproperty | |
+ def type_(): | |
+ pass | |
+ | |
+ @abc.abstractproperty | |
+ def description(): | |
+ pass | |
+ | |
+ | |
+### Nested containers? | |
+### Duplication of default value in type_ and Config. If we eliminate that, we need to extract default from the type_ for the documentation. | |
+class Transaction_ToInstall(Config): | |
+ section = "transaction" | |
+ name = "to_install" | |
+ type_ = fields.List(fields.String(), default=[]) | |
+ default = [] | |
+ description = """ | |
+ List of packages to be added to the upgrade transaction. | |
+ Signed packages which are already installed will be skipped. | |
+ """ | |
+ | |
+ | |
+class Transaction_ToKeep(Config): | |
+ section = "transaction" | |
+ name = "to_keep" | |
+ type_ = fields.List(fields.String(), default=[ | |
+ "leapp", | |
+ "python2-leapp", | |
+ "python3-leapp", | |
+ "leapp-repository", | |
+ "snactor", | |
+ ]) | |
+ description = """ | |
+ List of packages to be kept in the upgrade transaction. | |
+ """ | |
+ | |
+ | |
+class Transaction_ToRemove(Config): | |
+ section = "transaction" | |
+ name = "to_remove" | |
+ type_ = fields.List(fields.String(), default=[ | |
+ "initial-setup", | |
+ ]) | |
+ description = """ | |
+ List of packages to be removed from the upgrade transaction. | |
+ initial-setup should be removed to avoid it asking for EULA acceptance during upgrade. | |
+ """ | |
+ | |
+ | |
class RpmTransactionConfigTasksCollector(Actor): | |
""" | |
Provides additional RPM transaction tasks from /etc/leapp/transaction. | |
@@ -13,11 +101,11 @@ class RpmTransactionConfigTasksCollector(Actor): | |
After collecting task data from /etc/leapp/transaction directory, a message with relevant data | |
will be produced. | |
""" | |
- | |
+ configs = (Transaction_ToInstall, Transaction_ToKeep, Transation_ToRemove) | |
name = 'rpm_transaction_config_tasks_collector' | |
consumes = (InstalledRedHatSignedRPM,) | |
produces = (RpmTransactionTasks,) | |
tags = (FactsPhaseTag, IPUWorkflowTag) | |
def process(self): | |
- self.produce(load_tasks(CONFIGURATION_BASE_PATH, self.log)) | |
+ self.produce(load_tasks(self.config, self.log)) | |
diff --git a/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/libraries/rpmtransactionconfigtaskscollector.py b/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/libraries/rpmtransactionconfigtaskscollector.py | |
index fb6ae8ff..4c37b709 100644 | |
--- a/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/libraries/rpmtransactionconfigtaskscollector.py | |
+++ b/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/libraries/rpmtransactionconfigtaskscollector.py | |
@@ -18,11 +18,11 @@ def load_tasks_file(path, logger): | |
return [] | |
-def load_tasks(base_dir, logger): | |
+def load_tasks(config, logger): | |
# Loads configuration files to_install, to_keep, and to_remove from the given base directory | |
rpms = next(api.consume(InstalledRedHatSignedRPM)) | |
rpm_names = [rpm.name for rpm in rpms.items] | |
- to_install = load_tasks_file(os.path.join(base_dir, 'to_install'), logger) | |
+ to_install = config['transaction']['to_install'] | |
# we do not want to put into rpm transaction what is already installed (it will go to "to_upgrade" bucket) | |
to_install_filtered = [pkg for pkg in to_install if pkg not in rpm_names] | |
@@ -34,5 +34,5 @@ def load_tasks(base_dir, logger): | |
return RpmTransactionTasks( | |
to_install=to_install_filtered, | |
- to_keep=load_tasks_file(os.path.join(base_dir, 'to_keep'), logger), | |
- to_remove=load_tasks_file(os.path.join(base_dir, 'to_remove'), logger)) | |
+ to_keep=config['transaction']['to_keep'], | |
+ to_remove=config['transaction']['to_remove']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment