ovirt-ansible-collection icon indicating copy to clipboard operation
ovirt-ansible-collection copied to clipboard

ovirt_disk: Add convert action of the disk

Open mnecas opened this issue 2 years ago • 7 comments

Fixes: https://github.com/oVirt/ovirt-ansible-collection/issues/600

mnecas avatar Oct 12 '22 12:10 mnecas

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

mnecas avatar Oct 12 '22 13:10 mnecas

Hey, thanks for the very quick initiative!

[SNIP]

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

spameier avatar Oct 12 '22 17:10 spameier

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

mnecas avatar Oct 12 '22 18:10 mnecas

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

spameier avatar Oct 12 '22 20:10 spameier

Do you have some error in engine log?

mnecas avatar Oct 13 '22 07:10 mnecas

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 avatar Oct 13 '22 15:10 spameier

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.

spameier avatar Oct 14 '22 06:10 spameier