diff --git a/netbox/dcim/forms.py b/netbox/dcim/forms.py index 4c81ae9ff..8a0008696 100644 --- a/netbox/dcim/forms.py +++ b/netbox/dcim/forms.py @@ -925,7 +925,7 @@ class InterfaceForm(forms.ModelForm, BootstrapMixin): class Meta: model = Interface - fields = ['device', 'name', 'form_factor', 'mgmt_only', 'description'] + fields = ['device', 'name', 'form_factor', 'mac_address', 'mgmt_only', 'description'] widgets = { 'device': forms.HiddenInput(), } @@ -936,7 +936,7 @@ class InterfaceCreateForm(forms.ModelForm, BootstrapMixin): class Meta: model = Interface - fields = ['name_pattern', 'form_factor', 'mgmt_only', 'description'] + fields = ['name_pattern', 'form_factor', 'mac_address', 'mgmt_only', 'description'] class InterfaceBulkCreateForm(InterfaceCreateForm, BootstrapMixin): diff --git a/netbox/dcim/migrations/0004_interface_mac_address.py b/netbox/dcim/migrations/0004_interface_mac_address.py new file mode 100644 index 000000000..5dd393ab1 --- /dev/null +++ b/netbox/dcim/migrations/0004_interface_mac_address.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-01 13:53 +from __future__ import unicode_literals + +from django.db import migrations +import macaddress.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('dcim', '0003_auto_20160628_1721'), + ] + + operations = [ + migrations.AddField( + model_name='interface', + name='mac_address', + field=macaddress.fields.MACAddressField(blank=True, integer=True, null=True), + ), + ] diff --git a/netbox/dcim/models.py b/netbox/dcim/models.py index 21f775fd0..5670516e3 100644 --- a/netbox/dcim/models.py +++ b/netbox/dcim/models.py @@ -10,6 +10,7 @@ from extras.rpc import RPC_CLIENTS from utilities.fields import NullableCharField from utilities.models import CreatedUpdatedModel +from macaddress.fields import MACAddressField RACK_FACE_FRONT = 0 RACK_FACE_REAR = 1 @@ -856,6 +857,7 @@ class Interface(models.Model): device = models.ForeignKey('Device', related_name='interfaces', on_delete=models.CASCADE) name = models.CharField(max_length=30) form_factor = models.PositiveSmallIntegerField(choices=IFACE_FF_CHOICES, default=IFACE_FF_SFP_PLUS) + mac_address = MACAddressField(null=True, blank=True, verbose_name='MAC Address') mgmt_only = models.BooleanField(default=False, verbose_name='OOB Management', help_text="This interface is used only for out-of-band management") description = models.CharField(max_length=100, blank=True) diff --git a/netbox/dcim/views.py b/netbox/dcim/views.py index e8f3e4d77..2c4526163 100644 --- a/netbox/dcim/views.py +++ b/netbox/dcim/views.py @@ -1339,6 +1339,7 @@ class InterfaceBulkAddView(PermissionRequiredMixin, BulkEditView): iface_form = forms.InterfaceForm({ 'device': device.pk, 'name': name, + 'mac_address': mac_address, 'form_factor': form.cleaned_data['form_factor'], 'mgmt_only': form.cleaned_data['mgmt_only'], 'description': form.cleaned_data['description'], diff --git a/netbox/templates/dcim/inc/_interface.html b/netbox/templates/dcim/inc/_interface.html index 84af875e4..28d14946d 100644 --- a/netbox/templates/dcim/inc/_interface.html +++ b/netbox/templates/dcim/inc/_interface.html @@ -6,7 +6,7 @@ {% endif %} {% if not iface.is_physical %} -