Skip to content

Commit

Permalink
Add leapp pkgs rpm verification into the breadcrumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
Rezney authored and pirat89 committed Feb 22, 2023
1 parent 21b592a commit 096c3a9
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions commands/upgrade/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(self, activity):
self._crumbs = {
'activity': activity,
'packages': self._get_packages(),
'leapp_file_changes': [],
'executed': ' '.join([v if ' ' not in v else '"{}"'.format(v) for v in sys.argv]),
'success': True,
'activity_started': datetime.datetime.utcnow().isoformat() + 'Z',
Expand Down Expand Up @@ -86,6 +87,7 @@ def _commit_rhsm_facts(self):

def save(self):
self._crumbs['run_id'] = os.environ.get('LEAPP_EXECUTION_ID', 'N/A')
self._crumbs['leapp_file_changes'].extend(self._verify_leapp_pkgs())
messages = get_messages(('IPUConfig',), self._crumbs['run_id'])
versions = json.loads((messages or [{}])[0].get('message', {}).get(
'data', '{}')).get('version', {'target': 'N/A', 'source': 'N/A'})
Expand Down Expand Up @@ -124,6 +126,16 @@ def _get_packages(self):
for t in [line.strip().split(' ', 1) for line in res['stdout'].split('\n') if line.strip()]]
return []

def _verify_leapp_pkgs(self):
upg_path = os.environ.get('LEAPP_IPU_IN_PROGRESS').split('to')
cmd = ['/bin/bash', '-c', 'rpm -V leapp leapp-upgrade-el{}toel{}'.format(upg_path[0], upg_path[1])]
res = _call(cmd, lambda x, y: None, lambda x, y: None)
if res.get('exit_code', None) == 1:
if res.get('stdout', None):
return [{'result': t[0], 'file_name': t[1]}
for t in [line.strip().split(' ', 1) for line in res['stdout'].split('\n') if line.strip()]]
return []


def produces_breadcrumbs(f):
"""
Expand Down

0 comments on commit 096c3a9

Please sign in to comment.