diff --git a/machines/__pycache__/admin.cpython-34.pyc b/machines/__pycache__/admin.cpython-34.pyc index 737c879e..ee624fa2 100644 Binary files a/machines/__pycache__/admin.cpython-34.pyc and b/machines/__pycache__/admin.cpython-34.pyc differ diff --git a/machines/__pycache__/models.cpython-34.pyc b/machines/__pycache__/models.cpython-34.pyc index 8529d171..1b4447b2 100644 Binary files a/machines/__pycache__/models.cpython-34.pyc and b/machines/__pycache__/models.cpython-34.pyc differ diff --git a/machines/admin.py b/machines/admin.py index 83317546..a3d480ac 100644 --- a/machines/admin.py +++ b/machines/admin.py @@ -1,6 +1,6 @@ from django.contrib import admin -from .models import Machine, MachineType +from .models import Machine, MachineType, IpList, Interface class MachineAdmin(admin.ModelAdmin): list_display = ('user','type') @@ -8,5 +8,13 @@ class MachineAdmin(admin.ModelAdmin): class MachineTypeAdmin(admin.ModelAdmin): list_display = ('type',) +class IpListAdmin(admin.ModelAdmin): + list_display = ('ipv4',) + +class InterfaceAdmin(admin.ModelAdmin): + list_display = ('machine','name','mac_address','ipv4','details') + admin.site.register(Machine, MachineAdmin) admin.site.register(MachineType, MachineTypeAdmin) +admin.site.register(IpList, IpListAdmin) +admin.site.register(Interface, InterfaceAdmin) diff --git a/machines/migrations/0002_auto_20160703_1444.py b/machines/migrations/0002_auto_20160703_1444.py new file mode 100644 index 00000000..18ab1768 --- /dev/null +++ b/machines/migrations/0002_auto_20160703_1444.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import macaddress.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('machines', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Interface', + fields=[ + ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), + ('ipv6', models.GenericIPAddressField(protocol='IPv6')), + ('mac_address', macaddress.fields.MACAddressField(integer=True)), + ('details', models.CharField(max_length=255)), + ('name', models.CharField(max_length=255, blank=True, unique=True)), + ], + ), + migrations.CreateModel( + name='IpList', + fields=[ + ('id', models.AutoField(serialize=False, verbose_name='ID', auto_created=True, primary_key=True)), + ('ipv4', models.GenericIPAddressField(protocol='IPv4')), + ], + ), + migrations.AddField( + model_name='interface', + name='ipv4', + field=models.OneToOneField(null=True, to='machines.IpList', blank=True, on_delete=django.db.models.deletion.PROTECT), + ), + migrations.AddField( + model_name='interface', + name='machine', + field=models.ForeignKey(to='machines.Machine', on_delete=django.db.models.deletion.PROTECT), + ), + ] diff --git a/machines/migrations/__pycache__/0002_auto_20160703_1444.cpython-34.pyc b/machines/migrations/__pycache__/0002_auto_20160703_1444.cpython-34.pyc new file mode 100644 index 00000000..1c29c050 Binary files /dev/null and b/machines/migrations/__pycache__/0002_auto_20160703_1444.cpython-34.pyc differ diff --git a/machines/models.py b/machines/models.py index 49b794ed..38c5af50 100644 --- a/machines/models.py +++ b/machines/models.py @@ -1,4 +1,5 @@ from django.db import models +from macaddress.fields import MACAddressField from users.models import User @@ -16,4 +17,19 @@ class MachineType(models.Model): return self.type +class Interface(models.Model): + ipv4 = models.OneToOneField('IpList', on_delete=models.PROTECT, blank=True, null=True) + ipv6 = models.GenericIPAddressField(protocol='IPv6') + mac_address = MACAddressField() + machine = models.ForeignKey('Machine', on_delete=models.PROTECT) + details = models.CharField(max_length=255) + name = models.CharField(max_length=255, unique=True, blank=True) + def __str__(self): + return self.name + +class IpList(models.Model): + ipv4 = models.GenericIPAddressField(protocol='IPv4') + + def __str__(self): + return self.type