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)
val_ipv4(ipv4)
m = ipv4_re.match(ipv4)
return (ipv6_template % {'a': int(m.group(1)),
'b': int(m.group(2)),
'c': int(m.group(3)),
'd': int(m.group(4))})
return IPAddress(ipv6_template % {'a': int(m.group(1)),
'b': int(m.group(2)),
'c': int(m.group(3)),
'd': int(m.group(4))})
......@@ -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_ipv6_template,
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 self.id 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,
self.ipv4)
self.full_clean()
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