Fix a crash when missing rack id (#172)
This commit is contained in:
parent
bdc450ef6a
commit
8a46af19b8
1 changed files with 5 additions and 2 deletions
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue