Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ovirt_host_networks: Fix removing of network attachments #38816

Merged
merged 1 commit into from
Apr 16, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/ansible/modules/cloud/ovirt/ovirt_host_networks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down