-
Notifications
You must be signed in to change notification settings - Fork 42
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
Implement ansible module for management of libvirt volumes #180
base: main
Are you sure you want to change the base?
Conversation
First conflict free merge.
Trying to define a volume, that already exists caused the integration test to fail with a traceback that implies, a code block has been executed, which should have been skipped in the case of the target volume already existing. The previous code based on raising and catching an exception in case the volume does not already exist, but resulting in the exception bein risen anyway during the test, which lead to the failure. This commit replaces the exception based check in hope to fix this bug.
…nged Trying to define a volume, that already exists caused the integration test to fail with a traceback that implies, a code block has been executed, which should have been skipped in the case of the target volume already existing. The previous code based on raising and catching an exception in case the volume does not already exist, but resulting in the exception bein risen anyway during the test, which lead to the failure. This commit replaces the exception based check in hope to fix this bug.
The integration tests now fail because of ... keyboard interrupt? How? |
@NK308 hello, i wonder if we can remote those remote targets |
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.
@NK308 thanks for the PR
I would separate the code:
- You refactor the code in one PR
- Then you add the module in another PR or wise versa
It's easy to make a mistake and imo not a good idea in general to mix refactoring and new features in a single PR.
Hence, i'm suggesting splitting the PR.
cc @csmart
import libvirt | ||
|
||
|
||
class LibvirtConnection(object): |
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.
class LibvirtConnection(object): | |
class LibvirtConnection(object): |
don't you import this class from module_utils.pool?
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.
The imported class is not called LibvirtConnection
in the namespace of plugin.modules.libvirt
which is something I adopted from https://github.com/flagbot/community.libvirt/tree/feature/virt_volume.
plugins/modules/virt_volume.py
Outdated
from ansible_collections.community.libvirt.plugins.module_utils.pool import LibvirtConnection as PoolConnection, HAS_VIRT, HAS_XML | ||
from ansible_collections.community.libvirt.plugins.module_utils.entry import EntryNotFound |
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.
from ansible_collections.community.libvirt.plugins.module_utils.pool import LibvirtConnection as PoolConnection, HAS_VIRT, HAS_XML | |
from ansible_collections.community.libvirt.plugins.module_utils.entry import EntryNotFound | |
from ansible_collections.community.libvirt.plugins.module_utils.pool import LibvirtConnection as PoolConnection, HAS_VIRT, HAS_XML | |
from ansible_collections.community.libvirt.plugins.module_utils.entry import EntryNotFound |
I think this should be moved up to line 131
Hi |
About the refactoring topic, if I'm gonna split the refactoring off this PR anyway... The coding style seems to be a bit weird in general. The Also it seems very arbitrary, which methods take the python wrapper of some libvirt object, or it's name (and call I'm not sure, how much of that might be prevented by the requirement to keep compatibility down to python2. Things like generic classes surely won't work. |
I'm not sure about that. In some of the previous commits, there was an actual error message, which showed an actual problem with an integration test, which dissappeared after I fixed it. And this error only showed on the Remote RHEL targets for some reason, I don't understand. |
"no connection driver available for qemu:///system" is a new error, and I'm not able to tell, why it starts showing up exactly now, and not earlier. |
I'm unfortunately completely unfamiliar with the technology and have no idea about why the tests fail |
@NK308 i took a quick look, i see you test on very old distros, how about just testing only on ubuntu 24.04 if it makes sense? |
@Andersson007 The issue seems to be very specific to the RHEL remote targets, even the current version, while older versions of other operating systems don't seem to cause any problems. |
@NK308 my comment is not related to the failures, i just think it's an extra thing and there's no such a requirement to test against them. I'm not familiar with the technology though and I don't know if it's distro dependent or not. |
I now have removed the OS specific variables from the integration tests, if that's what you meant. The remaining operating systems represented in |
@NK308 how about removing RH 7 and updating Ubuntu 16 to 24.04 ? |
Those versions are not end of life yet, and servers can still receive extended support, as stated here https://en.wikipedia.org/wiki/Ubuntu_version_history and here https://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux. |
Hi @NK308 thanks very much for reviving this, I'll take a look and put in any comments in line. |
SUMMARY
This PR adds a module to create, delete and modify libvirt volumes.
This PR is based on the fork which was subject of #45
ISSUE TYPE
COMPONENT NAME
virt_volume
ADDITIONAL INFORMATION
Some of the code of the new ansible module as well as parts of the code of
virt_pool
, have been refactored tomodule_utils
to reduce redundancy.For now I have only tested the simple creation und deletion of storage volumes, so there might some more testing be needed.
For now I didn't do much more, compared to #45, than bringing the branch up to date with the main branch, including the adoption of changes in the code and doc style from the other modules.