Fix a crash when missing rack id #172

Merged
cyrinux merged 6 commits from fix_a_crash into master 2021-07-20 21:55:47 +02:00

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
ramnes commented 2021-07-09 11:05:04 +02:00 (Migrated from github.com)
Review

Seems overly complicated, why not just something like this?

            and server.rack
            and nb_rack
Seems overly complicated, why not just something like this? ```suggestion and server.rack and nb_rack ```
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,