From 2d8ec831e6aa7b885ae9a4e28b2fa42ae7943a6b Mon Sep 17 00:00:00 2001 From: Cyril Levis Date: Thu, 17 Nov 2022 11:00:48 +0100 Subject: [PATCH] fix: dvd rom inventory crash dvdrom dont have serial number, we fallback on a 'unknown' value now to prevent crash --- netbox_agent/inventory.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/netbox_agent/inventory.py b/netbox_agent/inventory.py index 8e55a4c..69d5b97 100644 --- a/netbox_agent/inventory.py +++ b/netbox_agent/inventory.py @@ -371,13 +371,14 @@ class Inventory(): desc = disk.get('description') name = '{} ({})'.format(disk['Model'], disk['Size']) description = disk['Type'] + sn = getattr(disk, 'SN', 'unknown') parms = { 'device': self.device_id, 'discovered': True, 'tags': [{'name': INVENTORY_TAG['disk']['name']}], 'name': name, - 'serial': disk['SN'], + 'serial': sn, 'part_id': disk['Model'], 'description': description, 'manufacturer': getattr(manufacturer, "id", None), @@ -389,7 +390,7 @@ class Inventory(): logging.info('Creating Disk {model} {serial}'.format( model=disk['Model'], - serial=disk['SN'], + serial=sn, )) def dump_disks_map(self, disks):