Truncate GPU product name to 50 characteres.

Example: Hi1710 [iBMC Intelligent Management system chip w/VGA support]
This product is too long, the api want max_length = 50 ...
This commit is contained in:
Cyril Levis 2020-09-30 14:22:56 +02:00
commit edb335e8c3
No known key found for this signature in database
GPG key ID: 8538D68543979A20

View file

@ -442,6 +442,8 @@ class Inventory():
def create_netbox_gpus(self): def create_netbox_gpus(self):
for gpu in self.lshw.get_hw_linux('gpu'): for gpu in self.lshw.get_hw_linux('gpu'):
if 'product' in gpu and len(gpu['product']) > 50:
gpu['product'] = (gpu['product'][:48] + '..')
manufacturer = self.find_or_create_manufacturer(gpu["vendor"]) manufacturer = self.find_or_create_manufacturer(gpu["vendor"])
_ = nb.dcim.inventory_items.create( _ = nb.dcim.inventory_items.create(
device=self.device_id, device=self.device_id,