From d7af66b325139a01a9352bb9c4e3a352ee2048a5 Mon Sep 17 00:00:00 2001 From: Solvik Blum Date: Wed, 7 Aug 2019 15:36:24 +0200 Subject: [PATCH] fix bug while testing debug with an interface not existing while updating --- netbox_agent/network.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/netbox_agent/network.py b/netbox_agent/network.py index a3b0490..07ec6c0 100644 --- a/netbox_agent/network.py +++ b/netbox_agent/network.py @@ -147,6 +147,11 @@ class Network(): interface = nb.dcim.interfaces.get( mac_address=nic['mac'], ) + if not interface: + logging.info('Interface {} not found, creating..'.format( + mac_address=nic['mac']) + ) + interface = self.create_netbox_nic(device, nic) nic_update = False if nic['name'] != interface.name: