Commit 15cff265 by Bach Dániel

firewall: rename ipv4_2_ipv6 to convert_ipv4_to_ipv6

parent 4db5bd68
......@@ -261,11 +261,12 @@ def val_mx(value):
"Should be: <priority>:<hostname>"))
def ipv4_2_ipv6(ipv6_template, ipv4):
def convert_ipv4_to_ipv6(ipv6_template, ipv4):
"""Convert IPv4 address string to IPv6 address string."""
ipv4 = str(ipv4)
m = ipv4_re.match(ipv4)
return (ipv6_template % {'a': int(,
'b': int(,
'c': int(,
'd': int(})
return IPAddress(ipv6_template % {'a': int(,
'b': int(,
'c': int(,
'd': int(})
......@@ -9,9 +9,9 @@ from django.db import models
from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
from firewall.fields import (MACAddressField, val_alfanum, val_reverse_domain,
val_domain, val_ipv4, val_ipv6, val_mx,
ipv4_2_ipv6, IPNetworkField, IPAddressField)
val_ipv6_template, val_domain, val_ipv4,
val_ipv6, val_mx, convert_ipv4_to_ipv6,
IPNetworkField, IPAddressField)
from django.core.validators import MinValueValidator, MaxValueValidator
import django.conf
from django.db.models.signals import post_save, post_delete
......@@ -473,7 +473,8 @@ class Host(models.Model):
def save(self, *args, **kwargs):
if not and self.ipv6 == "auto":
self.ipv6 = ipv4_2_ipv6(self.vlan.ipv6_template, self.ipv4)
self.ipv6 = convert_ipv4_to_ipv6(self.vlan.ipv6_template,
super(Host, self).save(*args, **kwargs)
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 sign in to comment