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

ovirt_disk: Add convert action of the disk #601

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/601-ovirt_disk-add-convert-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- ovirt_disk - Add convert action of the disk (https://github.com/oVirt/ovirt-ansible-collection/pull/601).
6 changes: 6 additions & 0 deletions plugins/modules/ovirt_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,6 +916,12 @@ def main():
action_condition=lambda d: module.params['sparsify'],
wait_condition=lambda d: d.status == otypes.DiskStatus.OK,
)
ret = disks_module.action(
Copy link

@spameier spameier Oct 14, 2022

Choose a reason for hiding this comment

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

You need to explicitly add the disk format here.

if module.params['format'] != None:
    disk.format = otypes.DiskFormat.COW if module.params['format'] == 'cow' else otypes.DiskFormat.RAW

Also when converting from raw to cow you need to set disk.sparse to True. I am unsure whether you want the user to set this or implicitly change the value.

disk=disk,
action='convert',
action_condition=lambda d: module.params['format'] != str(d.format),
wait_condition=lambda d: d.status == otypes.DiskStatus.OK,
)

# Export disk as image to glance domain
elif state == 'exported':
Expand Down