Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: crm_rpmcheck: use ansible to get package versions #1497

Merged
merged 1 commit into from
Jul 31, 2024

Conversation

aleksei-burlakov
Copy link
Contributor

@aleksei-burlakov aleksei-burlakov commented Jul 29, 2024

This PR introduces ansible and this change is just the right place. Instead of repeatedly calling rpm -q ... it calls ansible only once and gets all the package information.

Copy link

codecov bot commented Jul 29, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.55%. Comparing base (3e96f90) to head (3538203).
Report is 38 commits behind head on master.

Additional details and impacted files
Flag Coverage Δ
integration 54.25% <ø> (+0.32%) ⬆️
unit 52.47% <ø> (+0.12%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

see 19 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -23,6 +23,11 @@ def package_data(pkg):
"""
Gathers version and release information about a package.
"""
if os.path.isfile('/bin/ansible'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use shutil.which instead, as it works better with environ PATH and also checks for 'x' permission.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My idea was to make the code uniform. So that it looked like the rest. Like
if os.path.isfile('/bin/rpm'):
and
if os.path.isfile('/usr/bin/dpkg'):
look all the same.
I could use the shutil.which indeed, but that would logically require refactoring the /bin/rpm and /bin/dpkg cases.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a good time to refactor them.

@@ -31,6 +36,37 @@ def package_data(pkg):

return {'name': pkg, 'error': "unknown package manager"}

packages = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Private variables, which is not intended to be accessed directly from other modules, should start with _.

Copy link
Collaborator

@liangxin1300 liangxin1300 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@liangxin1300 liangxin1300 merged commit ae058b0 into ClusterLabs:master Jul 31, 2024
31 checks passed
aleksei-burlakov added a commit that referenced this pull request Aug 6, 2024
This PR continues the #1497 . Additionally to the package information it is
also the system information that read from ansible.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants