Skip to content

Instantly share code, notes, and snippets.

View abadger's full-sized avatar

Toshio Kuratomi abadger

View GitHub Profile
@abadger
abadger / attribute-string-literal-parser.py
Created August 20, 2024 18:22
Parsing "docstrings" for class attributes.
#!/usr/bin/python3 -tt
import ast
import inspect
# Define the classes from your code
class MyField():
"""
That's my field
type_ = fields.List(
fields.Map(
values=fields.Map(
fields.KeyValue(key="name", value=fields.String)
)
)
)
### another layer of abstraction
DracutModule = fields.Map(
@abadger
abadger / gist:33c474f2b3da1d336a4790921050f9d2
Last active May 6, 2024 16:45
Deriving from an environment var from another github action var
env:
BASE_EE_VERSION: ${{ ANSIBLE_CORE_VERSION }}-${{ EE_VERSION }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Set derived variables
run: |
@abadger
abadger / gist:2f04378c477dc3af20c47f4f3bbe5a31
Last active November 6, 2023 12:58
Early code for Actor-side implementation of configs
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
@pytest.mark.parametrize(
("bad_output_from_extract",),
(
[
[
"convert2rhel-0:0.18.0-1.el7.noarch",
"Not a NEVRA that we was not filtered due to a bug",
"convert2rhel-0:0.20.0-1.el7.noarch",
],
],
@abadger
abadger / gist:68e4ed8d44494df9ed9a2473d5f77da2
Created September 6, 2023 18:41
Front end format for MVP (script
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)
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 logger.info, 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()?
diff --git a/convert2rhel/actions/pre_ponr_changes/handle_packages.py b/convert2rhel/actions/pre_ponr_changes/handle_packages.py
index ad4ce58..a46b93f 100644
--- a/convert2rhel/actions/pre_ponr_changes/handle_packages.py
+++ b/convert2rhel/actions/pre_ponr_changes/handle_packages.py
@@ -17,7 +17,7 @@ __metaclass__ = type
import logging
-from convert2rhel import actions, pkghandler
+from convert2rhel import actions, pkghandler, utils
[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
(SKIP) ENSURE_KERNEL_MODULES_COMPATIBILITY.SKIP: Skipped because SUBSCRIBE_SYSTEM was not successful
@abadger
abadger / subcommand.py
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'))