netbox-community / Device-Type-Library-Import

This library is intended to assist with importing device and module types into NetBox from the NetBox Community DeviceType-Library
https://github.com/netbox-community/devicetype-library
MIT License
256 stars 77 forks source link

Strip invalid spaces from Manufacturer slug generation #8

Closed mtinberg closed 2 years ago

mtinberg commented 3 years ago

https://github.com/minitriga/Netbox-Device-Type-Library-Import/blob/1f31c11edadccbdfa984e2cb170fe05f2142f3cf/nb-dt-import.py#L55

Slug can't have spaces, but some directories and the Manufacturer Name does have spaces, strip them out. Fixes problems importing devicetype-library for "Palo Alto"

data['manufacturer']['slug'] = manufacturer.lower().replace(" ", "")

cuervotux commented 2 years ago

Slug can't have char '&' and the process importing fail. To fix problem importing devicetype for "Rohde & Schwarz":

data['manufacturer']['slug'] = manufacturer.lower().replace(" ", "").replace("_&","")

FloEisen commented 2 years ago

In the PR, I implemented a clean solution in the original slugFormat() function which solves the problem with special chars