Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
[controller] Preparation to solve duplicated IP issue
Browse files Browse the repository at this point in the history
  • Loading branch information
nemesifier committed Apr 12, 2020
1 parent 8ab98d6 commit 9648b7c
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions django_netjsonconfig/base/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ class AbstractDevice(BaseModel):
# with data received from devices
last_ip = models.GenericIPAddressField(blank=True,
null=True,
db_index=True,
help_text=_('indicates the IP address logged from '
'the last request coming from the device'))
management_ip = models.GenericIPAddressField(blank=True,
null=True,
db_index=True,
help_text=_('ip address of the management interface, '
'if available'))
hardware_id = models.CharField(**(app_settings.HARDWARE_ID_OPTIONS))
Expand Down
2 changes: 1 addition & 1 deletion django_netjsonconfig/controller/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def dispatch(self, request, *args, **kwargs):

class UpdateLastIpMixin(object):
def update_last_ip(self, device, request):
update_last_ip(device, request)
return update_last_ip(device, request)


class BaseDeviceChecksumView(UpdateLastIpMixin, BaseConfigView):
Expand Down
23 changes: 23 additions & 0 deletions django_netjsonconfig/migrations/0043_add_indexes_on_ip_fields.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.0.4 on 2020-04-12 02:07

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('django_netjsonconfig', '0042_device_key_none'),
]

operations = [
migrations.AlterField(
model_name='device',
name='last_ip',
field=models.GenericIPAddressField(blank=True, db_index=True, help_text='indicates the IP address logged from the last request coming from the device', null=True),
),
migrations.AlterField(
model_name='device',
name='management_ip',
field=models.GenericIPAddressField(blank=True, db_index=True, help_text='ip address of the management interface, if available', null=True),
),
]
1 change: 1 addition & 0 deletions django_netjsonconfig/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def update_last_ip(device, request):
changed = True
if changed:
device.save()
return changed


def forbid_unallowed(request, param_group, param, allowed_values=None):
Expand Down

0 comments on commit 9648b7c

Please sign in to comment.