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
b57fed74
Commit
b57fed74
authored
Oct 02, 2017
by
LEVY-FALK Hugo
Committed by
root
Oct 02, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Affectation de configuration de ports à une interface.
parent
ad67b9cb
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
54 additions
and
6 deletions
+54
-6
machines/forms.py
machines/forms.py
+5
-5
machines/migrations/0061_auto_20171001_1727.py
machines/migrations/0061_auto_20171001_1727.py
+24
-0
machines/models.py
machines/models.py
+3
-0
machines/templates/machines/aff_machines.html
machines/templates/machines/aff_machines.html
+5
-0
machines/urls.py
machines/urls.py
+2
-0
machines/views.py
machines/views.py
+15
-1
No files found.
machines/forms.py
View file @
b57fed74
...
...
@@ -52,14 +52,14 @@ class BaseEditMachineForm(EditMachineForm):
class
EditInterfaceForm
(
ModelForm
):
class
Meta
:
model
=
Interface
fields
=
'__all__'
# fields = '__all__'
exclude
=
[
'port_lists'
]
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
EditInterfaceForm
,
self
).
__init__
(
*
args
,
**
kwargs
)
self
.
fields
[
'mac_address'
].
label
=
'Adresse mac'
self
.
fields
[
'type'
].
label
=
'Type de machine'
self
.
fields
[
'type'
].
empty_label
=
"Séléctionner un type de machine"
self
.
fields
[
'port_lists'
].
label
=
"Configuration des ports"
if
"machine"
in
self
.
fields
:
self
.
fields
[
'machine'
].
queryset
=
Machine
.
objects
.
all
().
select_related
(
'user'
)
...
...
@@ -232,10 +232,10 @@ class VlanForm(ModelForm):
class
DelVlanForm
(
Form
):
vlan
=
forms
.
ModelMultipleChoiceField
(
queryset
=
Vlan
.
objects
.
all
(),
label
=
"Vlan actuels"
,
widget
=
forms
.
CheckboxSelectMultiple
)
class
EditPortForm
(
ModelForm
):
class
EditPort
Config
Form
(
ModelForm
):
class
Meta
:
model
=
Port
fields
=
'__all__'
model
=
Interface
fields
=
[
'port_lists'
]
class
EditPortListForm
(
ModelForm
):
class
Meta
:
...
...
machines/migrations/0061_auto_20171001_1727.py
0 → 100644
View file @
b57fed74
# -*- coding: utf-8 -*-
# Generated by Django 1.10.7 on 2017-10-01 15:27
from
__future__
import
unicode_literals
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'machines'
,
'0060_port_io'
),
]
operations
=
[
migrations
.
RemoveField
(
model_name
=
'portlist'
,
name
=
'interfaces'
,
),
migrations
.
AddField
(
model_name
=
'interface'
,
name
=
'port_lists'
,
field
=
models
.
ManyToManyField
(
to
=
'machines.PortList'
),
),
]
machines/models.py
View file @
b57fed74
...
...
@@ -279,6 +279,9 @@ class Interface(models.Model):
domain
=
None
return
str
(
domain
)
def
has_private_ip
(
self
):
return
IPAddress
(
str
(
self
.
ipv4
)).
is_private
()
class
Domain
(
models
.
Model
):
PRETTY_NAME
=
"Domaine dns"
...
...
machines/templates/machines/aff_machines.html
View file @
b57fed74
...
...
@@ -91,6 +91,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
<i
class=
"glyphicon glyphicon-edit"
></i>
Gerer les alias
</a>
</li>
<li>
<a
href=
"{% url 'machines:port-config' interface.id%}"
>
<i
class=
"glyphicon glyphicon-edit"
></i>
Gerer la configuration des ports
</a>
</li>
<li>
<a
href=
"{% url 'machines:history' 'interface' interface.id %}"
>
<i
class=
"glyphicon glyphicon-time"
></i>
Historique
...
...
machines/urls.py
View file @
b57fed74
...
...
@@ -96,4 +96,6 @@ urlpatterns = [
url
(
r
'^edit_portlist/(?P<pk>[0-9]+)$'
,
views
.
edit_portlist
,
name
=
'edit-portlist'
),
url
(
r
'^del_portlist/(?P<pk>[0-9]+)$'
,
views
.
del_portlist
,
name
=
'del-portlist'
),
url
(
r
'^add_portlist/$'
,
views
.
add_portlist
,
name
=
'add-portlist'
),
url
(
r
'^port_config/(?P<pk>[0-9]+)$'
,
views
.
configure_ports
,
name
=
'port-config'
),
]
machines/views.py
View file @
b57fed74
...
...
@@ -48,7 +48,7 @@ from reversion.models import Version
import
re
from
.forms
import
NewMachineForm
,
EditMachineForm
,
EditInterfaceForm
,
AddInterfaceForm
,
MachineTypeForm
,
DelMachineTypeForm
,
ExtensionForm
,
DelExtensionForm
,
BaseEditInterfaceForm
,
BaseEditMachineForm
from
.forms
import
EditIpTypeForm
,
IpTypeForm
,
DelIpTypeForm
,
DomainForm
,
AliasForm
,
DelAliasForm
,
NsForm
,
DelNsForm
,
TextForm
,
DelTextForm
,
MxForm
,
DelMxForm
,
VlanForm
,
DelVlanForm
,
ServiceForm
,
DelServiceForm
,
NasForm
,
DelNasForm
from
.forms
import
EditPortListForm
,
EditPortForm
from
.forms
import
EditPortListForm
,
EditPort
Config
Form
from
.models
import
IpType
,
Machine
,
Interface
,
IpList
,
MachineType
,
Extension
,
Mx
,
Ns
,
Domain
,
Service
,
Service_link
,
Vlan
,
Nas
,
Text
,
PortList
,
Port
from
users.models
import
User
from
users.models
import
all_has_access
...
...
@@ -993,6 +993,20 @@ def add_portlist(request):
return
redirect
(
"/machines/index_portlist/"
)
return
form
({
'machineform'
:
port_list
},
'machines/machine.html'
,
request
)
@
login_required
@
permission_required
(
'cableur'
)
def
configure_ports
(
request
,
pk
):
try
:
interface_instance
=
Interface
.
objects
.
get
(
pk
=
pk
)
except
Interface
.
DoesNotExist
:
messages
.
error
(
request
,
u
"Interface inexistante"
)
return
redirect
(
"/machines"
)
interface
=
EditPortConfigForm
(
request
.
POST
or
None
,
instance
=
interface_instance
)
if
interface
.
is_valid
():
interface
.
save
()
messages
.
success
(
request
,
"Configuration des ports mise à jour."
)
return
redirect
(
"/machines/"
)
return
form
({
'interfaceform'
:
interface
},
'machines/machine.html'
,
request
)
""" Framework Rest """
...
...
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