mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-27 10:58:37 -06:00
Rename field in IPAddr : "hostname" to "ptr"
This commit is contained in:
parent
705690edda
commit
ee78bf5455
@ -335,11 +335,11 @@ class IPAddressForm(forms.ModelForm, BootstrapMixin):
|
||||
|
||||
class Meta:
|
||||
model = IPAddress
|
||||
fields = ['address', 'vrf', 'hostname', 'nat_device', 'nat_inside', 'description']
|
||||
fields = ['address', 'vrf', 'ptr', 'nat_device', 'nat_inside', 'description']
|
||||
help_texts = {
|
||||
'address': "IPv4 or IPv6 address and mask",
|
||||
'vrf': "VRF (if applicable)",
|
||||
'hostname': "Reverse DNS host name",
|
||||
'ptr': "Reverse DNS name",
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
@ -392,7 +392,7 @@ class IPAddressFromCSVForm(forms.ModelForm):
|
||||
|
||||
class Meta:
|
||||
model = IPAddress
|
||||
fields = ['address', 'vrf', 'hostname', 'device', 'interface_name', 'is_primary', 'description']
|
||||
fields = ['address', 'vrf', 'ptr', 'device', 'interface_name', 'is_primary', 'description']
|
||||
|
||||
def clean(self):
|
||||
|
||||
@ -439,7 +439,7 @@ class IPAddressBulkEditForm(forms.Form, BootstrapMixin):
|
||||
pk = forms.ModelMultipleChoiceField(queryset=IPAddress.objects.all(), widget=forms.MultipleHiddenInput)
|
||||
vrf = forms.ModelChoiceField(queryset=VRF.objects.all(), required=False, label='VRF',
|
||||
help_text="Select the VRF to assign, or check below to remove VRF assignment")
|
||||
hostname = forms.CharField(max_length=100, required=False)
|
||||
ptr = forms.CharField(max_length=100, required=False, label='PTR')
|
||||
vrf_global = forms.BooleanField(required=False, label='Set VRF to global')
|
||||
description = forms.CharField(max_length=50, required=False)
|
||||
|
||||
|
24
netbox/ipam/migrations/0008_auto_20160727_1307.py
Normal file
24
netbox/ipam/migrations/0008_auto_20160727_1307.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.9.7 on 2016-07-27 13:07
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('ipam', '0007_auto_20160722_0958'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='ipaddress',
|
||||
name='hostname',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='ipaddress',
|
||||
name='ptr',
|
||||
field=models.CharField(blank=True, max_length=100, verbose_name=b'PTR'),
|
||||
),
|
||||
]
|
@ -376,7 +376,7 @@ class Prefix(CreatedUpdatedModel):
|
||||
|
||||
ipaddresses = IPAddress.objects.filter(family=4)
|
||||
for ip in ipaddresses:
|
||||
if ip.hostname:
|
||||
if ip.ptr:
|
||||
ibytes = str(ip.address).split('/')[0].split('.')
|
||||
islash = str(ip.address).split('/')[1]
|
||||
i = netaddr.IPAddress(unicode('.'.join(ibytes)))
|
||||
@ -386,12 +386,12 @@ class Prefix(CreatedUpdatedModel):
|
||||
zone_id = ibytes[2] + '.' + ibytes[1] + '.' + ibytes[0] + '.in-addr.arpa.'
|
||||
if not zone_id in zones:
|
||||
zones[zone_id] = header(zone_id)
|
||||
zones[zone_id] += ibytes[3].ljust(3) + ' IN PTR ' + ip.hostname.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||
zones[zone_id] += ibytes[3].ljust(3) + ' IN PTR ' + ip.ptr.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||
else:
|
||||
zone_id = ibytes[1]+'.'+ibytes[0]+'.in-addr.arpa.'
|
||||
if not zone_id in zones:
|
||||
zones[zone_id] = header(zone_id)
|
||||
zones[zone_id] += (ibytes[3]+'.'+ibytes[2]).ljust(7) + ' IN PTR ' + ip.hostname.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||
zones[zone_id] += (ibytes[3]+'.'+ibytes[2]).ljust(7) + ' IN PTR ' + ip.ptr.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||
|
||||
|
||||
|
||||
@ -416,7 +416,7 @@ class Prefix(CreatedUpdatedModel):
|
||||
pnibbles = pnibbles[:zslash/16] + ['0000'] * (8 - zslash/16)
|
||||
|
||||
for ip in ipaddresses:
|
||||
if ip.hostname:
|
||||
if ip.ptr:
|
||||
ifull = str(ipaddress.IPv6Address(unicode(str(ip.address).split('/')[0])).exploded)
|
||||
inibbles = ifull.split(':')
|
||||
idigits = ifull.replace(':','')[::-1]
|
||||
@ -427,7 +427,7 @@ class Prefix(CreatedUpdatedModel):
|
||||
if not zone_id in zones:
|
||||
zones[zone_id] = header(zone_id)
|
||||
|
||||
zones[zone_id] += ('.'.join(idigits[:32-zslash/4])).ljust(30)+' IN PTR ' + ip.hostname.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||
zones[zone_id] += ('.'.join(idigits[:32-zslash/4])).ljust(30)+' IN PTR ' + ip.ptr.ljust(40) + ' ; ' + ip.description.ljust(20) + ' ; gen by netbox ( '+time.strftime('%A %B %d %Y %H:%M:%S',time.localtime())+' ) \n'
|
||||
|
||||
|
||||
for z in zones:
|
||||
@ -459,7 +459,7 @@ class IPAddress(CreatedUpdatedModel):
|
||||
address = IPAddressField()
|
||||
vrf = models.ForeignKey('VRF', related_name='ip_addresses', on_delete=models.PROTECT, blank=True, null=True,
|
||||
verbose_name='VRF')
|
||||
hostname = models.CharField(max_length=100, blank=True, verbose_name='Host Name')
|
||||
ptr = models.CharField(max_length=100, blank=True, verbose_name='PTR')
|
||||
interface = models.ForeignKey(Interface, related_name='ip_addresses', on_delete=models.CASCADE, blank=True,
|
||||
null=True)
|
||||
nat_inside = models.OneToOneField('self', related_name='nat_outside', on_delete=models.SET_NULL, blank=True,
|
||||
@ -513,7 +513,7 @@ class IPAddress(CreatedUpdatedModel):
|
||||
return ','.join([
|
||||
str(self.address),
|
||||
self.vrf.rd if self.vrf else '',
|
||||
self.hostname if self.hostname else '',
|
||||
self.ptr if self.ptr else '',
|
||||
self.device.identifier if self.device else '',
|
||||
self.interface.name if self.interface else '',
|
||||
'True' if is_primary else '',
|
||||
|
@ -160,7 +160,7 @@ class IPAddressTable(BaseTable):
|
||||
pk = ToggleColumn()
|
||||
address = tables.LinkColumn('ipam:ipaddress', args=[Accessor('pk')], verbose_name='IP Address')
|
||||
vrf = tables.Column(orderable=False, default='Global', verbose_name='VRF')
|
||||
hostname = tables.Column(verbose_name='Host Name')
|
||||
ptr = tables.Column(verbose_name='PTR')
|
||||
device = tables.LinkColumn('dcim:device', args=[Accessor('interface.device.pk')], orderable=False,
|
||||
verbose_name='Device')
|
||||
interface = tables.Column(orderable=False, verbose_name='Interface')
|
||||
@ -168,7 +168,7 @@ class IPAddressTable(BaseTable):
|
||||
|
||||
class Meta(BaseTable.Meta):
|
||||
model = IPAddress
|
||||
fields = ('pk', 'address', 'vrf', 'hostname', 'device', 'interface', 'description')
|
||||
fields = ('pk', 'address', 'vrf', 'ptr', 'device', 'interface', 'description')
|
||||
|
||||
|
||||
class IPAddressBriefTable(BaseTable):
|
||||
|
@ -65,10 +65,10 @@
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Host Name</td>
|
||||
<td>PTR</td>
|
||||
<td>
|
||||
{% if ipaddress.hostname %}
|
||||
<span>{{ ipaddress.hostname }}</span>
|
||||
{% if ipaddress.ptr %}
|
||||
<span>{{ ipaddress.ptr }}</span>
|
||||
{% else %}
|
||||
<span class="text-muted">None</span>
|
||||
{% endif %}
|
||||
|
@ -8,7 +8,7 @@
|
||||
<tr>
|
||||
<td><a href="{% url 'ipam:ipaddress' pk=ipaddress.pk %}">{{ ipaddress }}</a></td>
|
||||
<td>{{ ipaddress.vrf }}</td>
|
||||
<td>{{ ipaddress.hostname }}</td>
|
||||
<td>{{ ipaddress.ptr }}</td>
|
||||
<td>{{ ipaddress.interface.device }}</td>
|
||||
<td>{{ ipaddress.interface }}</td>
|
||||
<td>{{ ipaddress.description }}</td>
|
||||
|
@ -8,7 +8,7 @@
|
||||
<div class="panel-body">
|
||||
{% render_field form.address %}
|
||||
{% render_field form.vrf %}
|
||||
{% render_field form.hostname %}
|
||||
{% render_field form.ptr %}
|
||||
{% if obj %}
|
||||
<div class="form-group">
|
||||
<label class="col-md-3 control-label">Device</label>
|
||||
|
@ -39,8 +39,8 @@
|
||||
<td>65000:123</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Host Name</td>
|
||||
<td>Reverse DNS host name</td>
|
||||
<td>PTR</td>
|
||||
<td>Reverse DNS Name</td>
|
||||
<td>foo.com</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
Loading…
Reference in New Issue
Block a user