From 8a46af19b8ebcaecb4075762866fd8d2926edbab Mon Sep 17 00:00:00 2001 From: Cyrinux Date: Tue, 20 Jul 2021 21:55:47 +0200 Subject: [PATCH] Fix a crash when missing rack id (#172) --- netbox_agent/server.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/netbox_agent/server.py b/netbox_agent/server.py index 68db8da..9cedf62 100644 --- a/netbox_agent/server.py +++ b/netbox_agent/server.py @@ -66,7 +66,6 @@ class ServerBase(): def update_netbox_location(self, server): dc = self.get_datacenter() - rack = self.get_rack() nb_rack = self.get_netbox_rack() nb_dc = self.get_netbox_datacenter() @@ -79,7 +78,11 @@ class ServerBase(): update = True server.site = nb_dc.id - if rack and server.rack and server.rack.id != nb_rack.id: + if ( + server.rack + and nb_rack + and server.rack.id != nb_rack.id + ): logging.info('Rack location has changed from {} to {}, updating'.format( server.rack, nb_rack,