Netbox v3.7.6's Interface's exported CSV can't be re-imported with the device name changed to another existing device: errors: header name case mismatch and invalid type choice #9702

Closed
opened 2025-12-29 21:21:14 +01:00 by adam · 3 comments
Owner

Originally created by @LinuxMagicSupportTeam on GitHub (May 18, 2024).

Deployment Type

Self-hosted

NetBox Version

v3.7.6

Python Version

3.10

Steps to Reproduce

Devices / Device Components / Interfaces / Export|Import:

  • Export the Interfaces, Current View or All Data (CSV)
  • modify the CSV data with another existing device's name
    (the purpose is to "clone" the interfaces for the new device, which is a clone of the another device)
  • Import with "Direct Import" or Upload file

Issue 1: the exported CSV's headers have upper case letters which the Import process can't recognize.
Issue 2: all the "type" values seem to be invalid choices, despite the data being specified by the Export process

sample CSV data:

name,device,label,enabled,type,description
Eth1,testdev,,True,SFP (2GFC),
ETH2,testdev,,True,1000BASE-T (1GE),
ETH3,testdev,,True,100BASE-FX (10/100ME FIBER),
ETH4,testdev,,True,1000BASE-T (1GE),
ETH5,testdev,,True,1000BASE-T (1GE),
SFP-1,testdev,,True,SFP (1GE),
SFP-2,testdev,,True,SFP (1GFC),

e.g. Error shown:

Record 1 type: Select a valid choice. SFP (2GFC) is not one of the available choices. 
SFP (2GFC) is not one of the available choices. 

Expected Behavior

The Exported CSV should be importable by the Import process without the header and type issues.

Observed Behavior

CSV headers in upper case not recognized

"type" data all seem to be invalid

Originally created by @LinuxMagicSupportTeam on GitHub (May 18, 2024). ### Deployment Type Self-hosted ### NetBox Version v3.7.6 ### Python Version 3.10 ### Steps to Reproduce Devices / Device Components / Interfaces / Export|Import: * Export the Interfaces, Current View or All Data (CSV) * modify the CSV data with another existing device's name (the purpose is to "clone" the interfaces for the new device, which is a clone of the another device) * Import with "Direct Import" or Upload file Issue 1: the exported CSV's headers have upper case letters which the Import process can't recognize. Issue 2: all the "type" values seem to be invalid choices, despite the data being specified by the Export process sample CSV data: ``` name,device,label,enabled,type,description Eth1,testdev,,True,SFP (2GFC), ETH2,testdev,,True,1000BASE-T (1GE), ETH3,testdev,,True,100BASE-FX (10/100ME FIBER), ETH4,testdev,,True,1000BASE-T (1GE), ETH5,testdev,,True,1000BASE-T (1GE), SFP-1,testdev,,True,SFP (1GE), SFP-2,testdev,,True,SFP (1GFC), ``` e.g. Error shown: ``` Record 1 type: Select a valid choice. SFP (2GFC) is not one of the available choices. SFP (2GFC) is not one of the available choices. ``` ### Expected Behavior The Exported CSV should be importable by the Import process without the header and type issues. ### Observed Behavior CSV headers in upper case not recognized "type" data all seem to be invalid
adam closed this issue 2025-12-29 21:21:14 +01:00
Author
Owner

@jcollie commented on GitHub (May 18, 2024):

This is a deliberate design decision by the NetBox developers, and they are not open to changing that.

https://github.com/netbox-community/netbox/issues/14502

https://github.com/netbox-community/netbox/wiki/Frequently-Asked-Questions#why-cant-i-pass-exported-data-directly-into-the-import-form

@jcollie commented on GitHub (May 18, 2024): This is a deliberate design decision by the NetBox developers, and they are _not_ open to changing that. https://github.com/netbox-community/netbox/issues/14502 https://github.com/netbox-community/netbox/wiki/Frequently-Asked-Questions#why-cant-i-pass-exported-data-directly-into-the-import-form
Author
Owner

@KPTheProf commented on GitHub (May 20, 2024):

Hi @LinuxMagicSupportTeam I've created export templates to extract the data in a format that I can import back in again to Netbox. Here's the one I use for interfaces. Just create a new template and add a CSV extension. Select DCIM | Interface as the assigned module and then add the below Jinja2 code.

