CSV import of IP Addresses with attached interface throws exception #3707

Closed
opened 2025-12-29 18:30:42 +01:00 by adam · 2 comments
Owner

Originally created by @DanSheps on GitHub (May 19, 2020).

Environment

  • Python version: 3.6
  • NetBox version: 2.8.4

Steps to Reproduce

  1. Disable any installed plugins by commenting out the PLUGINS setting in
    configuration.py.
  2. Create a device (D1)
  3. Add a interface (Intf!)
  4. Import ip addresses in the following format:
address,status,device,interface
10.231.1.23/24,Active,D1,Intf1

Expected Behavior

Import to suceed

Observed Behavior

<class 'KeyError'>

'interface_name'
Originally created by @DanSheps on GitHub (May 19, 2020). ### Environment * Python version: 3.6 * NetBox version: 2.8.4 ### Steps to Reproduce 1. Disable any installed plugins by commenting out the `PLUGINS` setting in `configuration.py`. 2. Create a device (D1) 3. Add a interface (Intf!) 4. Import ip addresses in the following format: ``` address,status,device,interface 10.231.1.23/24,Active,D1,Intf1 ``` ### Expected Behavior Import to suceed ### Observed Behavior ``` <class 'KeyError'> 'interface_name' ```
adam closed this issue 2025-12-29 18:30:42 +01:00
Author
Owner

@DanSheps commented on GitHub (May 19, 2020):

Root cause (netbox/ipam/forms.py):

    def save(self, *args, **kwargs):

        # Set interface
        if self.cleaned_data['device'] and self.cleaned_data['interface_name']:
            self.instance.interface = Interface.objects.get(
                device=self.cleaned_data['device'],
                name=self.cleaned_data['interface_name']
            )
        elif self.cleaned_data['virtual_machine'] and self.cleaned_data['interface_name']:
            self.instance.interface = Interface.objects.get(
                virtual_machine=self.cleaned_data['virtual_machine'],
                name=self.cleaned_data['interface_name']
            )
@DanSheps commented on GitHub (May 19, 2020): Root cause (`netbox/ipam/forms.py`): ``` def save(self, *args, **kwargs): # Set interface if self.cleaned_data['device'] and self.cleaned_data['interface_name']: self.instance.interface = Interface.objects.get( device=self.cleaned_data['device'], name=self.cleaned_data['interface_name'] ) elif self.cleaned_data['virtual_machine'] and self.cleaned_data['interface_name']: self.instance.interface = Interface.objects.get( virtual_machine=self.cleaned_data['virtual_machine'], name=self.cleaned_data['interface_name'] ) ```
Author
Owner

@DanSheps commented on GitHub (May 19, 2020):

Duplicate of #4649

Whoops

@DanSheps commented on GitHub (May 19, 2020): Duplicate of #4649 Whoops
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#3707