From 8c49c867d20d93571095763f50907c34432f1111 Mon Sep 17 00:00:00 2001 From: Ondra Machacek Date: Mon, 16 Apr 2018 16:54:19 +0200 Subject: [PATCH] ovirt_host_networks: Fix removing of network attachments (#38816) --- lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py b/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py index 6c674ce177..5d88c46526 100644 --- a/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py +++ b/lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py @@ -433,12 +433,13 @@ def main(): ] if networks else None, ) elif state == 'absent' and nic: + attachments = [] nic_service = nics_service.nic_service(nic.id) - attachments_service = nic_service.network_attachments_service() - attachments = attachments_service.list() attached_labels = set([str(lbl.id) for lbl in nic_service.network_labels_service().list()]) if networks: + attachments_service = nic_service.network_attachments_service() + attachments = attachments_service.list() attachments = [ attachment for attachment in attachments if get_link_name(connection, attachment.network) in network_names @@ -460,7 +461,7 @@ def main(): removed_labels=[ otypes.NetworkLabel(id=str(name)) for name in labels ] if labels else None, - removed_network_attachments=list(attachments), + removed_network_attachments=attachments if attachments else None, ) nic = search_by_name(nics_service, nic_name)