ovirt_disk: support sparse parameter (#34091) (#34894)

Support sparse parameter as an explicit
value to allow creating raw-sparse disks.

This commit fixes #34091
pull/35007/head
Simone Tiraboschi 7 years ago committed by ansibot
parent 0a9489ef66
commit 41ce1eaea9

@ -87,10 +87,15 @@ options:
format: format:
description: description:
- Specify format of the disk. - 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. - Note that this option isn't idempotent as it's not currently possible to change format of the disk via API.
choices: ['raw', 'cow'] choices: ['raw', 'cow']
sparse:
required: False
version_added: "2.5"
description:
- "I(True) if the disk should be sparse (also known as I(thin provision)).
If the parameter is omitted, cow disks will be created as sparse and raw disks as I(preallocated)"
- Note that this option isn't idempotent as it's not currently possible to change sparseness of the disk via API.
storage_domain: storage_domain:
description: description:
- "Storage domain name where disk should be created. By default storage is chosen by oVirt/RHV engine." - "Storage domain name where disk should be created. By default storage is chosen by oVirt/RHV engine."
@ -438,7 +443,11 @@ class DisksModule(BaseModule):
format=otypes.DiskFormat( format=otypes.DiskFormat(
self._module.params.get('format') self._module.params.get('format')
) if self._module.params.get('format') else None, ) if self._module.params.get('format') else None,
sparse=self._module.params.get('format') != 'raw', sparse=self._module.params.get(
'sparse'
) if self._module.params.get(
'sparse'
) is not None else self._module.params.get('format') != 'raw',
openstack_volume_type=otypes.OpenStackVolumeType( openstack_volume_type=otypes.OpenStackVolumeType(
name=self.param('openstack_volume_type') name=self.param('openstack_volume_type')
) if self.param('openstack_volume_type') else None, ) if self.param('openstack_volume_type') else None,
@ -563,6 +572,7 @@ def main():
profile=dict(default=None), profile=dict(default=None),
quota_id=dict(default=None), quota_id=dict(default=None),
format=dict(default='cow', choices=['raw', 'cow']), format=dict(default='cow', choices=['raw', 'cow']),
sparse=dict(default=None, type='bool'),
bootable=dict(default=None, type='bool'), bootable=dict(default=None, type='bool'),
shareable=dict(default=None, type='bool'), shareable=dict(default=None, type='bool'),
logical_unit=dict(default=None, type='dict'), logical_unit=dict(default=None, type='dict'),

Loading…
Cancel
Save