diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_disk.py b/lib/ansible/modules/cloud/ovirt/ovirt_disk.py index e95251e7bf..e3a059697b 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_disk.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_disk.py @@ -555,6 +555,18 @@ class DiskAttachmentsModule(DisksModule): ) +def searchable_attributes(module): + """ + Return all searchable disk attributes passed to module. + """ + attributes = { + 'name': module.params.get('name'), + 'Storage.name': module.params.get('storage_domain'), + 'vm_names': module.params.get('vm_name'), + } + return dict((k, v) for k, v in attributes.items() if v is not None) + + def main(): argument_spec = ovirt_full_argument_spec( state=dict( @@ -616,6 +628,7 @@ def main(): if state in ('present', 'detached', 'attached'): ret = disks_module.create( entity=disk, + search_params=searchable_attributes(module), result_state=otypes.DiskStatus.OK if lun is None else None, fail_condition=lambda d: d.status == otypes.DiskStatus.ILLEGAL if lun is None else False, ) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py index 0372314fbd..31b0d6dec9 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_templates.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_templates.py @@ -422,6 +422,17 @@ def _get_vnic_profile_mappings(module): return vnicProfileMappings +def searchable_attributes(module): + """ + Return all searchable template attributes passed to module. + """ + attributes = { + 'name': module.params.get('name'), + 'cluster': module.params.get('cluster'), + } + return dict((k, v) for k, v in attributes.items() if v is not None) + + def main(): argument_spec = ovirt_full_argument_spec( state=dict( @@ -474,6 +485,7 @@ def main(): if state == 'present': ret = templates_module.create( result_state=otypes.TemplateStatus.OK, + search_params=searchable_attributes(module), clone_permissions=module.params['clone_permissions'], seal=module.params['seal'], )