Fix a crash when missing rack id (#172)

This commit is contained in:
Cyrinux 2021-07-20 21:55:47 +02:00 committed by GitHub
parent bdc450ef6a
commit 8a46af19b8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,