Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Nounous
re2o
Commits
f1373ee5
Commit
f1373ee5
authored
Aug 28, 2017
by
Gabriel Detraz
Committed by
Mael Kervella
Aug 28, 2017
Browse files
Si il y a deja des ip, on change leur destination ip_type
parent
27d68235
Changes
1
Hide whitespace changes
Inline
Side-by-side
machines/models.py
View file @
f1373ee5
...
...
@@ -93,7 +93,13 @@ class IpType(models.Model):
for
net
in
self
.
ip_range
.
cidrs
():
networks
+=
net
.
iter_hosts
()
ip_obj
=
[
IpList
(
ip_type
=
self
,
ipv4
=
str
(
ip
))
for
ip
in
networks
]
IpList
.
objects
.
bulk_create
(
ip_obj
)
listes_ip
=
IpList
.
objects
.
filter
(
ipv4__in
=
[
str
(
ip
)
for
ip
in
networks
])
# Si il n'y a pas d'ip, on les crée
if
not
listes_ip
:
IpList
.
objects
.
bulk_create
(
ip_obj
)
# Sinon on update l'ip_type
else
:
listes_ip
.
update
(
ip_type
=
self
)
return
def
del_ip_range
(
self
):
...
...
@@ -373,8 +379,7 @@ def interface_post_delete(sender, **kwargs):
@
receiver
(
post_save
,
sender
=
IpType
)
def
iptype_post_save
(
sender
,
**
kwargs
):
iptype
=
kwargs
[
'instance'
]
if
not
iptype
.
ip_objects
():
iptype
.
gen_ip_range
()
iptype
.
gen_ip_range
()
@
receiver
(
post_save
,
sender
=
MachineType
)
def
machine_post_save
(
sender
,
**
kwargs
):
...
...
Write
Preview
Supports
Markdown
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