device,name,label,parent,bridge,lag,type,speed,duplex,enabled,mark_connected,mac_address,wwn,vdcs,mtu,mgmt_only,description,poe_mode,poe_type,mode,vrf,rf_role,rf_channel,rf_channel_frequency,rf_channel_width,tx_power,tags,id
{% for obj in queryset -%}
  {{- obj.device if obj.device is not none }},
  {{- obj.name if obj.name is not none }},
  {{- obj.label | quote if obj.label is not none }},
  {{- obj.parent if obj.parent is not none }},
  {{- obj.bridge if obj.bridge is not none }},
  {{- obj.lag if obj.lag is not none }},
  {{- obj.type if obj.type is not none }},
  {{- obj.speed if obj.speed is not none }},
  {{- obj.duplex if obj.duplex is not none }},
  {{- obj.enabled if obj.enabled is not none }},
  {{- obj.mark_connected if obj.mark_connected is not none }},
  {{- obj.mac_address if obj.mac_address is not none }},
  {{- obj.wwn if obj.wwn is not none }},
  {%- if obj.vdcs is not none %}
    {%- for vdc in obj.vdcs.all() -%}
      {{- '"' if loop.first }}
      {{- vdc.name if vdc.name is not none }}{{- "," if not loop.last }}
      {{- '"' if loop.last }}
    {%- endfor %}
  {%- endif %},
  {{- obj.mtu if obj.mtu is not none }},
  {{- obj.mgmt_only if obj.mgmt_only is not none }},
  {{- obj.description | quote if obj.description is not none }},
  {{- obj.poe_mode if obj.poe_mode is not none }},
  {{- obj.poe_type if obj.poe_type is not none }},
  {{- obj.mode if obj.mode is not none }},
  {{- obj.vrf.rd if obj.vrf is not none }},
  {{- obj.rf_role if obj.rf_role is not none }},
  {{- obj.rf_channel if obj.rf_channel is not none }},
  {{- obj.rf_channel_frequency if obj.rf_channel_frequency is not none }},
  {{- obj.rf_channel_width if obj.rf_channel_width is not none }},
  {{- obj.tx_power if obj.tx_power is not none }},
  {%- if obj.tags is not none %}
    {%- for tag in obj.tags.all() -%}
      {{- '"' if loop.first }}
      {{- tag.slug if tag.slug is not none }}{{- "," if not loop.last }}
      {{- '"' if loop.last }}
    {%- endfor %}
  {%- endif %},
  {{- obj.id if obj.id is not none }}
{% endfor %}
@KPTheProf commented on GitHub (May 20, 2024): Hi @LinuxMagicSupportTeam I've created export templates to extract the data in a format that I can import back in again to Netbox. Here's the one I use for interfaces. Just create a new template and add a CSV extension. Select DCIM | Interface as the assigned module and then add the below Jinja2 code. ``` device,name,label,parent,bridge,lag,type,speed,duplex,enabled,mark_connected,mac_address,wwn,vdcs,mtu,mgmt_only,description,poe_mode,poe_type,mode,vrf,rf_role,rf_channel,rf_channel_frequency,rf_channel_width,tx_power,tags,id {% for obj in queryset -%} {{- obj.device if obj.device is not none }}, {{- obj.name if obj.name is not none }}, {{- obj.label | quote if obj.label is not none }}, {{- obj.parent if obj.parent is not none }}, {{- obj.bridge if obj.bridge is not none }}, {{- obj.lag if obj.lag is not none }}, {{- obj.type if obj.type is not none }}, {{- obj.speed if obj.speed is not none }}, {{- obj.duplex if obj.duplex is not none }}, {{- obj.enabled if obj.enabled is not none }}, {{- obj.mark_connected if obj.mark_connected is not none }}, {{- obj.mac_address if obj.mac_address is not none }}, {{- obj.wwn if obj.wwn is not none }}, {%- if obj.vdcs is not none %} {%- for vdc in obj.vdcs.all() -%} {{- '"' if loop.first }} {{- vdc.name if vdc.name is not none }}{{- "," if not loop.last }} {{- '"' if loop.last }} {%- endfor %} {%- endif %}, {{- obj.mtu if obj.mtu is not none }}, {{- obj.mgmt_only if obj.mgmt_only is not none }}, {{- obj.description | quote if obj.description is not none }}, {{- obj.poe_mode if obj.poe_mode is not none }}, {{- obj.poe_type if obj.poe_type is not none }}, {{- obj.mode if obj.mode is not none }}, {{- obj.vrf.rd if obj.vrf is not none }}, {{- obj.rf_role if obj.rf_role is not none }}, {{- obj.rf_channel if obj.rf_channel is not none }}, {{- obj.rf_channel_frequency if obj.rf_channel_frequency is not none }}, {{- obj.rf_channel_width if obj.rf_channel_width is not none }}, {{- obj.tx_power if obj.tx_power is not none }}, {%- if obj.tags is not none %} {%- for tag in obj.tags.all() -%} {{- '"' if loop.first }} {{- tag.slug if tag.slug is not none }}{{- "," if not loop.last }} {{- '"' if loop.last }} {%- endfor %} {%- endif %}, {{- obj.id if obj.id is not none }} {% endfor %} ```
Author
Owner

@jeremystretch commented on GitHub (May 20, 2024):

Please see the FAQ on our wiki. Please also remember to search for issues before creating a new one.

@jeremystretch commented on GitHub (May 20, 2024): Please see the [FAQ](https://github.com/netbox-community/netbox/wiki/Frequently-Asked-Questions#why-cant-i-pass-exported-data-directly-into-the-import-form) on our wiki. Please also remember to search for issues before creating a new one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9702