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
0dbc3afe
authored
Nov 12, 2014
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
network: fix ipv6 conversion
parent
bb9f818b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
circle/firewall/models.py
+2
-0
circle/network/views.py
+8
-8
No files found.
circle/firewall/models.py
View file @
0dbc3afe
...
...
@@ -414,6 +414,8 @@ class Vlan(AclBase, models.Model):
def
convert_ipv4_to_ipv6
(
self
,
ipv4
):
"""Convert IPv4 address string to IPv6 address string."""
if
isinstance
(
ipv4
,
basestring
):
ipv4
=
IPAddress
(
ipv4
,
4
)
nums
=
{
ascii_letters
[
i
]:
int
(
ipv4
.
words
[
i
])
for
i
in
range
(
4
)}
return
IPAddress
(
self
.
ipv6_template
%
nums
)
...
...
circle/network/views.py
View file @
0dbc3afe
...
...
@@ -444,19 +444,19 @@ class HostCreate(LoginRequiredMixin, SuperuserRequiredMixin,
def
_get_ajax
(
self
,
*
args
,
**
kwargs
):
GET
=
self
.
request
.
GET
result
=
{}
if
"vlan"
in
GET
:
vlan
=
get_object_or_404
(
Vlan
.
objects
,
pk
=
GET
[
"vlan"
])
vlan
=
get_object_or_404
(
Vlan
.
objects
,
pk
=
GET
.
get
(
"vlan"
,
""
))
if
"ipv4"
in
GET
:
try
:
result
[
"ipv6"
]
=
vlan
.
convert_ipv4_to_ipv6
(
GET
[
"ipv4"
])
except
:
result
[
"ipv6"
]
=
""
else
:
try
:
result
.
update
(
vlan
.
get_new_address
())
except
ValidationError
:
result
[
"ipv4"
]
=
""
result
[
"ipv6"
]
=
""
if
"ipv4"
in
GET
:
try
:
result
[
"ipv6"
]
=
vlan
.
convert_ipv4_to_ipv6
(
GET
[
"ipv4"
])
except
:
result
[
"ipv6"
]
=
""
return
JsonResponse
({
k
:
unicode
(
result
[
k
]
or
""
)
for
k
in
result
})
return
JsonResponse
({
k
:
unicode
(
result
[
k
]
or
""
)
for
k
in
result
})
def
get
(
self
,
*
args
,
**
kwargs
):
if
self
.
request
.
is_ajax
():
...
...
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