Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #16190

Closed
LinuxMagicSupportTeam opened this issue May 18, 2024 · 3 comments

Comments

@LinuxMagicSupportTeam
Copy link

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

@LinuxMagicSupportTeam LinuxMagicSupportTeam added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 18, 2024
@jcollie
Copy link

jcollie commented May 18, 2024

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

#14502

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

@KPTheProf
Copy link

KPTheProf commented 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 %}

@jeremystretch
Copy link
Member

jeremystretch commented May 20, 2024

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

@jeremystretch jeremystretch closed this as not planned Won't fix, can't repro, duplicate, stale May 20, 2024
@jeremystretch jeremystretch removed type: bug A confirmed report of unexpected behavior in the application status: needs triage This issue is awaiting triage by a maintainer labels May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants