netbox: inventory: Fix VMs do not have device_roles, but instead use roles (#50761)

This makes sure that roles show up as device_role when using VMs
pull/52019/head
Karsten Jakobsen 6 years ago committed by René Moser
parent 7b84c0ee80
commit e6ae688e47

@ -252,7 +252,10 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
def extract_device_role(self, host):
try:
return [self.device_roles_lookup[host["device_role"]["id"]]]
if 'device_role' in host:
return [self.device_roles_lookup[host["device_role"]["id"]]]
elif 'role' in host:
return [self.device_roles_lookup[host["role"]["id"]]]
except Exception:
return

Loading…
Cancel
Save