community.general
community.general copied to clipboard
Implement usb_facts module
SUMMARY
Implements a module for retrieving information about connected usb devices.
ISSUE TYPE
- New Module/Plugin Pull Request
COMPONENT NAME
usb_facts
ADDITIONAL INFORMATION
So far, obtaining information about usb devices was only possible by running lsusb as command and parsing its output. This module implements exactly that and returns information regarding connected usb devices as data structure.
More information about usb devices could be made available by increasing the verbosity of lsusb and parsing that, but just this should be sufficient for most use cases.
Two test cases for the parsing of a single lsusb output and multiple at once are included.
The test ansible-test sanity --test pylint [explain] failed with 2 errors:
tests/unit/plugins/modules/test_usb_facts.py:101:111: trailing-whitespace: Trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:0: missing-final-newline: Final newline missing
The test ansible-test sanity --test pep8 [explain] failed with 9 errors:
tests/unit/plugins/modules/test_usb_facts.py:16:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:21:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:52:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:56:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:57:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:58:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:82:38: E211: whitespace before '['
tests/unit/plugins/modules/test_usb_facts.py:101:112: W291: trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:77: W292: no newline at end of file
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/usb_facts.py:0:0: invalid-documentation: DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got 'Max Maxopoly ([email protected])'
The test ansible-test sanity --test pylint [explain] failed with 2 errors:
tests/unit/plugins/modules/test_usb_facts.py:101:111: trailing-whitespace: Trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:0: missing-final-newline: Final newline missing
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/usb_facts.py:0:0: invalid-documentation: DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got 'Max Maxopoly ([email protected])'
The test ansible-test sanity --test pylint [explain] failed with 2 errors:
tests/unit/plugins/modules/test_usb_facts.py:101:111: trailing-whitespace: Trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:0: missing-final-newline: Final newline missing
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/usb_facts.py:0:0: invalid-documentation: DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got 'Max Maxopoly ([email protected])'
The test ansible-test sanity --test pep8 [explain] failed with 9 errors:
tests/unit/plugins/modules/test_usb_facts.py:16:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:21:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:52:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:56:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:57:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:58:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:82:38: E211: whitespace before '['
tests/unit/plugins/modules/test_usb_facts.py:101:112: W291: trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:77: W292: no newline at end of file
The test ansible-test sanity --test validate-modules [explain] failed with 1 error:
plugins/modules/usb_facts.py:0:0: invalid-documentation: DOCUMENTATION.author: Invalid author for dictionary value @ data['author']. Got 'Max Maxopoly ([email protected])'
The test botmeta failed with 1 error:
.github/BOTMETA.yml:0:0: No (active or inactive) maintainer mentioned for plugins/modules/usb_facts.py
The test ansible-test sanity --test pylint [explain] failed with 2 errors:
tests/unit/plugins/modules/test_usb_facts.py:101:111: trailing-whitespace: Trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:0: missing-final-newline: Final newline missing
The test ansible-test sanity --test pep8 [explain] failed with 9 errors:
tests/unit/plugins/modules/test_usb_facts.py:16:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:21:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:52:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:56:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:57:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:58:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:82:38: E211: whitespace before '['
tests/unit/plugins/modules/test_usb_facts.py:101:112: W291: trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:77: W292: no newline at end of file
The test ansible-test sanity --test pep8 [explain] failed with 9 errors:
tests/unit/plugins/modules/test_usb_facts.py:16:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:21:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:52:1: E302: expected 2 blank lines, found 1
tests/unit/plugins/modules/test_usb_facts.py:56:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:57:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:58:50: E128: continuation line under-indented for visual indent
tests/unit/plugins/modules/test_usb_facts.py:82:38: E211: whitespace before '['
tests/unit/plugins/modules/test_usb_facts.py:101:112: W291: trailing whitespace
tests/unit/plugins/modules/test_usb_facts.py:102:77: W292: no newline at end of file
As far as I can tell the only check failing is
Author maxopoly not mentioned as active or inactive maintainer for plugins/modules/usb_facts.py (mentioned are: )
What/who should I be putting as maintainer?
The test botmeta failed with 2 errors:
.github/BOTMETA.yml:0:0: Author maxopoly not mentioned as active or inactive maintainer for plugins/modules/usb_facts.py (mentioned are: )
.github/BOTMETA.yml:0:0: No (active or inactive) maintainer mentioned for plugins/modules/usb_facts.py
If I may suggest, give it a try to andebox by yours truly:
https://pypi.org/project/andebox/
You can run this sanity test easily in your local machine by simply running:
$ andebox test -- sanity --docker default --python 3.10 plugins/modules/your_module.py
As far as I can tell the only check failing is
Author maxopoly not mentioned as active or inactive maintainer for plugins/modules/usb_facts.py (mentioned are: )What/who should I be putting as maintainer?
Did you check out the part in CONTRIBUTING.md about adding new modules and plugins? It explicitly mentions .github/BOTMETA.yml.
If I may suggest, give it a try to andebox by yours truly:
Didn't know about that, very cool. Thanks for the tip!
Did you check out the part in CONTRIBUTING.md about adding new modules and plugins? It explicitly mentions .github/BOTMETA.yml.
Skimmed over it, but apparently not thoroughly enough. My bad for failing to read instructions. Should be good now.
I implemented all suggestions as provided, should be good to go.
Backport to stable-8: 💚 backport PR created
✅ Backport PR branch: patchback/backports/stable-8/6298ad4faa851b44db8926e4c52252cda9ed1d9a/pr-8076
Backported as https://github.com/ansible-collections/community.general/pull/8115
🤖 @patchback I'm built with octomachinery and my source is open — https://github.com/sanitizers/patchback-github-app.
@Maxopoly thanks for contributing this! @russoz thanks for reviewing!