diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_nics.py b/lib/ansible/modules/cloud/ovirt/ovirt_nics.py index 8a54a178ec1..0dcf9fb9df3 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_nics.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_nics.py @@ -212,7 +212,18 @@ def main(): dcs_service = connection.system_service().data_centers_service() dc = dcs_service.list(search='Clusters.name=%s' % cluster_name)[0] networks_service = dcs_service.service(dc.id).networks_service() - network = search_by_name(networks_service, module.params['network']) + network = next( + (n for n in networks_service.list() + if n.name == module.params['network']), + None + ) + if network is None: + raise Exception( + "Network '%s' was not found in datacenter '%s'." % ( + module.params['network'], + dc.name + ) + ) for vnic in connection.system_service().vnic_profiles_service().list(): if vnic.name == profile and vnic.network.id == network.id: vmnics_module.vnic_id = vnic.id