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
cb9a7a5b
authored
Oct 02, 2013
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: add get_new_address()
parent
43a54035
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
circle/firewall/models.py
+18
-0
No files found.
circle/firewall/models.py
View file @
cb9a7a5b
...
...
@@ -283,6 +283,24 @@ class Vlan(models.Model):
def
prefix6
(
self
):
return
self
.
network6
.
prefixlen
def
get_new_address
(
self
):
i
=
0
hosts
=
Host
.
objects
.
filter
(
vlan
=
self
)
used_v4
=
hosts
.
values_list
(
'ipv4'
,
flat
=
True
)
used_v6
=
hosts
.
values_list
(
'ipv6'
,
flat
=
True
)
for
ipv4
in
self
.
network4
.
iter_hosts
():
i
+=
1
if
i
>
10000
:
break
ipv4
=
str
(
ipv4
)
if
ipv4
not
in
used_v4
:
print
ipv4
ipv6
=
ipv4_2_ipv6
(
ipv4
)
if
ipv6
not
in
used_v6
:
return
(
ipv4
,
ipv6
)
raise
ValidationError
(
_
(
"All IP addresses are already in use."
))
class
VlanGroup
(
models
.
Model
):
"""
...
...
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