1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ovirt_host_networks: Fix removing of network attachments (#38816)

This commit is contained in:
Ondra Machacek 2018-04-16 16:54:19 +02:00 committed by ansibot
parent bdbb89378f
commit 8c49c867d2

View file

@ -433,12 +433,13 @@ def main():
] if networks else None, ] if networks else None,
) )
elif state == 'absent' and nic: elif state == 'absent' and nic:
attachments = []
nic_service = nics_service.nic_service(nic.id) 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()]) attached_labels = set([str(lbl.id) for lbl in nic_service.network_labels_service().list()])
if networks: if networks:
attachments_service = nic_service.network_attachments_service()
attachments = attachments_service.list()
attachments = [ attachments = [
attachment for attachment in attachments attachment for attachment in attachments
if get_link_name(connection, attachment.network) in network_names if get_link_name(connection, attachment.network) in network_names
@ -460,7 +461,7 @@ def main():
removed_labels=[ removed_labels=[
otypes.NetworkLabel(id=str(name)) for name in labels otypes.NetworkLabel(id=str(name)) for name in labels
] if labels else None, ] 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) nic = search_by_name(nics_service, nic_name)