-
Notifications
You must be signed in to change notification settings - Fork 94
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
Dev: crm_rpmcheck: use ansible to get package versions #1497
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
675dffc
to
01fb54e
Compare
utils/crm_rpmcheck.py
Outdated
@@ -23,6 +23,11 @@ def package_data(pkg): | |||
""" | |||
Gathers version and release information about a package. | |||
""" | |||
if os.path.isfile('/bin/ansible'): |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
utils/crm_rpmcheck.py
Outdated
@@ -31,6 +36,37 @@ def package_data(pkg): | |||
|
|||
return {'name': pkg, 'error': "unknown package manager"} | |||
|
|||
packages = None |
There was a problem hiding this comment.
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 _
.
01fb54e
to
3538203
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This PR continues the #1497 . Additionally to the package information it is also the system information that read from ansible.
This PR introduces
ansible
and this change is just the right place. Instead of repeatedly callingrpm -q ...
it calls ansible only once and gets all the package information.