Skip to content

Commit

Permalink
fix rack comparison while updating location (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
Solvik authored Sep 12, 2019
1 parent 06328e7 commit a129781
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions netbox_agent/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@ def update_netbox_location(self, server):
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,
))
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,
Expand Down

0 comments on commit a129781

Please sign in to comment.