mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Add MAC address field to interfaces
This commit is contained in:
@ -925,7 +925,7 @@ class InterfaceForm(forms.ModelForm, BootstrapMixin):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ['device', 'name', 'form_factor', 'mgmt_only', 'description']
|
fields = ['device', 'name', 'form_factor', 'mac_address', 'mgmt_only', 'description']
|
||||||
widgets = {
|
widgets = {
|
||||||
'device': forms.HiddenInput(),
|
'device': forms.HiddenInput(),
|
||||||
}
|
}
|
||||||
@ -936,7 +936,7 @@ class InterfaceCreateForm(forms.ModelForm, BootstrapMixin):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Interface
|
model = Interface
|
||||||
fields = ['name_pattern', 'form_factor', 'mgmt_only', 'description']
|
fields = ['name_pattern', 'form_factor', 'mac_address', 'mgmt_only', 'description']
|
||||||
|
|
||||||
|
|
||||||
class InterfaceBulkCreateForm(InterfaceCreateForm, BootstrapMixin):
|
class InterfaceBulkCreateForm(InterfaceCreateForm, BootstrapMixin):
|
||||||
|
21
netbox/dcim/migrations/0004_interface_mac_address.py
Normal file
21
netbox/dcim/migrations/0004_interface_mac_address.py
Normal file
@ -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),
|
||||||
|
),
|
||||||
|
]
|
@ -10,6 +10,7 @@ from extras.rpc import RPC_CLIENTS
|
|||||||
from utilities.fields import NullableCharField
|
from utilities.fields import NullableCharField
|
||||||
from utilities.models import CreatedUpdatedModel
|
from utilities.models import CreatedUpdatedModel
|
||||||
|
|
||||||
|
from macaddress.fields import MACAddressField
|
||||||
|
|
||||||
RACK_FACE_FRONT = 0
|
RACK_FACE_FRONT = 0
|
||||||
RACK_FACE_REAR = 1
|
RACK_FACE_REAR = 1
|
||||||
@ -856,6 +857,7 @@ class Interface(models.Model):
|
|||||||
device = models.ForeignKey('Device', related_name='interfaces', on_delete=models.CASCADE)
|
device = models.ForeignKey('Device', related_name='interfaces', on_delete=models.CASCADE)
|
||||||
name = models.CharField(max_length=30)
|
name = models.CharField(max_length=30)
|
||||||
form_factor = models.PositiveSmallIntegerField(choices=IFACE_FF_CHOICES, default=IFACE_FF_SFP_PLUS)
|
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',
|
mgmt_only = models.BooleanField(default=False, verbose_name='OOB Management',
|
||||||
help_text="This interface is used only for out-of-band management")
|
help_text="This interface is used only for out-of-band management")
|
||||||
description = models.CharField(max_length=100, blank=True)
|
description = models.CharField(max_length=100, blank=True)
|
||||||
|
@ -1339,6 +1339,7 @@ class InterfaceBulkAddView(PermissionRequiredMixin, BulkEditView):
|
|||||||
iface_form = forms.InterfaceForm({
|
iface_form = forms.InterfaceForm({
|
||||||
'device': device.pk,
|
'device': device.pk,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
'mac_address': mac_address,
|
||||||
'form_factor': form.cleaned_data['form_factor'],
|
'form_factor': form.cleaned_data['form_factor'],
|
||||||
'mgmt_only': form.cleaned_data['mgmt_only'],
|
'mgmt_only': form.cleaned_data['mgmt_only'],
|
||||||
'description': form.cleaned_data['description'],
|
'description': form.cleaned_data['description'],
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
{% if not iface.is_physical %}
|
{% if not iface.is_physical %}
|
||||||
<td colspan="2">Virtual</td>
|
<td>Virtual</td>
|
||||||
{% elif iface.connection %}
|
{% elif iface.connection %}
|
||||||
{% with iface.get_connected_interface as connected_iface %}
|
{% with iface.get_connected_interface as connected_iface %}
|
||||||
<td>
|
<td>
|
||||||
@ -17,11 +17,16 @@
|
|||||||
</td>
|
</td>
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
{% elif iface.circuit %}
|
{% elif iface.circuit %}
|
||||||
<td colspan="2">
|
<td>
|
||||||
<a href="{% url 'circuits:circuit' pk=iface.circuit.pk %}">{{ iface.circuit }}</a>
|
<a href="{% url 'circuits:circuit' pk=iface.circuit.pk %}">{{ iface.circuit }}</a>
|
||||||
</td>
|
</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
<td colspan="2">Not connected</td>
|
<td>Not connected</td>
|
||||||
|
{% endif %}
|
||||||
|
{% if iface.mac_address %}
|
||||||
|
<td><span class="small text-muted">{{ iface.mac_address }}</span></td>
|
||||||
|
{% else %}
|
||||||
|
<td><span class="small text-muted">00:00:00:00:00:00</span></td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td class="text-right">
|
<td class="text-right">
|
||||||
{% if iface.circuit or iface.connection %}
|
{% if iface.circuit or iface.connection %}
|
||||||
|
@ -5,6 +5,7 @@ django-filter==0.13.0
|
|||||||
django-rest-swagger==0.3.7
|
django-rest-swagger==0.3.7
|
||||||
django-tables2==1.2.1
|
django-tables2==1.2.1
|
||||||
djangorestframework==3.3.3
|
djangorestframework==3.3.3
|
||||||
|
django-macaddress==1.3.2
|
||||||
graphviz==0.4.10
|
graphviz==0.4.10
|
||||||
Markdown==2.6.6
|
Markdown==2.6.6
|
||||||
ncclient==0.4.7
|
ncclient==0.4.7
|
||||||
|
Reference in New Issue
Block a user