Skip to content

Instantly share code, notes, and snippets.

View abadger's full-sized avatar

Toshio Kuratomi abadger

View GitHub Profile
abadger / gist:2f04378c477dc3af20c47f4f3bbe5a31
Last active November 6, 2023 12:58
Early code for Actor-side implementation of configs
View gist:2f04378c477dc3af20c47f4f3bbe5a31
diff --git a/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/ b/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/
index 4ef726f5..e85240be 100644
--- a/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/
+++ b/repos/system_upgrade/common/actors/rpmtransactionconfigtaskscollector/
@@ -6,6 +6,94 @@ from leapp.tags import FactsPhaseTag, IPUWorkflowTag
CONFIGURATION_BASE_PATH = '/etc/leapp/transaction'
+import abc
+import six
View gist:15ebd7845a3f21c9a3e7a7d7de7c36b7
"Not a NEVRA that we was not filtered due to a bug",
abadger / gist:68e4ed8d44494df9ed9a2473d5f77da2
Created September 6, 2023 18:41
Front end format for MVP (script
View gist:68e4ed8d44494df9ed9a2473d5f77da2
The problem (as you pointed out earlier) is that you really want to apply one or more
transformations to the raw data to make it easier for the front end to work with it. I knew that
we would need to transform the results but there was a miscommunication about where that
transformation would occur. We thought it would be done somewhere after the data was passed back
from the client and the front end folks thought it would occur somewhere before they got it and no
one checked with the folks in the middle to make sure they understood that the only place left for
the transformation was in their code. Transformations that I know are needed:
* For each message, our unique key is a combination of the action's id (an action is one discrete
test or action that we can verify works prior to committing to going through with a conversion)
View gist:43e8ea04bbbcddbccecfc7e2abbaab63
Some thoughts on the design of the framework:
We need to have separate returns for final results (SUCCESS, FAILURE, and SKIP) because there must be one and only one of those after run() finishes.
final result messages should be a list so that adding multiple messages to SUCCESS can be nicely formatted.
WARNING, and other things messages that can have multiple should be stored in a new list attribute on the Action class.
When evaluating logger.warning and, decide whether to set it as a SUCCESS messages or WARNING message. success messages will not be shown in convresion, only in analyze. warning messages will be shown in both.
add_result() should be renamed since we want results to be final results only. Maybe add_message()?
View gist:35680972b9f55c8bebd902975bc19a62
diff --git a/convert2rhel/actions/pre_ponr_changes/ b/convert2rhel/actions/pre_ponr_changes/
index ad4ce58..a46b93f 100644
--- a/convert2rhel/actions/pre_ponr_changes/
+++ b/convert2rhel/actions/pre_ponr_changes/
@@ -17,7 +17,7 @@ __metaclass__ = type
import logging
-from convert2rhel import actions, pkghandler
+from convert2rhel import actions, pkghandler, utils
View gist:1563baa9979aa93445e16473416980ec
[03/31/2023 18:17:22] TASK - [Conversion analysis report] ***************************************
(ERROR) RHEL_COMPATIBLE_KERNEL.BOOTED_KERNEL_INCOMPATIBLE: The booted kernel version is incompatible with the standard RHEL kernel. To proceed with the conversion, boot into a kernel that is available in the Oracle Linux Server 8 base repository by executing the following steps:
1. Ensure that the Oracle Linux Server 8 base repository is enabled
2. Run: yum install kernel
3. (optional) Run: grubby --set-default /boot/vmlinuz-`rpm -q --qf "%{BUILDTIME}\t%{EVR}.%{ARCH}\n" kernel | sort -nr | head -1 | cut -f2`
4. Reboot the machine and if step 3 was not applied choose the kernel installed in step 2 manually
(ERROR) PRE_SUBSCRIPTION.UNKNOWN_ERROR: Failed to install subscription-manager packages. See the above yum output for details.
(SKIP) SUBSCRIBE_SYSTEM.SKIP: Skipped because PRE_SUBSCRIPTION was not successful
abadger /
Created March 22, 2023 17:24
pseudo-python code to add a default subcommand
--#!/usr/bin/python -tt # W: Missing module docstring
import argparse
import sys
global_options = argparse.ArgumentParser()
global_options.add_argument('--debug', action='store_true')
global_option_names = frozenset(('--debug', '-d', 'convert', 'analyze'))
abadger /
Last active March 15, 2023 18:34
Have catchalls reraise KeyboardInterrupt
# Not needed as long as we do not catch BaseException later on
# except KeyboardInterrupt:
# raise
except KnownError:
self.set_result("NICE_ERROR_CODE", "ERROR", "Nice error message")
except (Exception, SystemExit) as e:
self.set_result("UNKNOWN_ERROR", "ERROR", "Unknown Error was returned: %s" % e)
abadger / gist:238eca60f1664e4fbf91f6285d54f6a5
Created March 14, 2023 20:12
How to write a unittest fixture
View gist:238eca60f1664e4fbf91f6285d54f6a5
diff --git a/convert2rhel/unit_tests/actions/ b/convert2rhel/unit_tests/actions/
index 8dbac8a..0716164 100644
--- a/convert2rhel/unit_tests/actions/
+++ b/convert2rhel/unit_tests/actions/
@@ -584,6 +584,9 @@ def _gen_version(major, minor):
class TestEFIChecks(unittest.TestCase):
+ def setUp(self):
+ self.efi_check = actions.efi_check.EfiCheck()
abadger /
Last active March 6, 2023 18:22
How to write a unittest that ignores a decorator
# let's say we have a function "testing" which is decorated by "my_decorator"
import functools
def my_decorator(func):
def wrapped(*args, **kwargs):
print("In real decorator")