show related hosts' ipv4/v6 addr from nameserver
This commit is contained in:
parent
3b4669771a
commit
8c25bdf14d
@ -333,6 +333,21 @@ class RelatedHost(models.Model):
|
|||||||
# so the resulting hostname has a dot inside:
|
# so the resulting hostname has a dot inside:
|
||||||
return dnstools.FQDN('%s.%s' % (self.name, main.host), main.domain)
|
return dnstools.FQDN('%s.%s' % (self.name, main.host), main.domain)
|
||||||
|
|
||||||
|
def get_ip(self, kind):
|
||||||
|
record = 'A' if kind == 'ipv4' else 'AAAA'
|
||||||
|
try:
|
||||||
|
return dnstools.query_ns(self.get_fqdn(), record)
|
||||||
|
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
|
||||||
|
return 'none'
|
||||||
|
except (dns.resolver.NoNameservers, dns.resolver.Timeout, dnstools.NameServerNotAvailable):
|
||||||
|
return 'error'
|
||||||
|
|
||||||
|
def get_ipv4(self):
|
||||||
|
return self.get_ip('ipv4')
|
||||||
|
|
||||||
|
def get_ipv6(self):
|
||||||
|
return self.get_ip('ipv6')
|
||||||
|
|
||||||
|
|
||||||
pre_delete.connect(pre_delete_host, sender=RelatedHost)
|
pre_delete.connect(pre_delete_host, sender=RelatedHost)
|
||||||
|
|
||||||
|
@ -19,8 +19,16 @@
|
|||||||
{% trans "Comment" %}
|
{% trans "Comment" %}
|
||||||
</th>
|
</th>
|
||||||
<th>{% trans "Available" %}</th>
|
<th>{% trans "Available" %}</th>
|
||||||
<th>{% blocktrans with type=_("IPv4") %}{{ type }} interface ID{% endblocktrans %}</th>
|
<th>
|
||||||
<th>{% blocktrans with type=_("IPv6") %}{{ type }} interface ID{% endblocktrans %}</th>
|
{% blocktrans with type=_("IPv4") %}{{ type }} Address{% endblocktrans %}
|
||||||
|
<br>
|
||||||
|
{% blocktrans with type=_("IPv4") %}{{ type }} interface ID{% endblocktrans %}
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
{% blocktrans with type=_("IPv6") %}{{ type }} Address{% endblocktrans %}
|
||||||
|
<br>
|
||||||
|
{% blocktrans with type=_("IPv6") %}{{ type }} interface ID{% endblocktrans %}
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
{% for rh in related_hosts %}
|
{% for rh in related_hosts %}
|
||||||
@ -31,8 +39,16 @@
|
|||||||
{{ rh.comment }}
|
{{ rh.comment }}
|
||||||
</td>
|
</td>
|
||||||
<td>{{ rh.available|yesno }}</td>
|
<td>{{ rh.available|yesno }}</td>
|
||||||
<td>{{ rh.interface_id_ipv4 }}</td>
|
<td>
|
||||||
<td>{{ rh.interface_id_ipv6 }}</td>
|
{{ rh.get_ipv4 }}
|
||||||
|
<br>
|
||||||
|
{{ rh.interface_id_ipv4 }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ rh.get_ipv6 }}
|
||||||
|
<br>
|
||||||
|
{{ rh.interface_id_ipv6 }}
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr><td colspan="5">{% trans "No related hosts yet." %}</td></tr>
|
<tr><td colspan="5">{% trans "No related hosts yet." %}</td></tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user