Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
15cff265
authored
Mar 18, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: rename ipv4_2_ipv6 to convert_ipv4_to_ipv6
parent
4db5bd68
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
circle/firewall/fields.py
+6
-5
circle/firewall/models.py
+5
-4
No files found.
circle/firewall/fields.py
View file @
15cff265
...
@@ -261,11 +261,12 @@ def val_mx(value):
...
@@ -261,11 +261,12 @@ def val_mx(value):
"Should be: <priority>:<hostname>"
))
"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."""
"""Convert IPv4 address string to IPv6 address string."""
ipv4
=
str
(
ipv4
)
val_ipv4
(
ipv4
)
val_ipv4
(
ipv4
)
m
=
ipv4_re
.
match
(
ipv4
)
m
=
ipv4_re
.
match
(
ipv4
)
return
(
ipv6_template
%
{
'a'
:
int
(
m
.
group
(
1
)),
return
IPAddress
(
ipv6_template
%
{
'a'
:
int
(
m
.
group
(
1
)),
'b'
:
int
(
m
.
group
(
2
)),
'b'
:
int
(
m
.
group
(
2
)),
'c'
:
int
(
m
.
group
(
3
)),
'c'
:
int
(
m
.
group
(
3
)),
'd'
:
int
(
m
.
group
(
4
))})
'd'
:
int
(
m
.
group
(
4
))})
circle/firewall/models.py
View file @
15cff265
...
@@ -9,9 +9,9 @@ from django.db import models
...
@@ -9,9 +9,9 @@ from django.db import models
from
django.forms
import
ValidationError
from
django.forms
import
ValidationError
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
firewall.fields
import
(
MACAddressField
,
val_alfanum
,
val_reverse_domain
,
from
firewall.fields
import
(
MACAddressField
,
val_alfanum
,
val_reverse_domain
,
val_ipv6_template
,
val_ipv6_template
,
val_domain
,
val_ipv4
,
val_
domain
,
val_ipv4
,
val_ipv6
,
val_mx
,
val_
ipv6
,
val_mx
,
convert_ipv4_to_ipv6
,
ipv4_2_ipv6
,
IPNetworkField
,
IPAddressField
)
IPNetworkField
,
IPAddressField
)
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
import
django.conf
import
django.conf
from
django.db.models.signals
import
post_save
,
post_delete
from
django.db.models.signals
import
post_save
,
post_delete
...
@@ -473,7 +473,8 @@ class Host(models.Model):
...
@@ -473,7 +473,8 @@ class Host(models.Model):
def
save
(
self
,
*
args
,
**
kwargs
):
def
save
(
self
,
*
args
,
**
kwargs
):
if
not
self
.
id
and
self
.
ipv6
==
"auto"
:
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
()
self
.
full_clean
()
super
(
Host
,
self
)
.
save
(
*
args
,
**
kwargs
)
super
(
Host
,
self
)
.
save
(
*
args
,
**
kwargs
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment