From b06003e5d2915c07a64d2e26c7b934dc64b3edae Mon Sep 17 00:00:00 2001 From: Nijin Ashok Date: Thu, 17 Nov 2016 19:54:50 +0530 Subject: [PATCH] Fix issue in adding RAW disk in block storage domain (#3432) By default, sparse option is true in ovirt. So the raw disk creation in a block storage domain will fail with error "Disk configuration (RAW Sparse) is incompatible with the storage domain type". The commit adds sparse option where it is send as False when format is raw and True when format is qcow2 --- lib/ansible/modules/extras/cloud/ovirt/ovirt_disks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/extras/cloud/ovirt/ovirt_disks.py b/lib/ansible/modules/extras/cloud/ovirt/ovirt_disks.py index a8f84c26e83..092fb051cf1 100644 --- a/lib/ansible/modules/extras/cloud/ovirt/ovirt_disks.py +++ b/lib/ansible/modules/extras/cloud/ovirt/ovirt_disks.py @@ -65,7 +65,10 @@ options: default: 'virtio' format: description: - - "Format of the disk. Either copy-on-write or raw." + - Specify format of the disk. + - If (cow) format is used, disk will by created as sparse, so space will be allocated for the volume as needed, also known as I(thin provision). + - If (raw) format is used, disk storage will be allocated right away, also known as I(preallocated). + - Note that this option isn't idempotent as it's not currently possible to change format of the disk via API. choices: ['raw', 'cow'] storage_domain: description: @@ -168,6 +171,7 @@ class DisksModule(BaseModule): format=otypes.DiskFormat( self._module.params.get('format') ) if self._module.params.get('format') else None, + sparse=False if self._module.params.get('format') == 'raw' else True, provisioned_size=convert_to_bytes( self._module.params.get('size') ), @@ -198,7 +202,6 @@ class DisksModule(BaseModule): return ( equal(self._module.params.get('description'), entity.description) and equal(convert_to_bytes(self._module.params.get('size')), entity.provisioned_size) and - equal(self._module.params.get('format'), str(entity.format)) and equal(self._module.params.get('shareable'), entity.shareable) ) @@ -234,7 +237,6 @@ def main(): vm_id=dict(default=None), size=dict(default=None), interface=dict(default=None,), - allocation_policy=dict(default=None), storage_domain=dict(default=None), profile=dict(default=None), format=dict(default=None, choices=['raw', 'cow']),