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
c9b84047
Commit
c9b84047
authored
Mar 03, 2019
by
detraz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change les variables type en name ou machine_type pour éviter les confusions
parent
0bc1734c
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
88 additions
and
58 deletions
+88
-58
api/serializers.py
api/serializers.py
+6
-6
freeradius_utils/auth.py
freeradius_utils/auth.py
+4
-4
machines/admin.py
machines/admin.py
+1
-1
machines/forms.py
machines/forms.py
+9
-9
machines/migrations/0102_auto_20190303_1611.py
machines/migrations/0102_auto_20190303_1611.py
+30
-0
machines/models.py
machines/models.py
+23
-23
machines/templates/machines/aff_iptype.html
machines/templates/machines/aff_iptype.html
+1
-1
machines/templates/machines/aff_machines.html
machines/templates/machines/aff_machines.html
+1
-1
machines/templates/machines/aff_machinetype.html
machines/templates/machines/aff_machinetype.html
+1
-1
machines/views.py
machines/views.py
+9
-9
re2o/utils.py
re2o/utils.py
+1
-1
topologie/models.py
topologie/models.py
+1
-1
users/views.py
users/views.py
+1
-1
No files found.
api/serializers.py
View file @
c9b84047
...
...
@@ -150,7 +150,7 @@ class MachineTypeSerializer(NamespacedHMSerializer):
class
Meta
:
model
=
machines
.
MachineType
fields
=
(
'
typ
e'
,
'ip_type'
,
'api_url'
)
fields
=
(
'
nam
e'
,
'ip_type'
,
'api_url'
)
class
IpTypeSerializer
(
NamespacedHMSerializer
):
...
...
@@ -159,7 +159,7 @@ class IpTypeSerializer(NamespacedHMSerializer):
class
Meta
:
model
=
machines
.
IpType
fields
=
(
'
typ
e'
,
'extension'
,
'need_infra'
,
'domaine_ip_start'
,
fields
=
(
'
nam
e'
,
'extension'
,
'need_infra'
,
'domaine_ip_start'
,
'domaine_ip_stop'
,
'prefix_v6'
,
'vlan'
,
'ouverture_ports'
,
'api_url'
)
...
...
@@ -267,7 +267,7 @@ class InterfaceSerializer(NamespacedHMSerializer):
class
Meta
:
model
=
machines
.
Interface
fields
=
(
'ipv4'
,
'mac_address'
,
'machine'
,
'type'
,
'details'
,
fields
=
(
'ipv4'
,
'mac_address'
,
'machine'
,
'
machine_
type'
,
'details'
,
'port_lists'
,
'active'
,
'api_url'
)
...
...
@@ -747,7 +747,7 @@ class InterfaceVlanSerializer(NamespacedHMSerializer):
domain
=
serializers
.
CharField
(
read_only
=
True
)
ipv4
=
serializers
.
CharField
(
read_only
=
True
)
ipv6
=
Ipv6ListSerializer
(
read_only
=
True
,
many
=
True
)
vlan_id
=
serializers
.
IntegerField
(
source
=
'type.ip_type.vlan.vlan_id'
,
read_only
=
True
)
vlan_id
=
serializers
.
IntegerField
(
source
=
'
machine_
type.ip_type.vlan.vlan_id'
,
read_only
=
True
)
class
Meta
:
model
=
machines
.
Interface
...
...
@@ -865,7 +865,7 @@ class SubnetPortsOpenSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
machines
.
IpType
fields
=
(
'
typ
e'
,
'domaine_ip_start'
,
'domaine_ip_stop'
,
'complete_prefixv6'
,
'ouverture_ports'
)
fields
=
(
'
nam
e'
,
'domaine_ip_start'
,
'domaine_ip_stop'
,
'complete_prefixv6'
,
'ouverture_ports'
)
class
InterfacePortsOpenSerializer
(
serializers
.
ModelSerializer
):
...
...
@@ -1080,7 +1080,7 @@ class DNSReverseZonesSerializer(serializers.ModelSerializer):
class
Meta
:
model
=
machines
.
IpType
fields
=
(
'
typ
e'
,
'extension'
,
'soa'
,
'ns_records'
,
'mx_records'
,
fields
=
(
'
nam
e'
,
'extension'
,
'soa'
,
'ns_records'
,
'mx_records'
,
'txt_records'
,
'ptr_records'
,
'ptr_v6_records'
,
'cidrs'
,
'prefix_v6'
,
'prefix_v6_length'
)
...
...
freeradius_utils/auth.py
View file @
c9b84047
...
...
@@ -148,7 +148,7 @@ def authorize(data):
# Toutes les reuquètes non proxifiées
nas_type
=
None
if
nas_instance
:
nas_type
=
Nas
.
objects
.
filter
(
nas_type
=
nas_instance
.
type
).
first
()
nas_type
=
Nas
.
objects
.
filter
(
nas_type
=
nas_instance
.
machine_
type
).
first
()
if
not
nas_type
or
nas_type
.
port_access_mode
==
'802.1X'
:
user
=
data
.
get
(
'User-Name'
,
''
).
decode
(
'utf-8'
,
errors
=
'replace'
)
user
=
user
.
split
(
'@'
,
1
)[
0
]
...
...
@@ -193,7 +193,7 @@ def post_auth(data):
if
not
nas_instance
:
logger
.
info
(
u
"Requete proxifiee, nas inconnu"
.
encode
(
'utf-8'
))
return
radiusd
.
RLM_MODULE_OK
nas_type
=
Nas
.
objects
.
filter
(
nas_type
=
nas_instance
.
type
).
first
()
nas_type
=
Nas
.
objects
.
filter
(
nas_type
=
nas_instance
.
machine_
type
).
first
()
if
not
nas_type
:
logger
.
info
(
u
"Type de nas non enregistre dans la bdd!"
.
encode
(
'utf-8'
)
...
...
@@ -280,7 +280,7 @@ def find_nas_from_request(nas_id):
Q
(
domain
=
Domain
.
objects
.
filter
(
name
=
nas_id
))
|
Q
(
ipv4
=
IpList
.
objects
.
filter
(
ipv4
=
nas_id
))
)
.
select_related
(
'type'
)
.
select_related
(
'
machine_
type'
)
.
select_related
(
'machine__switch__stack'
))
return
nas
.
first
()
...
...
@@ -531,7 +531,7 @@ def decide_vlan_switch(nas_machine, nas_type, port_number,
# Si on choisi de placer les machines sur le vlan
# correspondant à leur type :
if
RadiusOption
.
get_cached_value
(
'radius_general_policy'
)
==
'MACHINE'
:
DECISION_VLAN
=
interface
.
type
.
ip_type
.
vlan
.
vlan_id
DECISION_VLAN
=
interface
.
machine_
type
.
ip_type
.
vlan
.
vlan_id
if
not
interface
.
ipv4
:
interface
.
assign_ipv4
()
return
(
...
...
machines/admin.py
View file @
c9b84047
...
...
@@ -136,7 +136,7 @@ class OuverturePortListAdmin(VersionAdmin):
class
InterfaceAdmin
(
VersionAdmin
):
""" Admin view of a Interface object """
list_display
=
(
'machine'
,
'type'
,
'mac_address'
,
'ipv4'
,
'details'
)
list_display
=
(
'machine'
,
'
machine_
type'
,
'mac_address'
,
'ipv4'
,
'details'
)
class
DomainAdmin
(
VersionAdmin
):
...
...
machines/forms.py
View file @
c9b84047
...
...
@@ -90,15 +90,15 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
class
Meta
:
model
=
Interface
fields
=
[
'machine'
,
'type'
,
'ipv4'
,
'mac_address'
,
'details'
]
fields
=
[
'machine'
,
'
machine_
type'
,
'ipv4'
,
'mac_address'
,
'details'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
prefix
=
kwargs
.
pop
(
'prefix'
,
self
.
Meta
.
model
.
__name__
)
user
=
kwargs
.
get
(
'user'
)
super
(
EditInterfaceForm
,
self
).
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
self
.
fields
[
'mac_address'
].
label
=
_
(
"MAC address"
)
self
.
fields
[
'type'
].
label
=
_
(
"Machine type"
)
self
.
fields
[
'type'
].
empty_label
=
_
(
"Select a machine type"
)
self
.
fields
[
'
machine_
type'
].
label
=
_
(
"Machine type"
)
self
.
fields
[
'
machine_
type'
].
empty_label
=
_
(
"Select a machine type"
)
if
"ipv4"
in
self
.
fields
:
self
.
fields
[
'ipv4'
].
empty_label
=
_
(
"Automatic IPv4 assignment"
)
self
.
fields
[
'ipv4'
].
queryset
=
IpList
.
objects
.
filter
(
...
...
@@ -122,7 +122,7 @@ class EditInterfaceForm(FormRevMixin, FieldPermissionFormMixin, ModelForm):
.
select_related
(
'user'
)
can_use_all_machinetype
,
_reason
=
MachineType
.
can_use_all
(
user
)
if
not
can_use_all_machinetype
:
self
.
fields
[
'type'
].
queryset
=
MachineType
.
objects
.
filter
(
self
.
fields
[
'
machine_
type'
].
queryset
=
MachineType
.
objects
.
filter
(
ip_type__in
=
IpType
.
objects
.
filter
(
need_infra
=
False
)
)
...
...
@@ -132,7 +132,7 @@ class AddInterfaceForm(EditInterfaceForm):
affiche ou non l'ensemble des ip disponibles"""
class
Meta
(
EditInterfaceForm
.
Meta
):
fields
=
[
'type'
,
'ipv4'
,
'mac_address'
,
'details'
]
fields
=
[
'
machine_
type'
,
'ipv4'
,
'mac_address'
,
'details'
]
class
AliasForm
(
FormRevMixin
,
ModelForm
):
...
...
@@ -191,12 +191,12 @@ class MachineTypeForm(FormRevMixin, ModelForm):
class
Meta
:
model
=
MachineType
fields
=
[
'
typ
e'
,
'ip_type'
]
fields
=
[
'
nam
e'
,
'ip_type'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
prefix
=
kwargs
.
pop
(
'prefix'
,
self
.
Meta
.
model
.
__name__
)
super
(
MachineTypeForm
,
self
).
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
self
.
fields
[
'
typ
e'
].
label
=
_
(
"Machine type to add"
)
self
.
fields
[
'
nam
e'
].
label
=
_
(
"Machine type to add"
)
self
.
fields
[
'ip_type'
].
label
=
_
(
"Related IP type"
)
...
...
@@ -228,7 +228,7 @@ class IpTypeForm(FormRevMixin, ModelForm):
def
__init__
(
self
,
*
args
,
**
kwargs
):
prefix
=
kwargs
.
pop
(
'prefix'
,
self
.
Meta
.
model
.
__name__
)
super
(
IpTypeForm
,
self
).
__init__
(
*
args
,
prefix
=
prefix
,
**
kwargs
)
self
.
fields
[
'
typ
e'
].
label
=
_
(
"IP type to add"
)
self
.
fields
[
'
nam
e'
].
label
=
_
(
"IP type to add"
)
class
EditIpTypeForm
(
IpTypeForm
):
...
...
@@ -236,7 +236,7 @@ class EditIpTypeForm(IpTypeForm):
synchroniser les objets iplist"""
class
Meta
(
IpTypeForm
.
Meta
):
fields
=
[
'extension'
,
'
typ
e'
,
'need_infra'
,
'domaine_ip_network'
,
'domaine_ip_netmask'
,
fields
=
[
'extension'
,
'
nam
e'
,
'need_infra'
,
'domaine_ip_network'
,
'domaine_ip_netmask'
,
'prefix_v6'
,
'prefix_v6_length'
,
'vlan'
,
'reverse_v4'
,
'reverse_v6'
,
'ouverture_ports'
]
...
...
machines/migrations/0102_auto_20190303_1611.py
0 → 100644
View file @
c9b84047
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2019-03-03 15:11
from
__future__
import
unicode_literals
from
django.db
import
migrations
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0101_auto_20190108_1623'
),
]
operations
=
[
migrations
.
RenameField
(
model_name
=
'interface'
,
old_name
=
'type'
,
new_name
=
'machine_type'
,
),
migrations
.
RenameField
(
model_name
=
'iptype'
,
old_name
=
'type'
,
new_name
=
'name'
,
),
migrations
.
RenameField
(
model_name
=
'machinetype'
,
old_name
=
'type'
,
new_name
=
'name'
,
),
]
machines/models.py
View file @
c9b84047
...
...
@@ -241,7 +241,7 @@ class Machine(RevMixin, FieldPermissionModelMixin, models.Model):
class
MachineType
(
RevMixin
,
AclMixin
,
models
.
Model
):
""" Type de machine, relié à un type d'ip, affecté aux interfaces"""
typ
e
=
models
.
CharField
(
max_length
=
255
)
nam
e
=
models
.
CharField
(
max_length
=
255
)
ip_type
=
models
.
ForeignKey
(
'IpType'
,
on_delete
=
models
.
PROTECT
,
...
...
@@ -260,7 +260,7 @@ class MachineType(RevMixin, AclMixin, models.Model):
def
all_interfaces
(
self
):
""" Renvoie toutes les interfaces (cartes réseaux) de type
machinetype"""
return
Interface
.
objects
.
filter
(
type
=
self
)
return
Interface
.
objects
.
filter
(
machine_
type
=
self
)
@
staticmethod
def
can_use_all
(
user_request
,
*
_args
,
**
_kwargs
):
...
...
@@ -278,12 +278,12 @@ class MachineType(RevMixin, AclMixin, models.Model):
return
True
,
None
def
__str__
(
self
):
return
self
.
typ
e
return
self
.
nam
e
class
IpType
(
RevMixin
,
AclMixin
,
models
.
Model
):
""" Type d'ip, définissant un range d'ip, affecté aux machine types"""
typ
e
=
models
.
CharField
(
max_length
=
255
)
nam
e
=
models
.
CharField
(
max_length
=
255
)
extension
=
models
.
ForeignKey
(
'Extension'
,
on_delete
=
models
.
PROTECT
)
need_infra
=
models
.
BooleanField
(
default
=
False
)
domaine_ip_start
=
models
.
GenericIPAddressField
(
protocol
=
'IPv4'
)
...
...
@@ -456,7 +456,7 @@ class IpType(RevMixin, AclMixin, models.Model):
else
:
for
ipv6
in
Ipv6List
.
objects
.
filter
(
interface__in
=
Interface
.
objects
.
filter
(
type__in
=
MachineType
.
objects
.
filter
(
ip_type
=
self
)
machine_
type__in
=
MachineType
.
objects
.
filter
(
ip_type
=
self
)
)
):
ipv6
.
check_and_replace_prefix
(
prefix
=
self
.
prefix_v6
)
...
...
@@ -465,7 +465,7 @@ class IpType(RevMixin, AclMixin, models.Model):
from
re2o.utils
import
all_active_assigned_interfaces
if
self
.
reverse_v4
:
return
(
all_active_assigned_interfaces
()
.
filter
(
type__ip_type
=
self
)
.
filter
(
machine_
type__ip_type
=
self
)
.
filter
(
ipv4__isnull
=
False
))
else
:
return
None
...
...
@@ -474,7 +474,7 @@ class IpType(RevMixin, AclMixin, models.Model):
from
re2o.utils
import
all_active_interfaces
if
self
.
reverse_v6
:
return
(
all_active_interfaces
(
full
=
True
)
.
filter
(
type__ip_type
=
self
))
.
filter
(
machine_
type__ip_type
=
self
))
else
:
return
None
...
...
@@ -519,7 +519,7 @@ class IpType(RevMixin, AclMixin, models.Model):
return
user_request
.
has_perm
(
'machines.use_all_iptype'
),
None
def
__str__
(
self
):
return
self
.
typ
e
return
self
.
nam
e
class
Vlan
(
RevMixin
,
AclMixin
,
models
.
Model
):
...
...
@@ -724,19 +724,19 @@ class Extension(RevMixin, AclMixin, models.Model):
def
get_associated_sshfp_records
(
self
):
from
re2o.utils
import
all_active_assigned_interfaces
return
(
all_active_assigned_interfaces
()
.
filter
(
type__ip_type__extension
=
self
)
.
filter
(
machine_
type__ip_type__extension
=
self
)
.
filter
(
machine__id__in
=
SshFp
.
objects
.
values
(
'machine'
)))
def
get_associated_a_records
(
self
):
from
re2o.utils
import
all_active_assigned_interfaces
return
(
all_active_assigned_interfaces
()
.
filter
(
type__ip_type__extension
=
self
)
.
filter
(
machine_
type__ip_type__extension
=
self
)
.
filter
(
ipv4__isnull
=
False
))
def
get_associated_aaaa_records
(
self
):
from
re2o.utils
import
all_active_interfaces
return
(
all_active_interfaces
(
full
=
True
)
.
filter
(
type__ip_type__extension
=
self
))
.
filter
(
machine_
type__ip_type__extension
=
self
))
def
get_associated_cname_records
(
self
):
from
re2o.utils
import
all_active_assigned_interfaces
...
...
@@ -1003,7 +1003,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
)
mac_address
=
MACAddressField
(
integer
=
False
)
machine
=
models
.
ForeignKey
(
'Machine'
,
on_delete
=
models
.
CASCADE
)
type
=
models
.
ForeignKey
(
'MachineType'
,
on_delete
=
models
.
PROTECT
)
machine_
type
=
models
.
ForeignKey
(
'MachineType'
,
on_delete
=
models
.
PROTECT
)
details
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
)
port_lists
=
models
.
ManyToManyField
(
'OuverturePortList'
,
blank
=
True
)
...
...
@@ -1027,9 +1027,9 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
def
ipv6_slaac
(
self
):
""" Renvoie un objet type ipv6 à partir du prefix associé à
l'iptype parent"""
if
self
.
type
.
ip_type
.
prefix_v6
:
if
self
.
machine_
type
.
ip_type
.
prefix_v6
:
return
EUI
(
self
.
mac_address
).
ipv6
(
IPNetwork
(
self
.
type
.
ip_type
.
prefix_v6
).
network
IPNetwork
(
self
.
machine_
type
.
ip_type
.
prefix_v6
).
network
)
else
:
return
None
...
...
@@ -1037,7 +1037,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
@
cached_property
def
gen_ipv6_dhcpv6
(
self
):
"""Cree une ip, à assigner avec dhcpv6 sur une machine"""
prefix_v6
=
self
.
type
.
ip_type
.
prefix_v6
.
encode
().
decode
(
'utf-8'
)
prefix_v6
=
self
.
machine_
type
.
ip_type
.
prefix_v6
.
encode
().
decode
(
'utf-8'
)
if
not
prefix_v6
:
return
None
return
IPv6Address
(
...
...
@@ -1122,7 +1122,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
def
assign_ipv4
(
self
):
""" Assigne une ip à l'interface """
free_ips
=
self
.
type
.
ip_type
.
free_ip
()
free_ips
=
self
.
machine_
type
.
ip_type
.
free_ip
()
if
free_ips
:
self
.
ipv4
=
free_ips
[
0
]
else
:
...
...
@@ -1162,16 +1162,16 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
# instance.
# But in our case, it's impossible to create a type value so we raise
# the error.
if
not
hasattr
(
self
,
'type'
):
if
not
hasattr
(
self
,
'
machine_
type'
):
raise
ValidationError
(
_
(
"The selected IP type is invalid."
))
self
.
filter_macaddress
()
if
not
self
.
ipv4
or
self
.
type
.
ip_type
!=
self
.
ipv4
.
ip_type
:
if
not
self
.
ipv4
or
self
.
machine_
type
.
ip_type
!=
self
.
ipv4
.
ip_type
:
self
.
assign_ipv4
()
super
(
Interface
,
self
).
clean
(
*
args
,
**
kwargs
)
def
validate_unique
(
self
,
*
args
,
**
kwargs
):
super
(
Interface
,
self
).
validate_unique
(
*
args
,
**
kwargs
)
interfaces_similar
=
Interface
.
objects
.
filter
(
mac_address
=
self
.
mac_address
,
type__ip_type
=
self
.
type
.
ip_type
)
interfaces_similar
=
Interface
.
objects
.
filter
(
mac_address
=
self
.
mac_address
,
machine_type__ip_type
=
self
.
machine_
type
.
ip_type
)
if
interfaces_similar
and
interfaces_similar
.
first
()
!=
self
:
raise
ValidationError
(
_
(
"Mac address already registered in this Machine Type/Subnet"
))
...
...
@@ -1179,7 +1179,7 @@ class Interface(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
self
.
filter_macaddress
()
# On verifie la cohérence en forçant l'extension par la méthode
if
self
.
ipv4
:
if
self
.
type
.
ip_type
!=
self
.
ipv4
.
ip_type
:
if
self
.
machine_
type
.
ip_type
!=
self
.
ipv4
.
ip_type
:
raise
ValidationError
(
_
(
"The IPv4 address and the machine type"
" don't match."
))
self
.
validate_unique
()
...
...
@@ -1381,7 +1381,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
def
check_and_replace_prefix
(
self
,
prefix
=
None
):
"""Si le prefixe v6 est incorrect, on maj l'ipv6"""
prefix_v6
=
prefix
or
self
.
interface
.
type
.
ip_type
.
prefix_v6
.
encode
().
decode
(
'utf-8'
)
prefix_v6
=
prefix
or
self
.
interface
.
machine_
type
.
ip_type
.
prefix_v6
.
encode
().
decode
(
'utf-8'
)
if
not
prefix_v6
:
return
if
(
IPv6Address
(
self
.
ipv6
.
encode
().
decode
(
'utf-8'
)).
exploded
[:
20
]
!=
...
...
@@ -1398,7 +1398,7 @@ class Ipv6List(RevMixin, AclMixin, FieldPermissionModelMixin, models.Model):
.
exclude
(
id
=
self
.
id
)):
raise
ValidationError
(
_
(
"A SLAAC IP address is already registered."
))
try
:
prefix_v6
=
self
.
interface
.
type
.
ip_type
.
prefix_v6
.
encode
().
decode
(
'utf-8'
)
prefix_v6
=
self
.
interface
.
machine_
type
.
ip_type
.
prefix_v6
.
encode
().
decode
(
'utf-8'
)
except
AttributeError
:
# Prevents from crashing when there is no defined prefix_v6
prefix_v6
=
None
if
prefix_v6
:
...
...
@@ -1453,7 +1453,7 @@ class Domain(RevMixin, AclMixin, models.Model):
""" Retourne l'extension de l'interface parente si c'est un A
Retourne l'extension propre si c'est un cname, renvoie None sinon"""
if
self
.
interface_parent
:
return
self
.
interface_parent
.
type
.
ip_type
.
extension
return
self
.
interface_parent
.
machine_
type
.
ip_type
.
extension
elif
hasattr
(
self
,
'extension'
):
return
self
.
extension
else
:
...
...
machines/templates/machines/aff_iptype.html
View file @
c9b84047
...
...
@@ -45,7 +45,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</thead>
{% for type in iptype_list %}
<tr>
<td>
{{ type.
typ
e }}
</td>
<td>
{{ type.
nam
e }}
</td>
<td>
{{ type.extension }}
</td>
<td>
{{ type.need_infra|tick }}
</td>
<td>
{{ type.domaine_ip_start }}-{{ type.domaine_ip_stop }}{% if type.ip_network %}
<b><u>
on
</u></b>
...
...
machines/templates/machines/aff_machines.html
View file @
c9b84047
...
...
@@ -88,7 +88,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
{% endif %}
</td>
<td>
{{ interface.type }}
{{ interface.
machine_
type }}
</td>
<td>
{{ interface.mac_address }}
...
...
machines/templates/machines/aff_machinetype.html
View file @
c9b84047
...
...
@@ -36,7 +36,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
</thead>
{% for type in machinetype_list %}
<tr>
<td>
{{ type.
typ
e }}
</td>
<td>
{{ type.
nam
e }}
</td>
<td>
{{ type.ip_type }}
</td>
<td
class=
"text-right"
>
{% can_edit type %}
...
...
machines/views.py
View file @
c9b84047
...
...
@@ -144,7 +144,7 @@ def f_type_id(is_type_tt):
""" The id that will be used in HTML to store the value of the field
type. Depends on the fact that type is generate using typeahead or not
"""
return
'id_Interface-
type_hidden'
if
is_type_tt
else
'id_Interface-
type'
return
'id_Interface-
machine_type_hidden'
if
is_type_tt
else
'id_Interface-machine_
type'
def
generate_ipv4_choices
(
form_obj
):
...
...
@@ -170,7 +170,7 @@ def generate_ipv4_choices(form_obj):
v
=
ip
.
ipv4
)
for
t
in
form_obj
.
fields
[
'type'
].
queryset
.
exclude
(
id__in
=
used_mtype_id
):
for
t
in
form_obj
.
fields
[
'
machine_
type'
].
queryset
.
exclude
(
id__in
=
used_mtype_id
):
choices
+=
'], "'
+
str
(
t
.
id
)
+
'": ['
choices
+=
'{key: "", value: "'
+
str
(
f_ipv4
.
empty_label
)
+
'"},'
choices
+=
']}'
...
...
@@ -184,11 +184,11 @@ def generate_ipv4_engine(is_type_tt):
'new Bloodhound( {{'
'datumTokenizer: Bloodhound.tokenizers.obj.whitespace( "value" ),'
'queryTokenizer: Bloodhound.tokenizers.whitespace,'
'local: choices_ipv4[ $( "#{type_id}" ).val() ],'
'local: choices_ipv4[ $( "#{
machine_
type_id}" ).val() ],'
'identify: function( obj ) {{ return obj.key; }}'
'}} )'
).
format
(
type_id
=
f_type_id
(
is_type_tt
)
machine_
type_id
=
f_type_id
(
is_type_tt
)
)
...
...
@@ -198,7 +198,7 @@ def generate_ipv4_match_func(is_type_tt):
return
(
'function(q, sync) {{'
'if (q === "") {{'
'var first = choices_ipv4[$("#{type_id}").val()].slice(0, 5);'
'var first = choices_ipv4[$("#{
machine_
type_id}").val()].slice(0, 5);'
'first = first.map( function (obj) {{ return obj.key; }} );'
'sync(engine_ipv4.get(first));'
'}} else {{'
...
...
@@ -206,7 +206,7 @@ def generate_ipv4_match_func(is_type_tt):
'}}'
'}}'
).
format
(
type_id
=
f_type_id
(
is_type_tt
)
machine_
type_id
=
f_type_id
(
is_type_tt
)
)
...
...
@@ -1388,7 +1388,7 @@ def index(request):
.
prefetch_related
(
'interface_set__domain__extension'
)
.
prefetch_related
(
'interface_set__ipv4__ip_type'
)
.
prefetch_related
(
'interface_set__type__ip_type__extension'
'interface_set__
machine_
type__ip_type__extension'
).
prefetch_related
(
'interface_set__domain__related_domain__extension'
).
prefetch_related
(
'interface_set__ipv6list'
))
...
...
@@ -1417,7 +1417,7 @@ def index_iptype(request):
iptype_list
=
(
IpType
.
objects
.
select_related
(
'extension'
)
.
select_related
(
'vlan'
)
.
order_by
(
'
typ
e'
))
.
order_by
(
'
nam
e'
))
return
render
(
request
,
'machines/index_iptype.html'
,
...
...
@@ -1443,7 +1443,7 @@ def index_machinetype(request):
""" View displaying the list of existing types of machines """
machinetype_list
=
(
MachineType
.
objects
.
select_related
(
'ip_type'
)
.
order_by
(
'
typ
e'
))
.
order_by
(
'
nam
e'
))
return
render
(
request
,
'machines/index_machinetype.html'
,
...
...
re2o/utils.py
View file @
c9b84047
...
...
@@ -126,7 +126,7 @@ def filter_active_interfaces(interface_set):
).
filter
(
active
=
True
)
).
select_related
(
'domain'
)
.
select_related
(
'machine'
)
.
select_related
(
'type'
)
.
select_related
(
'
machine_
type'
)
.
select_related
(
'ipv4'
)
.
select_related
(
'domain__extension'
)
.
select_related
(
'ipv4__ip_type'
)
...
...
topologie/models.py
View file @
c9b84047
...
...
@@ -300,7 +300,7 @@ class Switch(AclMixin, Machine):
It must the the management interface for that device"""
switch_iptype
=
OptionalTopologie
.
get_cached_value
(
'switchs_ip_type'
)
if
switch_iptype
:
return
self
.
interface_set
.
filter
(
type__ip_type
=
switch_iptype
).
first
()
return
self
.
interface_set
.
filter
(
machine_
type__ip_type
=
switch_iptype
).
first
()
return
self
.
interface_set
.
first
()
@
cached_property
...
...
users/views.py
View file @
c9b84047
...
...
@@ -965,7 +965,7 @@ def profil(request, users, **_kwargs):
machines
=
Machine
.
objects
.
filter
(
user
=
users
).
select_related
(
'user'
)
\
.
prefetch_related
(
'interface_set__domain__extension'
)
\
.
prefetch_related
(
'interface_set__ipv4__ip_type__extension'
)
\
.
prefetch_related
(
'interface_set__type'
)
\
.
prefetch_related
(
'interface_set__
machine_
type'
)
\
.
prefetch_related
(
'interface_set__domain__related_domain__extension'
)
machines
=
SortTable
.
sort
(
machines
,
...
...
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