Commit ddffea2d authored by Leonidas Poulopoulos's avatar Leonidas Poulopoulos

Added FQDN resolving in mail notification templates to denote the host that an action originated

parent a5d4c70f
from django import template
from django.utils.safestring import mark_safe
from django.utils.encoding import force_unicode
import socket
register = template.Library()
@register.filter
def tofqdn(value):
try:
fqdn = socket.getfqdn(value)
if fqdn == value:
return False
else:
return fqdn
except socket.gaierror:
return False
\ No newline at end of file
{% load tofqdn %}
A new rule creation job has spawned
Peer: {{route.applier.get_profile.peer.peer_name}}
User {{route.applier.username}} requested the application of the following rule from address {{address}} :
User {{route.applier.username}} requested the application of the following rule from address {{address}} {% if address|tofqdn %}({{address|tofqdn}}){% endif %}:
Match
* Dst Addr:{{route.destination}}
......
{% load tofqdn %}
A new rule removal job has spawned
Peer: {{route.applier.get_profile.peer.peer_name}}
User {{route.applier.username}} requested the removal of the following rule from address {{address}} :
User {{route.applier.username}} requested the removal of the following rule from address {{address}} {% if address|tofqdn %}({{address|tofqdn}}){% endif %}:
Match
* Dst Addr:{{route.destination}}
......
{% load tofqdn %}
A new rule edit job has spawned
Peer: {{route.applier.get_profile.peer.peer_name}}
User {{route.applier.username}} requested the application of the following rule from address {{address}} :
User {{route.applier.username}} requested the application of the following rule from address {{address}} {% if address|tofqdn %}({{address|tofqdn}}){% endif %}:
Match
* Dst Addr:{{route.destination}}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment