CSV importing ip-address with nat_inside do not work #2554

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

Originally created by @Grokzen on GitHub (Apr 26, 2019).

Environment

  • Python version: 3.6.x
  • NetBox version: 2.5.10

Steps to Reproduce

  1. Create an IP address that will later be used for nat_inside
  2. Create a CSV datablob that is capable of importing a new IP address. Use another IP as the one you want to import, but set the ip address from 1. as the nat_inside address.

Expected Behavior

Import works and a new ip address is created with a nat_inside address set on it. The side-bar describes that it should be possible to import it with an nat_inside address set.

Observed Behavior

A form validation error is thrown

Row 1 nat_inside: Select a valid choice. That choice is not one of the available choices

Possible solutions.

Either remove nat_inside from the sidebar as a valid csv column.

Or add the following to the class IPAddressCSVForm

    nat_inside = FlexibleModelChoiceField(
        queryset=IPAddress.objects.all(),
        required=False,
        to_field_name='address',
        help_text='',
        error_messages={
            'invalid_choice': 'IP Address not found',
        }
    )

and you would be able to import nat_inside addresses again.

Originally created by @Grokzen on GitHub (Apr 26, 2019). <!-- NOTE: This form is only for reproducible bugs. If you need assistance with NetBox installation, or if you have a general question, DO NOT open an issue. Instead, post to our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please describe the environment in which you are running NetBox. Be sure that you are running an unmodified instance of the latest stable release before submitting a bug report. --> ### Environment * Python version: 3.6.x <!-- Example: 3.5.4 --> * NetBox version: 2.5.10 <!-- Example: 2.5.2 --> <!-- Describe in detail the exact steps that someone else can take to reproduce this bug using the current stable release of NetBox (or the current beta release where applicable). Begin with the creation of any necessary database objects and call out every operation being performed explicitly. If reporting a bug in the REST API, be sure to reconstruct the raw HTTP request(s) being made: Don't rely on a wrapper like pynetbox. --> ### Steps to Reproduce 1. Create an IP address that will later be used for nat_inside 2. Create a CSV datablob that is capable of importing a new IP address. Use another IP as the one you want to import, but set the ip address from `1.` as the nat_inside address. <!-- What did you expect to happen? --> ### Expected Behavior Import works and a new ip address is created with a nat_inside address set on it. The side-bar describes that it should be possible to import it with an nat_inside address set. <!-- What happened instead? --> ### Observed Behavior A form validation error is thrown `Row 1 nat_inside: Select a valid choice. That choice is not one of the available choices` ### Possible solutions. Either remove nat_inside from the sidebar as a valid csv column. Or add the following to the class `IPAddressCSVForm` ``` nat_inside = FlexibleModelChoiceField( queryset=IPAddress.objects.all(), required=False, to_field_name='address', help_text='', error_messages={ 'invalid_choice': 'IP Address not found', } ) ``` and you would be able to import nat_inside addresses again.
adam added the status: under review label 2025-12-29 18:19:54 +01:00
adam closed this issue 2025-12-29 18:19:54 +01:00
Author
Owner

@jeremystretch commented on GitHub (Apr 26, 2019):

Import works and a new ip address is created with a nat_inside address set on it. The side-bar describes that it should be possible to import it with an nat_inside address set.

Where do you see this? nat_inside is not a supported field for IP address imports in v2.5.10, and I'm fairly sure it hasn't ever been. Are you running a custom fork?

@jeremystretch commented on GitHub (Apr 26, 2019): > Import works and a new ip address is created with a nat_inside address set on it. The side-bar describes that it should be possible to import it with an nat_inside address set. Where do you see this? `nat_inside` is not [a supported field](https://github.com/digitalocean/netbox/blob/master/netbox/ipam/models.py#L589) for IP address imports in v2.5.10, and I'm fairly sure it hasn't ever been. Are you running a custom fork?
Author
Owner

@Grokzen commented on GitHub (Apr 27, 2019):

You are correct, it had snuck in to the csv_headers as a part of extending the export part and it looked like it was supported by default for import part as well.

@Grokzen commented on GitHub (Apr 27, 2019): You are correct, it had snuck in to the csv_headers as a part of extending the export part and it looked like it was supported by default for import part as well.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#2554