-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WIP] [DEBUG] POC of custom modifications tracking
Please do NOT review until marked as ready. All custom modifications ideas will be put there.
- Loading branch information
1 parent
64ec2ec
commit 1dbd49f
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
repos/system_upgrade/common/actors/trackcustommodifications/actor.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from leapp.actors import Actor | ||
from leapp.libraries.actor.trackcustommodifications import check_for_modifications | ||
from leapp.models import CustomModifications | ||
from leapp.reporting import Report | ||
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag | ||
|
||
|
||
class TrackCustomModificationsActor(Actor): | ||
""" | ||
Collects information about files in leapp directories that have been modified or newly added. | ||
""" | ||
|
||
name = 'track_custom_modifications_actor' | ||
produces = (CustomModifications, Report) | ||
tags = (IPUWorkflowTag, ChecksPhaseTag) | ||
|
||
def process(self): | ||
check_for_modifications() |
38 changes: 38 additions & 0 deletions
38
...stem_upgrade/common/actors/trackcustommodifications/libraries/trackcustommodifications.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import os | ||
|
||
from leapp.libraries.common.config.version import get_source_major_version, get_target_major_version | ||
from leapp.libraries.stdlib import api, CalledProcessError, run | ||
from leapp.models import CustomModifications | ||
|
||
|
||
RPMS_TO_CHECK = ['leapp-upgrade-el{}toel{}'.format(get_source_major_version(), get_target_major_version())] | ||
DIRS_TO_SCAN = ['/usr/share/leapp-repository'] | ||
|
||
|
||
def check_for_modifications(dirs=DIRS_TO_SCAN, rpms=RPMS_TO_CHECK): | ||
""" | ||
This will return a tuple (changes, custom) is case any untypical files or changes to shipped leapp files are | ||
discovered. | ||
(None, None) means that no modifications have been found. | ||
""" | ||
source_of_truth = [] | ||
for rpm in RPMS_TO_CHECK: | ||
get_rpm_files_command = ['rpm', '-ql', rpm] | ||
try: | ||
rpm_files = run(get_rpm_files_command) | ||
source_of_truth.append(rpm_files['stdout'].strip().split()) | ||
except CalledProcessError: | ||
api.current_logger().warning( | ||
'Could not get list of installed files from rpm %s'.format(rpm) | ||
) | ||
raise StopActorExecution() | ||
leapp_files = [] | ||
for directory in dirs: | ||
get_files_command = ['find', directory, '-type', 'f'] | ||
try: | ||
except CalledProcessError: | ||
api.current_logger().warning( | ||
'Could not get list of leapp files in %s'.format(directory) | ||
) | ||
raise StopActorExecution() | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from leapp.models import fields, Model | ||
from leapp.topics import SystemFactsTopic | ||
|
||
|
||
class CustomModifications(Model): | ||
"""Model to store any custom\changed files that are discovered in leapp directories""" | ||
topic = SystemFactsTopic | ||
|
||
filename = fields.String() | ||
actor_name = fields.String() |