You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Device Type Import/Export is inconsistent. While the functionality exists it isn't easy to use in practical terms and the API doesn't appear to fill in all the gaps.
Device type export is everything in one file (multiple objects per device type which is nice) but Import is 1 device type at a time
The problem with this is you can't export out 100's of devices then easily re import them in bulk elsewhere.
The import process is to cut up the export file (manually or using a script) then importing each individual object.
This is impractical to do manually for a large number of devices, it can be scripted though and the API used to manage the loading (slightly more complicated as you need to create related objects , eg interfaces, individually and link them back to newly create Device Type but if you know how to write something to talk to the api it shouldn't be a big deal.)
The export doesn't included images in anyway, eg path + filename, url. The API does include the image url but the API auth doesn't appear to be able to access that url.
There doesn't appear to be any way to add images or image paths when importing, I can't see how to load a front/rear image though the API either though it does have a link.
note the front and rear images don't appear to be image_attachments in the API but something else
The solution here is a combination of copying all the image files from the source server to the destination server, then grabbing the dcim_devicetype, and dcim_manufacturer tables from the source server and using that to put the correct filenames directly into the db on the destination server.
eg create a temp table based on the dcim_devicetype table + dcim_manufacture.slug of the source db to update the destination db
SET front_image=subquery.front_image,
rear_image=subquery.rear_image
FROM (
SELECT dt.model,
dt.slug,
dt.front_image,
dt.rear_image,
m.id AS man_id
FROM temp_device_type_images AS dt,
dcim_manufacturer AS m
WHERE dt.manufacturer_slug = m.slug
) AS subquery
WHERE dcim_devicetype.manufacturer_id = subquery.man_id
Possible Solutions
Fixing the existing export/import functionality
Add to the existing export yaml a front_image and rear_image file reference.
Change the export to a archive that contains the updated export yaml + image files
Export breaks up all devices types into individual files per device type inside the archive
Group device types per manufacturer
Import can read the archive and import multiple device types in one action
The end result internally may look something like this
./devicetype/
./devicetype/<manufacturer slug>/
./devicetype/<manufacturer slug>/<devicetype1 slug>.yml
./devicetype/<manufacturer slug>/<devicetype2 slug>.yml
./devicetype-images/
./devicetype-images/<devicetype1 front filename>.png
./devicetype-images/<devicetype1 rear filename>.png
./devicetype-images/<devicetype2 front filename>.png
A new UI and functionality based on the above that uses git repository(s) instead of zip archives.
The advantage of using a git repository would be the ability to one or many git repositories and then cherry pick which manufactures or individual devices are synchronized between netbox and the git repository.
The options in the UI for sync
Netbox to git repo (export)
git repo to Netbox (import)
Bidirectional (sync)
These options would be available at a repository, manufacturer and model levels.
The advantage of using git repositories over the archive only is they will encourage community sharing while at the same time making it easy to maintain a curated fork to match individual needs.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Device Type Import/Export is inconsistent. While the functionality exists it isn't easy to use in practical terms and the API doesn't appear to fill in all the gaps.
Device type export is everything in one file (multiple objects per device type which is nice) but Import is 1 device type at a time
The problem with this is you can't export out 100's of devices then easily re import them in bulk elsewhere.
The import process is to cut up the export file (manually or using a script) then importing each individual object.
This is impractical to do manually for a large number of devices, it can be scripted though and the API used to manage the loading (slightly more complicated as you need to create related objects , eg interfaces, individually and link them back to newly create Device Type but if you know how to write something to talk to the api it shouldn't be a big deal.)
An example of somebody else doing import is here (https://github.com/minitriga/Netbox-Device-Type-Library-Import)
Front and rear images are inaccessible.
The export doesn't included images in anyway, eg path + filename, url. The API does include the image url but the API auth doesn't appear to be able to access that url.
There doesn't appear to be any way to add images or image paths when importing, I can't see how to load a front/rear image though the API either though it does have a link.
note the front and rear images don't appear to be image_attachments in the API but something else
The solution here is a combination of copying all the image files from the source server to the destination server, then grabbing the dcim_devicetype, and dcim_manufacturer tables from the source server and using that to put the correct filenames directly into the db on the destination server.
eg create a temp table based on the dcim_devicetype table + dcim_manufacture.slug of the source db to update the destination db
Possible Solutions
Fixing the existing export/import functionality
The end result internally may look something like this
similar to the community library https://github.com/netbox-community/devicetype-library
A step further
A new UI and functionality based on the above that uses git repository(s) instead of zip archives.
The advantage of using a git repository would be the ability to one or many git repositories and then cherry pick which manufactures or individual devices are synchronized between netbox and the git repository.
The options in the UI for sync
These options would be available at a repository, manufacturer and model levels.
The advantage of using git repositories over the archive only is they will encourage community sharing while at the same time making it easy to maintain a curated fork to match individual needs.
Beta Was this translation helpful? Give feedback.
All reactions