Prefix CSV Import: Problem with VLANs #4677

Closed
opened 2025-12-29 19:19:23 +01:00 by adam · 4 comments
Owner

Originally created by @Qumoo on GitHub (Mar 18, 2021).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v2.10.6

Python version

3.7.3

Steps to Reproduce

  1. Create a VLAN group for one office, lets call it A (just a VLAN group without region or site)
  2. Create two VLANs one assigned to group A and one assigned to a site (in my case Test-Site) - both with id 20
  3. Try csv bulk importing with site in the csv-header
    Example CSV:
    prefix,status,vlan_group,vlan,site
    192.168.123.0/24,active,A,20,
    192.168.122.0/24,active,,20,Test-Site

Expected Behavior

It should import the prefixes since both VLANs are existing and identified.

Observed Behavior

"Row 1 vlan: Object not found"

When importing the prefixes for a VLAN that doesn't have a site assigned you need to remove the site from the csv-header.
Example CSV for importing prefixes when VLAN doesnt have a site assigned:
prefix,status,vlan_group,vlan
192.168.123.0/24,active,A,20

At the moment you would need to split your csv files to "has-a-site" and "no-site" and import separately.
Is this intended behaviour? If so could you add it to the documentation?

Originally created by @Qumoo on GitHub (Mar 18, 2021). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v2.10.6 ### Python version 3.7.3 ### Steps to Reproduce 1. Create a VLAN group for one office, lets call it A (just a VLAN group without region or site) 2. Create two VLANs one assigned to group A and one assigned to a site (in my case Test-Site) - both with id 20 3. Try csv bulk importing with site in the csv-header Example CSV: prefix,status,vlan_group,vlan,site 192.168.123.0/24,active,A,20, 192.168.122.0/24,active,,20,Test-Site ### Expected Behavior It should import the prefixes since both VLANs are existing and identified. ### Observed Behavior "Row 1 vlan: Object not found" When importing the prefixes for a VLAN that doesn't have a site assigned you need to remove the site from the csv-header. Example CSV for importing prefixes when VLAN doesnt have a site assigned: prefix,status,vlan_group,vlan 192.168.123.0/24,active,A,20 At the moment you would need to split your csv files to "has-a-site" and "no-site" and import separately. Is this intended behaviour? If so could you add it to the documentation?
adam added the type: bugstatus: accepted labels 2025-12-29 19:19:23 +01:00
adam closed this issue 2025-12-29 19:19:23 +01:00
Author
Owner

@jeremystretch commented on GitHub (Mar 19, 2021):

192.168.123.0/24,active,A,20,

You need to specify the site as well. Otherwise, NetBox looks for a VLAN assigned to group A but not assigned to a site, which doesn't exist, hence the error message.

@jeremystretch commented on GitHub (Mar 19, 2021): > 192.168.123.0/24,active,A,20, You need to specify the site as well. Otherwise, NetBox looks for a VLAN assigned to group A but _not_ assigned to a site, which doesn't exist, hence the error message.
Author
Owner

@Qumoo commented on GitHub (Mar 19, 2021):

There is a vlan 20 assigned to group A with no site assignment on the vlan or vlan group.
If I try import a prefix via csv that has this vlan with given CSV
prefix,status,vlan_group,vlan,site
192.168.123.0/24,active,A,20,

it fails.
So Netbox looking for A VLAN assigned to group A but not assigned to a site should yield in VLAN 20 assigned to group A without a site assignment but it doesn't.

@Qumoo commented on GitHub (Mar 19, 2021): There is a vlan 20 assigned to group A with no site assignment on the vlan or vlan group. If I try import a prefix via csv that has this vlan with given CSV prefix,status,vlan_group,vlan,site 192.168.123.0/24,active,A,20, it fails. So Netbox looking for A VLAN assigned to group A but not assigned to a site should yield in VLAN 20 assigned to group A without a site assignment but it doesn't.
Author
Owner

@jeremystretch commented on GitHub (Mar 19, 2021):

You said:

Create a VLAN group for one office, lets call it A

but then

(just a VLAN group without region or site)

Ok, so this is group is not for the site, but rather a global group.

So what's happening is NetBox is looking for a VLAN assigned to a site with a null name (which can't exist). It looks like the import form is forcing this filtering regardless of whether a value has been specified. Should be an easy fix.

@jeremystretch commented on GitHub (Mar 19, 2021): You said: > Create a VLAN group for one office, lets call it A but then > (just a VLAN group without region or site) Ok, so this is group is _not_ for the site, but rather a global group. So what's happening is NetBox is looking for a VLAN assigned to a site with a null name (which can't exist). It looks like the import form is [forcing this filtering](https://github.com/netbox-community/netbox/blob/91fe80f73c12bb4182ee892ca612252e9a30126b/netbox/ipam/forms.py#L469) regardless of whether a value has been specified. Should be an easy fix.
Author
Owner

@Qumoo commented on GitHub (Mar 19, 2021):

Sorry for the confusion but that is what I meant. Thanks.

@Qumoo commented on GitHub (Mar 19, 2021): Sorry for the confusion but that is what I meant. Thanks.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#4677