Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
re2o
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nounous
re2o
Commits
119416cc
Commit
119416cc
authored
Mar 26, 2018
by
Gabriel Detraz
Committed by
chirac
Mar 26, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bornes hérite de machine
parent
43ff16cc
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
43 deletions
+112
-43
re2o/utils.py
re2o/utils.py
+4
-4
topologie/forms.py
topologie/forms.py
+10
-6
topologie/migrations/0047_ap_machine.py
topologie/migrations/0047_ap_machine.py
+26
-0
topologie/migrations/0048_ap_machine.py
topologie/migrations/0048_ap_machine.py
+39
-0
topologie/models.py
topologie/models.py
+2
-2
topologie/templates/topologie/aff_ap.html
topologie/templates/topologie/aff_ap.html
+5
-5
topologie/views.py
topologie/views.py
+26
-26
No files found.
re2o/utils.py
View file @
119416cc
...
...
@@ -234,10 +234,10 @@ class SortTable:
'default'
:
[
'name'
]
}
TOPOLOGIE_INDEX_BORNE
=
{
'ap_name'
:
[
'domain__name'
],
'ap_ip'
:
[
'ipv4__ipv4'
],
'ap_mac'
:
[
'mac_address'
],
'default'
:
[
'domain__name'
]
'ap_name'
:
[
'
interface__
domain__name'
],
'ap_ip'
:
[
'i
nterface__i
pv4__ipv4'
],
'ap_mac'
:
[
'
interface__
mac_address'
],
'default'
:
[
'
interface__
domain__name'
]
}
TOPOLOGIE_INDEX_STACK
=
{
'stack_name'
:
[
'name'
],
...
...
topologie/forms.py
View file @
119416cc
...
...
@@ -33,7 +33,11 @@ NewSwitchForm)
from
__future__
import
unicode_literals
from
machines.models
import
Interface
from
machines.forms
import
EditInterfaceForm
from
machines.forms
import
(
EditInterfaceForm
,
EditMachineForm
,
NewMachineForm
)
from
django
import
forms
from
django.forms
import
ModelForm
,
Form
from
.models
import
(
...
...
@@ -111,19 +115,19 @@ class StackForm(ModelForm):
super
(
StackForm
,
self
).
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
class
AddAccessPointForm
(
EditInterfac
eForm
):
class
AddAccessPointForm
(
NewMachin
eForm
):
"""Formulaire pour la création d'une borne
Relié directement au modèle borne"""
class
Meta
:
model
=
AccessPoint
fields
=
[
'
mac_address'
,
'type'
,
'ipv4'
,
'details'
,
'location
'
]
fields
=
[
'
location'
,
'name
'
]
class
EditAccessPointForm
(
Edit
Interfac
eForm
):
"""Edition d'une
interfac
e. Edition complète"""
class
EditAccessPointForm
(
Edit
Machin
eForm
):
"""Edition d'une
born
e. Edition complète"""
class
Meta
:
model
=
AccessPoint
fields
=
[
'machine'
,
'type'
,
'ipv4'
,
'mac_address'
,
'details'
,
'location'
]
fields
=
'__all__'
class
EditSwitchForm
(
EditInterfaceForm
):
...
...
topologie/migrations/0047_ap_machine.py
0 → 100644
View file @
119416cc
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-03-23 01:18
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'topologie'
,
'0046_auto_20180326_0129'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'NewAccessPoint'
,
fields
=
[
(
'machine_ptr'
,
models
.
OneToOneField
(
auto_created
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
parent_link
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'machines.Machine'
)),
(
'location'
,
models
.
CharField
(
help_text
=
"Détails sur la localisation de l'AP"
,
max_length
=
255
,
null
=
True
,
blank
=
True
)),
],
bases
=
(
'machines.machine'
,),
),
]
topologie/migrations/0048_ap_machine.py
0 → 100644
View file @
119416cc
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2018-03-23 01:18
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'topologie'
,
'0047_ap_machine'
),
]
def
transfer_ap
(
apps
,
schema_editor
):
db_alias
=
schema_editor
.
connection
.
alias
ap
=
apps
.
get_model
(
"topologie"
,
"AccessPoint"
)
new_ap
=
apps
.
get_model
(
"topologie"
,
"NewAccessPoint"
)
ap_list
=
ap
.
objects
.
using
(
db_alias
).
all
()
for
borne
in
ap_list
:
new_borne
=
new_ap
()
new_borne
.
machine_ptr_id
=
borne
.
machine
.
pk
new_borne
.
__dict__
.
update
(
borne
.
machine
.
__dict__
)
new_borne
.
location
=
borne
.
location
new_borne
.
save
()
def
untransfer_ap
(
apps
,
schema_editor
):
return
operations
=
[
migrations
.
RunPython
(
transfer_ap
,
untransfer_ap
),
migrations
.
DeleteModel
(
name
=
'AccessPoint'
,
),
migrations
.
RenameModel
(
old_name
=
'NewAccessPoint'
,
new_name
=
'AccessPoint'
,
),
]
topologie/models.py
View file @
119416cc
...
...
@@ -47,7 +47,7 @@ from django.db import IntegrityError
from
django.db
import
transaction
from
reversion
import
revisions
as
reversion
from
machines.models
import
Interface
from
machines.models
import
Machine
,
Interface
class
Stack
(
models
.
Model
):
"""Un objet stack. Regrouppe des switchs en foreign key
...
...
@@ -109,7 +109,7 @@ class Stack(models.Model):
inférieure à l'id minimale"
})
class
AccessPoint
(
Interfac
e
):
class
AccessPoint
(
Machin
e
):
"""Define a wireless AP. Inherit from machines.interfaces
Definition pour une borne wifi , hérite de machines.interfaces
...
...
topologie/templates/topologie/aff_ap.html
View file @
119416cc
...
...
@@ -43,10 +43,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</thead>
{% for ap in ap_list %}
<tr>
<td>
{{ap}}
</td>
<td>
{{ap.mac_address}}
</td>
<td>
{{ap.ipv4}}
</td>
<td>
{{ap.details}}
</td>
<td>
{{ap
.interface_set.first
}}
</td>
<td>
{{ap.
interface_set.first.
mac_address}}
</td>
<td>
{{ap.i
nterface_set.first.i
pv4}}
</td>
<td>
{{ap.
interface_set.first.
details}}
</td>
<td>
{{ap.location}}
</td>
<td
class=
"text-right"
>
<a
class=
"btn btn-info btn-sm"
role=
"button"
title=
"Historique"
href=
"{% url 'topologie:history' 'ap' ap.pk %}"
>
...
...
@@ -58,7 +58,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</a>
{% acl_end %}
{% can_delete ap %}
<a
class=
"btn btn-danger btn-sm"
role=
"button"
title=
"Supprimer"
href=
"{% url 'machines:del-
interfac
e' ap.id %}"
>
<a
class=
"btn btn-danger btn-sm"
role=
"button"
title=
"Supprimer"
href=
"{% url 'machines:del-
machin
e' ap.id %}"
>
<i
class=
"fa fa-trash"
></i>
</a>
{% acl_end %}
...
...
topologie/views.py
View file @
119416cc
...
...
@@ -535,45 +535,45 @@ def new_ap(request):
request
.
POST
or
None
,
user
=
request
.
user
)
machine
=
NewMachin
eForm
(
interface
=
AddInterfac
eForm
(
request
.
POST
or
None
,
user
=
request
.
user
)
domain
=
DomainForm
(
request
.
POST
or
None
,
)
if
ap
.
is_valid
()
and
machin
e
.
is_valid
():
if
ap
.
is_valid
()
and
interfac
e
.
is_valid
():
user
=
AssoOption
.
get_cached_value
(
'utilisateur_asso'
)
if
not
user
:
messages
.
error
(
request
,
"L'user association n'existe pas encore,
\
veuillez le créer ou le linker dans preferences"
)
return
redirect
(
reverse
(
'topologie:index'
))
new_machine
=
machine
.
save
(
commit
=
False
)
new_machine
.
user
=
user
new_ap
=
ap
.
save
(
commit
=
False
)
domain
.
instance
.
interface_parent
=
new_ap
new_ap
.
user
=
user
new_interface
=
interface
.
save
(
commit
=
False
)
domain
.
instance
.
interface_parent
=
new_interface
if
domain
.
is_valid
():
new_domain_instance
=
domain
.
save
(
commit
=
False
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_
machine
.
save
()
new_
ap
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
new_
ap
.
machine
=
new_machine
new_
interface
.
machine
=
new_ap
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_
ap
.
save
()
new_
interface
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
new_domain_instance
.
interface_parent
=
new_
ap
new_domain_instance
.
interface_parent
=
new_
interface
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_domain_instance
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Création"
)
messages
.
success
(
request
,
"La borne a été créé"
)
return
redirect
(
reverse
(
'topologie:index-ap'
))
i_mbf_param
=
generate_ipv4_mbf_param
(
ap
,
False
)
i_mbf_param
=
generate_ipv4_mbf_param
(
interface
,
False
)
return
form
({
'topoform'
:
ap
,
'machineform'
:
machine
,
'topoform'
:
interface
,
'machineform'
:
ap
,
'domainform'
:
domain
,
'i_mbf_param'
:
i_mbf_param
,
'device'
:
'wifi ap'
,
...
...
@@ -585,41 +585,41 @@ def new_ap(request):
def
edit_ap
(
request
,
ap
,
ap_id
):
""" Edition d'un switch. Permet de chambre nombre de ports,
place dans le stack, interface et machine associée"""
ap_form
=
EditAccessPoint
Form
(
interface_form
=
EditInterface
Form
(
request
.
POST
or
None
,
user
=
request
.
user
,
instance
=
ap
instance
=
ap
.
interface_set
.
first
()
)
machine_form
=
NewMachine
Form
(
ap_form
=
EditAccessPoint
Form
(
request
.
POST
or
None
,
user
=
request
.
user
,
instance
=
ap
.
machine
instance
=
ap
)
domain_form
=
DomainForm
(
request
.
POST
or
None
,
instance
=
ap
.
domain
instance
=
ap
.
interface_set
.
first
().
domain
)
if
ap_form
.
is_valid
()
and
machin
e_form
.
is_valid
():
if
ap_form
.
is_valid
()
and
interfac
e_form
.
is_valid
():
user
=
AssoOption
.
get_cached_value
(
'utilisateur_asso'
)
if
not
user
:
messages
.
error
(
request
,
"L'user association n'existe pas encore,
\
veuillez le créer ou le linker dans preferences"
)
return
redirect
(
reverse
(
'topologie:index-ap'
))
new_machine
=
machine_form
.
save
(
commit
=
False
)
new_ap
=
ap_form
.
save
(
commit
=
False
)
new_interface
=
interface_form
.
save
(
commit
=
False
)
new_domain
=
domain_form
.
save
(
commit
=
False
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_
machine
.
save
()
new_
ap
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) : %s"
%
', '
.
join
(
field
for
field
in
machine
_form
.
changed_data
)
field
for
field
in
ap
_form
.
changed_data
)
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
new_
ap
.
save
()
new_
interface
.
save
()
reversion
.
set_user
(
request
.
user
)
reversion
.
set_comment
(
"Champs modifié(s) : %s"
%
', '
.
join
(
field
for
field
in
ap
_form
.
changed_data
)
field
for
field
in
interface
_form
.
changed_data
)
)
reversion
.
set_comment
(
"Création"
)
with
transaction
.
atomic
(),
reversion
.
create_revision
():
...
...
@@ -630,10 +630,10 @@ def edit_ap(request, ap, ap_id):
)
messages
.
success
(
request
,
"La borne a été modifiée"
)
return
redirect
(
reverse
(
'topologie:index-ap'
))
i_mbf_param
=
generate_ipv4_mbf_param
(
ap
_form
,
False
)
i_mbf_param
=
generate_ipv4_mbf_param
(
interface
_form
,
False
)
return
form
({
'topoform'
:
ap
_form
,
'machineform'
:
machine
_form
,
'topoform'
:
interface
_form
,
'machineform'
:
ap
_form
,
'domainform'
:
domain_form
,
'i_mbf_param'
:
i_mbf_param
,
'device'
:
'wifi ap'
,
...
...
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