fix rack comparison while updating location (#84)

This commit is contained in:
Solvik 2019-09-12 17:47:41 +02:00 committed by GitHub
parent 06328e745c
commit a1297813ef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,7 +42,7 @@ class ServerBase():
nb_dc = self.get_netbox_datacenter()
update = False
if dc and server.site.slug != nb_dc.slug:
if dc and server.site and server.site.slug != nb_dc.slug:
logging.info('Datacenter location has changed from {} to {}, updating'.format(
server.site.slug,
nb_dc.slug,
@ -50,7 +50,7 @@ class ServerBase():
update = True
server.site = nb_dc.id
if rack and server.rack != nb_rack:
if rack and server.rack and server.rack.id != nb_rack.id:
logging.info('Rack location has changed from {} to {}, updating'.format(
server.rack,
nb_rack,