This is an overview of the Actions framework that appears in the 1.3.0 version of convert2rhel. Actions are a more modular way to write checks and revertable changes for convert2rhel. We're using them to implement a pre-conversion report.
This may be interesting for those who are working on convert2rhel or anyone who is interested in writing their own plugin framework.
6. 05/08/2023 6
Writing New Actions: File Layout
●
Python modules live in convert2rhel/actions/{stage}/{action}.py
7. 05/08/2023 7
Writing New Actions: File Layout
●
Python modules live in convert2rhel/actions/{stage}/{action}.py
●
All Actions in a stage run before the next stage
8. 05/08/2023 8
Writing New Actions: File Layout
●
Python modules live in convert2rhel/actions/{stage}/{action}.py
●
All Actions in a stage run before the next stage
●
Currently two stages:
●
system_checks
●
pre_ponr_changes
11. 05/08/2023 11
Writing New Actions: Code Structure
●
Each Action is a class in a module
●
Must contain subclasses of convert2rhel.actions.Action
●
Must set a unique id
●
Must implement a run() method
●
Should call super().__init__()
●
Should log a task header with logger.task()
●
Default result is success. Specify a different result with set_result()
followed by return
12.
13.
14.
15.
16.
17. 05/08/2023 17
Writing New Actions: Code Structure
●
Each Action is a class in a module
●
Must contain subclasses of convert2rhel.actions.Action
●
Must set a unique id
●
Must implement a run() method
●
Should call super().__init__()
●
Should log a task header with logger.task()
●
Default result is success. Specify a different result with set_result()
followed by return
18. 05/08/2023 18
Writing New Actions: Code Structure
●
Each Action is a class in a module
●
Must contain subclasses of convert2rhel.actions.Action
●
Must set a unique id
●
Must implement a run() method
●
Should call super().__init__()
●
Should log a task header with logger.task()
●
Default result is success. Specify a different result with set_result()
followed by return
●
Dependencies
19.
20.
21. 05/08/2023 21
Writing New Actions: Code Structure
●
Each Action is a class in a module
●
Must contain subclasses of convert2rhel.actions.Action
●
Must set a unique id
●
Must implement a run() method
●
Should call super().__init__()
●
Should log a task header with logger.task()
●
Default result is success. Specify a different result with set_result()
followed by return
●
Dependencies
35. 05/08/2023 35
A brief word on Stages
●
Discover the Actions in this Stage
●
Figure out the dependency order of Actions
●
Run the Actions
36. 05/08/2023 36
A brief word on Stages
●
Discover the Actions in this Stage
●
Stage("system_checks", "Check whether system is ready for
conversion", pre_ponr_changes)
●
Helper function, get_actions()
●
All subclasses of convert2rhel.actions.Action...
●
… inside of a specific subdirectory of convert2rhel/actions
●
Knows about Stages that come afterwards
●
Figure out the dependency order of Actions
●
Run the Actions
37. 05/08/2023 37
A brief word on Stages
●
Discover the Actions in this Stage
●
Figure out the dependency order of Actions
●
Helper function resolve_action_order()
●
Used for both Stage.check_dependencies() and Stage.run()
●
Knows about all Stages which come afterwards
●
Run the Actions
38. 05/08/2023 38
A brief word on Stages
●
Discover the Actions in this Stage
●
Figure out the dependency order of Actions
●
Run the Actions
●
Run in order
●
Record failures
●
Skip tests whose dependencies have failed
●
Catch unhandled exceptions with a generic Error.
44. 05/08/2023 44
The Report
●
convert2rhel.actions.report.summary()
●
All data is in the results
●
Formats the data
●
Can filter out successes
●
Colorizes
●
Indents
●
Sorts by severity
●
Future:
●
Add Warnings and other messages to the report
●
A json version of the report for other programs to consume
45. 05/08/2023 45
People and places
●
Pull Request:
●
https://github.com/oamg/convert2rhel/pull/761
●
Preston and Rodolfo: Writing Actions
●
Rodolfo: Report
●
Toshio: Dependencies, Stages, and the Framework in general