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
5c9c9c3a
Commit
5c9c9c3a
authored
Oct 03, 2017
by
Gabriel Detraz
Committed by
root
Oct 03, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Attribut ipv6 sur les interfaces
parent
12fe7687
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
71 additions
and
7 deletions
+71
-7
machines/forms.py
machines/forms.py
+2
-2
machines/migrations/0059_iptype_prefix_v6.py
machines/migrations/0059_iptype_prefix_v6.py
+20
-0
machines/models.py
machines/models.py
+16
-1
machines/templates/machines/aff_iptype.html
machines/templates/machines/aff_iptype.html
+2
-0
machines/templates/machines/aff_machines.html
machines/templates/machines/aff_machines.html
+4
-2
preferences/migrations/0020_optionalmachine_ipv6.py
preferences/migrations/0020_optionalmachine_ipv6.py
+20
-0
preferences/models.py
preferences/models.py
+1
-0
preferences/templates/preferences/display_preferences.html
preferences/templates/preferences/display_preferences.html
+3
-1
re2o/context_processors.py
re2o/context_processors.py
+3
-1
No files found.
machines/forms.py
View file @
5c9c9c3a
...
...
@@ -142,7 +142,7 @@ class DelMachineTypeForm(Form):
class
IpTypeForm
(
ModelForm
):
class
Meta
:
model
=
IpType
fields
=
[
'type'
,
'extension'
,
'need_infra'
,
'domaine_ip_start'
,
'domaine_ip_stop'
,
'vlan'
]
fields
=
[
'type'
,
'extension'
,
'need_infra'
,
'domaine_ip_start'
,
'domaine_ip_stop'
,
'
prefix_v6'
,
'
vlan'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -151,7 +151,7 @@ class IpTypeForm(ModelForm):
class
EditIpTypeForm
(
IpTypeForm
):
class
Meta
(
IpTypeForm
.
Meta
):
fields
=
[
'extension'
,
'type'
,
'need_infra'
,
'vlan'
]
fields
=
[
'extension'
,
'type'
,
'need_infra'
,
'
prefix_v6'
,
'
vlan'
]
class
DelIpTypeForm
(
Form
):
iptypes
=
forms
.
ModelMultipleChoiceField
(
queryset
=
IpType
.
objects
.
all
(),
label
=
"Types d'ip actuelles"
,
widget
=
forms
.
CheckboxSelectMultiple
)
...
...
machines/migrations/0059_iptype_prefix_v6.py
0 → 100644
View file @
5c9c9c3a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-10-02 16:33
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0058_auto_20171002_0350'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'iptype'
,
name
=
'prefix_v6'
,
field
=
models
.
GenericIPAddressField
(
blank
=
True
,
null
=
True
,
protocol
=
'IPv6'
),
),
]
machines/models.py
View file @
5c9c9c3a
...
...
@@ -70,6 +70,7 @@ class IpType(models.Model):
need_infra
=
models
.
BooleanField
(
default
=
False
)
domaine_ip_start
=
models
.
GenericIPAddressField
(
protocol
=
'IPv4'
)
domaine_ip_stop
=
models
.
GenericIPAddressField
(
protocol
=
'IPv4'
)
prefix_v6
=
models
.
GenericIPAddressField
(
protocol
=
'IPv6'
,
null
=
True
,
blank
=
True
)
vlan
=
models
.
ForeignKey
(
'Vlan'
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
)
@
cached_property
...
...
@@ -122,6 +123,9 @@ class IpType(models.Model):
for
element
in
IpType
.
objects
.
all
().
exclude
(
pk
=
self
.
pk
):
if
not
self
.
ip_set
.
isdisjoint
(
element
.
ip_set
):
raise
ValidationError
(
"Le range indiqué n'est pas disjoint des ranges existants"
)
# On formate le prefix v6
if
self
.
prefix_v6
:
self
.
prefix_v6
=
str
(
IPNetwork
(
self
.
prefix_v6
+
'/64'
).
network
)
return
def
save
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -218,7 +222,6 @@ class Interface(models.Model):
PRETTY_NAME
=
"Interface"
ipv4
=
models
.
OneToOneField
(
'IpList'
,
on_delete
=
models
.
PROTECT
,
blank
=
True
,
null
=
True
)
#ipv6 = models.GenericIPAddressField(protocol='IPv6', null=True)
mac_address
=
MACAddressField
(
integer
=
False
,
unique
=
True
)
machine
=
models
.
ForeignKey
(
'Machine'
,
on_delete
=
models
.
CASCADE
)
type
=
models
.
ForeignKey
(
'MachineType'
,
on_delete
=
models
.
PROTECT
)
...
...
@@ -232,6 +235,18 @@ class Interface(models.Model):
user
=
self
.
machine
.
user
return
machine
.
active
and
user
.
has_access
()
@
cached_property
def
ipv6_object
(
self
):
if
self
.
type
.
ip_type
.
prefix_v6
:
return
EUI
(
self
.
mac_address
).
ipv6
(
IPNetwork
(
self
.
type
.
ip_type
.
prefix_v6
).
network
)
else
:
return
None
@
cached_property
def
ipv6
(
self
):
return
str
(
self
.
ipv6_object
)
def
mac_bare
(
self
):
return
str
(
EUI
(
self
.
mac_address
,
dialect
=
mac_bare
)).
lower
()
...
...
machines/templates/machines/aff_iptype.html
View file @
5c9c9c3a
...
...
@@ -30,6 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Nécessite l'autorisation infra
</th>
<th>
Début
</th>
<th>
Fin
</th>
<th>
Préfixe v6
</th>
<th>
Sur vlan
</th>
<th></th>
<th></th>
...
...
@@ -42,6 +43,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<td>
{{ type.need_infra }}
</td>
<td>
{{ type.domaine_ip_start }}
</td>
<td>
{{ type.domaine_ip_stop }}
</td>
<td>
{{ type.prefix_v6 }}
</td>
<td>
{{ type.vlan }}
</td>
<td
class=
"text-right"
>
{% if is_infra %}
...
...
machines/templates/machines/aff_machines.html
View file @
5c9c9c3a
...
...
@@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<th>
Nom dns
</th>
<th>
Type
</th>
<th>
Mac
</th>
<th>
I
pv4
</th>
<th>
I
P
</th>
<th></th>
</tr>
</thead>
...
...
@@ -74,7 +74,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</td>
<td>
{{ interface.type }}
</td>
<td>
{{ interface.mac_address }}
</td>
<td>
{{ interface.ipv4 }}
</td>
<td>
{{ interface.ipv4 }}
{{ interface.ipv6 }}
</td>
<td>
<div
class=
"dropdown"
>
<button
class=
"btn btn-default dropdown-toggle"
type=
"button"
id=
"editioninterface"
data-toggle=
"dropdown"
aria-haspopup=
"true"
aria-expanded=
"true"
>
...
...
preferences/migrations/0020_optionalmachine_ipv6.py
0 → 100644
View file @
5c9c9c3a
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-10-02 16:14
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'preferences'
,
'0019_remove_optionaltopologie_mac_autocapture'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'optionalmachine'
,
name
=
'ipv6'
,
field
=
models
.
BooleanField
(
default
=
False
),
),
]
preferences/models.py
View file @
5c9c9c3a
...
...
@@ -45,6 +45,7 @@ class OptionalMachine(models.Model):
password_machine
=
models
.
BooleanField
(
default
=
False
)
max_lambdauser_interfaces
=
models
.
IntegerField
(
default
=
10
)
max_lambdauser_aliases
=
models
.
IntegerField
(
default
=
10
)
ipv6
=
models
.
BooleanField
(
default
=
False
)
class
OptionalTopologie
(
models
.
Model
):
PRETTY_NAME
=
"Options topologie"
...
...
preferences/templates/preferences/display_preferences.html
View file @
5c9c9c3a
...
...
@@ -72,7 +72,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<tr>
<th>
Alias dns autorisé par utilisateur
</th>
<td>
{{ machineoptions.max_lambdauser_aliases }}
</td>
</tr>
<th>
Support de l'ipv6
</th>
<td>
{{ machineoptions.ipv6 }}
</td>
</tr>
</table>
<h4>
Préférences topologie
</h4>
{% if is_bureau %}
...
...
re2o/context_processors.py
View file @
5c9c9c3a
...
...
@@ -23,10 +23,11 @@
from
__future__
import
unicode_literals
from
machines.models
import
Interface
,
Machine
from
preferences.models
import
GeneralOption
from
preferences.models
import
GeneralOption
,
OptionalMachine
def
context_user
(
request
):
general_options
,
created
=
GeneralOption
.
objects
.
get_or_create
()
machine_options
,
created
=
OptionalMachine
.
objects
.
get_or_create
()
user
=
request
.
user
if
user
.
is_authenticated
():
interfaces
=
user
.
user_interfaces
()
...
...
@@ -54,4 +55,5 @@ def context_user(request):
'is_admin'
:
is_admin
,
'interfaces'
:
interfaces
,
'site_name'
:
general_options
.
site_name
,
'ipv6_enabled'
:
machine_options
.
ipv6
,
}
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