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

Conversation

mnecas
Copy link
Member

@mnecas mnecas commented Oct 12, 2022

Fixes: #600

@mnecas mnecas requested a review from mwperina October 12, 2022 12:43
@mnecas
Copy link
Member Author

mnecas commented Oct 12, 2022

@spameier could you please try this PR if it works for you?
It calls the conversion in the engine but on my env fails.

@spameier
Copy link

spameier commented Oct 12, 2022

Hey, thanks for the very quick initiative!

[SNIP]

After installing ovirt-engine-sdk-python from pypi it seems to work :)

@mnecas
Copy link
Member Author

mnecas commented Oct 12, 2022

Happy to hear that! (probably unrelated issues on my env)
Yeah, you need the latest SDK with the convert service.

@spameier
Copy link

I indeed see a conversion job being created in oVirt, but the format does not change. The job title in oVirt is "Converting disk test to Preallocated/RAW" when trying to convert from raw to cow.

Playbook:

- hosts: localhost
  gather_facts: no
  connection: local
  vars_files:
    - vault.yml # Contains encrypted `engine_password`
    - vars.yml
  tasks:
    - name: Login
      ovirt_auth:
        url: "{{ engine_url }}"
        password: "{{ engine_password  }}"
        username: "{{ engine_user }}"
    - ovirt_disk_info:
        auth: "{{ ovirt_auth }}"
        pattern: id=d7ca29bf-aa77-402b-9c8d-ae854b260ac2
      register: result
    - debug:
        msg: "{{ result.ovirt_disks[0].format }}"
    - ovirt_disk:
        auth: "{{ ovirt_auth }}"
        id: d7ca29bf-aa77-402b-9c8d-ae854b260ac2
        format: cow
        sparse: yes
    - ovirt_disk_info:
        auth: "{{ ovirt_auth }}"
        pattern: id=d7ca29bf-aa77-402b-9c8d-ae854b260ac2
      register: result
    - debug:
        msg: "{{ result.ovirt_disks[0].format }}"
  collections:
    - ovirt.ovirt

Output:


PLAY [localhost] ******************************************************************************************************

TASK [Login] **********************************************************************************************************
ok: [localhost]

TASK [ovirt_disk_info] ************************************************************************************************
ok: [localhost]

TASK [debug] **********************************************************************************************************
ok: [localhost] => {
    "msg": "raw"
}

TASK [ovirt_disk] *****************************************************************************************************
[WARNING]: Module did not set no_log for pass_discard
changed: [localhost]

TASK [ovirt_disk_info] ************************************************************************************************
ok: [localhost]

TASK [debug] **********************************************************************************************************
ok: [localhost] => {
    "msg": "raw"
}

PLAY RECAP ************************************************************************************************************
localhost                  : ok=6    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

@mnecas
Copy link
Member Author

mnecas commented Oct 13, 2022

Do you have some error in engine log?

@spameier
Copy link

I see no real error i the GUI. Here's a gist with the logs while the playbook is running: https://gist.github.com/spameier/be77ed3c6c28081bea85376f05e88d48

@spameier
Copy link

I could recreate the behaviour with ovirtsdk4. If I do not specify disk.format oVirt just converts raw to raw (or cow to cow). I think you need to add disk.format =. I can test it later with your branch but don't have access to a computer right now.

@@ -921,6 +921,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.

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.

Add support for converting disks
2 participants