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

IP objects with NAT throws error when trying to edit them #1238

Closed
r-bhikhie opened this issue May 30, 2017 · 5 comments
Closed

IP objects with NAT throws error when trying to edit them #1238

r-bhikhie opened this issue May 30, 2017 · 5 comments
Labels
type: bug A confirmed report of unexpected behavior in the application

Comments

@r-bhikhie
Copy link

Issue type: bug report

Python version: Python 2.7.9 (default, Sep 17 2016, 20:26:04)
NetBox version: Release v2.0.4 commit f7b0d22
Django version: Version: 1.11.1
nginx version: nginx/1.6.2
Gunicorn version: gunicorn (version 19.7.1)

Steps to recreate:

-Log in with user account
-Click IP space > IP Addresses
-Go to page 3
-Click the IP address of the object (/ipam/ip-addresses/203/)
-Click "Edit This IP" on the right hand side
-Error appears:
<type 'exceptions.AttributeError'>

'NoneType' object has no attribute 'site'

The object in question, I've tried to pull it from the API pages:

GET /api/ipam/ip-addresses/?family=&id__in=203&q=&parent=&mask_length=
HTTP 200 OK
Allow: GET, POST, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 203,
            "family": 4,
            "address": "192.168.1.10/32",
            "vrf": null,
            "tenant": null,
            "status": {
                "value": 1,
                "label": "Active"
            },
            "interface": null,
            "description": "pFSense VM - WAN",
            "nat_inside": {
                "id": 359,
                "url": "http://192.168.1.85/api/ipam/ip-addresses/359/",
                "family": 4,
                "address": "172.16.0.1/32"
            },
            "nat_outside": null,
            "custom_fields": {}
        }
    ]
}

@r-bhikhie r-bhikhie changed the title IP objects with NAT throw error when trying to edit them IP objects with NAT throws error when trying to edit them May 30, 2017
@jeremystretch
Copy link
Member

I'm not able to replicate this. Can you set DEBUG=True in configuration.py and try again? Please post the full stack trace from the error it yields.

@r-bhikhie
Copy link
Author

Is this the correct part?

Environment:


Request Method: GET
Request URL: http://192.168.1.85/ipam/ip-addresses/3/edit/

Django Version: 1.11.1
Python Version: 2.7.9
Installed Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'django.contrib.humanize',
 'corsheaders',
 'debug_toolbar',
 'django_filters',
 'django_tables2',
 'mptt',
 'rest_framework',
 'rest_framework_swagger',
 'circuits',
 'dcim',
 'ipam',
 'extras',
 'secrets',
 'tenancy',
 'users',
 'utilities')
Installed Middleware:
('debug_toolbar.middleware.DebugToolbarMiddleware',
 'corsheaders.middleware.CorsMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'utilities.middleware.LoginRequiredMiddleware',
 'utilities.middleware.APIVersionMiddleware')



Traceback:

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/exception.py" in inner
  41.             response = get_response(request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in view
  68.             return self.dispatch(request, *args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/mixins.py" in dispatch
  92.         return super(PermissionRequiredMixin, self).dispatch(request, *args, **kwargs)

File "/usr/local/lib/python2.7/dist-packages/django/views/generic/base.py" in dispatch
  88.         return handler(request, *args, **kwargs)

File "/opt/netbox/netbox/utilities/views.py" in get
  181.         form = self.form_class(instance=obj, initial=initial_data)

File "/opt/netbox/netbox/ipam/forms.py" in __init__
  445.             initial['nat_site'] = instance.nat_inside.device.site

Exception Type: AttributeError at /ipam/ip-addresses/3/edit/
Exception Value: 'NoneType' object has no attribute 'site'

@jeremystretch
Copy link
Member

Yes, that's it. Thanks.

@jeremystretch jeremystretch added the type: bug A confirmed report of unexpected behavior in the application label Jun 1, 2017
@r-bhikhie
Copy link
Author

r-bhikhie commented Jun 8, 2017

The issue is still present in 2.0.5.

I tried to set the NAT element to "null" via some clicking in the API, that made the object editable again.
Adding the NAT entry for "172.31.0.1/32" again via the GUI breaks the object as I described before.

@labrnth
Copy link

labrnth commented Jun 9, 2017

I'm getting this same issue on 2.0.4. I haven't yet upgraded to 2.0.5 but will give it a shot.

lampwins pushed a commit to lampwins/netbox that referenced this issue Oct 13, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

3 participants