oVirt/ovirt-ansible-collection

ovirt_disk module extend disk size

hemak88 opened this issue · 5 comments

SUMMARY

ovirt_disk module doesnt have the option to "extend disk size by" while editing a disk. This feature will be helpful in the case where existing disk size can be increased by a new "value" without calculating current size of disk and adding new disk size to it. This option is available in ovirt UI while editing a disk- "Extend size by (GiB)"

COMPONENT NAME

ovirt_disk

ADDITIONAL INFORMATION

Current "size" parameter in ovirt_disk module, gives an error as below when extendable size is lesser than existing disk size
"Cannot edit Virtual Disk. New disk size must be larger than the current disk size"

ovirt_disk.py

This is against ansible idempotent style. If we would have such a parameter and would run the playbook multiple times the disk would get resized every time.
So all the parameters in the ovirt modules are descriptions of how would you like the disk to look.
If you want to resize the disk you need to add to the size the original size+extendable size

Wont be having an additional parameter "extendsize" which by default will be "0" and when specified will add that much additional space to disk be a good enhancement.

Is there a way to get the disk provisioned size before extending the disk given the disk ID for an ovirt VM?

@veejoshee yup please checkout the ovirt_disk_info module.

Example:

    - ovirt.ovirt.ovirt_disk_info:
        auth: "{{ ovirt_auth }}"
        pattern: name=test
      register: result

Output:

    "ovirt_disks": [
        {
            "actual_size": 4096,
            "alias": "test",
            "backup": "none",
            "content_type": "data",
            "description": "",
            "disk_profile": {
                "href": "/ovirt-engine/api/diskprofiles/0f9c5266-0192-4127-897f-b297cf6c8e04",
                "id": "0f9c5266-0192-4127-897f-b297cf6c8e04"
            },
            "disk_snapshots": [],
            "format": "raw",
            "href": "/ovirt-engine/api/disks/f56564ed-ca74-4d96-9ec6-4b3999a8d93d",
            "id": "f56564ed-ca74-4d96-9ec6-4b3999a8d93d",
            "image_id": "fda31e9b-580d-4d2f-9650-2171c2a8196e",
            "name": "test",
            "permissions": [],
            "propagate_errors": false,
            "provisioned_size": 1073741824,
            "quota": {
                "href": "/ovirt-engine/api/datacenters/32ebd239-25a2-4a13-b514-5bf7c8de6878/quotas/712172d4-dc8e-4989-8a20-578506088116",
                "id": "712172d4-dc8e-4989-8a20-578506088116"
            },
            "shareable": false,
            "sparse": true,
            "statistics": [],
            "status": "ok",
            "storage_domains": [
                {
                    "href": "/ovirt-engine/api/storagedomains/95ef6fee-5773-46a2-9340-a636958a96b8",
                    "id": "95ef6fee-5773-46a2-9340-a636958a96b8"
                }
            ],
            "storage_type": "image",
            "total_size": 0,
            "wipe_after_delete": false
        }
    ]

@veejoshee yup please checkout the ovirt_disk_info module.

Example:

    - ovirt.ovirt.ovirt_disk_info:
        auth: "{{ ovirt_auth }}"
        pattern: name=test
      register: result

Output:

    "ovirt_disks": [
        {
            "actual_size": 4096,
            "alias": "test",
            "backup": "none",
            "content_type": "data",
            "description": "",
            "disk_profile": {
                "href": "/ovirt-engine/api/diskprofiles/0f9c5266-0192-4127-897f-b297cf6c8e04",
                "id": "0f9c5266-0192-4127-897f-b297cf6c8e04"
            },
            "disk_snapshots": [],
            "format": "raw",
            "href": "/ovirt-engine/api/disks/f56564ed-ca74-4d96-9ec6-4b3999a8d93d",
            "id": "f56564ed-ca74-4d96-9ec6-4b3999a8d93d",
            "image_id": "fda31e9b-580d-4d2f-9650-2171c2a8196e",
            "name": "test",
            "permissions": [],
            "propagate_errors": false,
            "provisioned_size": 1073741824,
            "quota": {
                "href": "/ovirt-engine/api/datacenters/32ebd239-25a2-4a13-b514-5bf7c8de6878/quotas/712172d4-dc8e-4989-8a20-578506088116",
                "id": "712172d4-dc8e-4989-8a20-578506088116"
            },
            "shareable": false,
            "sparse": true,
            "statistics": [],
            "status": "ok",
            "storage_domains": [
                {
                    "href": "/ovirt-engine/api/storagedomains/95ef6fee-5773-46a2-9340-a636958a96b8",
                    "id": "95ef6fee-5773-46a2-9340-a636958a96b8"
                }
            ],
            "storage_type": "image",
            "total_size": 0,
            "wipe_after_delete": false
        }
    ]

Thanks, that is what I was looking for!