Skip to content

Commit 98b8ea5

Browse files
committed
Fix netboxk interface delete
Iterate over a copy of the nb_nics list so that we can remove elements from the original nb_nics list safely without affecting the iteration.
1 parent b2ad6b1 commit 98b8ea5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

netbox_agent/network.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ def create_or_update_netbox_network_cards(self):
418418
# delete unknown interface
419419
nb_nics = list(self.get_netbox_network_cards())
420420
local_nics = [x["name"] for x in self.nics]
421-
for nic in nb_nics:
421+
for nic in list(nb_nics):
422422
if nic.name not in local_nics:
423423
logging.info(
424424
"Deleting netbox interface {name} because not present locally".format(

0 commit comments

Comments
 (0)