Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
857316e0
authored
Feb 06, 2015
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'issue-378' into 'master'
Firewall model to network GUI
✅
closes
#378
See merge request
!290
parents
9e28c78c
ffa98f10
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
275 additions
and
91 deletions
+275
-91
circle/firewall/models.py
+13
-18
circle/network/forms.py
+19
-2
circle/network/static/network/network.less
+17
-0
circle/network/tables.py
+34
-0
circle/network/templates/network/base.html
+0
-26
circle/network/templates/network/columns/firewall-rule-actions.html
+5
-0
circle/network/templates/network/columns/host-rule-action.html
+1
-1
circle/network/templates/network/confirm/base_delete.html
+1
-1
circle/network/templates/network/firewall-create.html
+18
-0
circle/network/templates/network/firewall-edit.html
+31
-0
circle/network/templates/network/firewall-list.html
+20
-0
circle/network/templates/network/host-edit.html
+1
-1
circle/network/templates/network/menu.html
+12
-18
circle/network/urls.py
+43
-16
circle/network/views.py
+60
-8
No files found.
circle/firewall/models.py
View file @
857316e0
...
@@ -33,6 +33,7 @@ from firewall.fields import (MACAddressField, val_alfanum, val_reverse_domain,
...
@@ -33,6 +33,7 @@ from firewall.fields import (MACAddressField, val_alfanum, val_reverse_domain,
val_ipv6
,
val_mx
,
val_ipv6
,
val_mx
,
IPNetworkField
,
IPAddressField
)
IPNetworkField
,
IPAddressField
)
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
from
django.core.urlresolvers
import
reverse
import
django.conf
import
django.conf
from
django.db.models.signals
import
post_save
,
post_delete
from
django.db.models.signals
import
post_save
,
post_delete
from
celery.exceptions
import
TimeoutError
from
celery.exceptions
import
TimeoutError
...
@@ -191,9 +192,8 @@ class Rule(models.Model):
...
@@ -191,9 +192,8 @@ class Rule(models.Model):
return
field
.
__class__
.
__name__
.
lower
()
return
field
.
__class__
.
__name__
.
lower
()
return
None
return
None
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.rule'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.rule'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_chain_name
(
self
,
local
,
remote
):
def
get_chain_name
(
self
,
local
,
remote
):
if
local
:
# host or vlan
if
local
:
# host or vlan
...
@@ -476,9 +476,8 @@ class Vlan(AclBase, models.Model):
...
@@ -476,9 +476,8 @@ class Vlan(AclBase, models.Model):
return
"
%
s -
%
s"
%
(
"managed"
if
self
.
managed
else
"unmanaged"
,
return
"
%
s -
%
s"
%
(
"managed"
if
self
.
managed
else
"unmanaged"
,
self
.
name
)
self
.
name
)
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.vlan'
,
None
,
{
'vid'
:
self
.
vid
})
return
reverse
(
'network.vlan'
,
kwargs
=
{
'vid'
:
self
.
vid
})
def
get_random_addresses
(
self
,
used_v4
,
buffer_size
=
100
,
max_hosts
=
10000
):
def
get_random_addresses
(
self
,
used_v4
,
buffer_size
=
100
,
max_hosts
=
10000
):
addresses
=
islice
(
self
.
network4
.
iter_hosts
(),
max_hosts
)
addresses
=
islice
(
self
.
network4
.
iter_hosts
(),
max_hosts
)
...
@@ -544,9 +543,8 @@ class VlanGroup(models.Model):
...
@@ -544,9 +543,8 @@ class VlanGroup(models.Model):
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
return
self
.
name
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.vlan_group'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.vlan_group'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Group
(
models
.
Model
):
class
Group
(
models
.
Model
):
...
@@ -567,9 +565,8 @@ class Group(models.Model):
...
@@ -567,9 +565,8 @@ class Group(models.Model):
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
return
self
.
name
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.group'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.group'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Host
(
models
.
Model
):
class
Host
(
models
.
Model
):
...
@@ -919,9 +916,8 @@ class Host(models.Model):
...
@@ -919,9 +916,8 @@ class Host(models.Model):
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
public_port
else
None
endpoints
[
'ipv6'
]
=
(
self
.
ipv6
,
port
)
if
public_port
else
None
return
endpoints
return
endpoints
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.host'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.host'
,
kwargs
=
{
'pk'
:
self
.
pk
})
@property
@property
def
eui
(
self
):
def
eui
(
self
):
...
@@ -970,6 +966,9 @@ class Firewall(models.Model):
...
@@ -970,6 +966,9 @@ class Firewall(models.Model):
logger
.
exception
(
"get_dhcp_clients failed"
)
logger
.
exception
(
"get_dhcp_clients failed"
)
return
{}
return
{}
def
get_absolute_url
(
self
):
return
reverse
(
'network.firewall'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Domain
(
models
.
Model
):
class
Domain
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
40
,
validators
=
[
val_domain
],
name
=
models
.
CharField
(
max_length
=
40
,
validators
=
[
val_domain
],
...
@@ -985,9 +984,8 @@ class Domain(models.Model):
...
@@ -985,9 +984,8 @@ class Domain(models.Model):
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
name
return
self
.
name
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.domain'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.domain'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Record
(
models
.
Model
):
class
Record
(
models
.
Model
):
...
@@ -1056,9 +1054,8 @@ class Record(models.Model):
...
@@ -1056,9 +1054,8 @@ class Record(models.Model):
else
:
else
:
return
self
.
domain
.
name
return
self
.
domain
.
name
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.record'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.record'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Meta
:
class
Meta
:
ordering
=
(
ordering
=
(
...
@@ -1088,9 +1085,8 @@ class SwitchPort(models.Model):
...
@@ -1088,9 +1085,8 @@ class SwitchPort(models.Model):
self
.
untagged_vlan
,
self
.
untagged_vlan
,
tagged_vlans
)
tagged_vlans
)
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.switch_port'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.switch_port'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
EthernetDevice
(
models
.
Model
):
class
EthernetDevice
(
models
.
Model
):
...
@@ -1143,9 +1139,8 @@ class BlacklistItem(models.Model):
...
@@ -1143,9 +1139,8 @@ class BlacklistItem(models.Model):
verbose_name
=
_
(
'blacklist item'
)
verbose_name
=
_
(
'blacklist item'
)
verbose_name_plural
=
_
(
'blacklist'
)
verbose_name_plural
=
_
(
'blacklist'
)
@models.permalink
def
get_absolute_url
(
self
):
def
get_absolute_url
(
self
):
return
(
'network.blacklist'
,
None
,
{
'pk'
:
self
.
pk
})
return
reverse
(
'network.blacklist'
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
send_task
(
sender
,
instance
,
created
=
False
,
**
kwargs
):
def
send_task
(
sender
,
instance
,
created
=
False
,
**
kwargs
):
...
...
circle/network/forms.py
View file @
857316e0
...
@@ -23,8 +23,10 @@ from crispy_forms.helper import FormHelper
...
@@ -23,8 +23,10 @@ from crispy_forms.helper import FormHelper
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Div
,
Submit
,
BaseInput
from
crispy_forms.layout
import
Layout
,
Fieldset
,
Div
,
Submit
,
BaseInput
from
crispy_forms.bootstrap
import
FormActions
,
FieldWithButtons
,
StrictButton
from
crispy_forms.bootstrap
import
FormActions
,
FieldWithButtons
,
StrictButton
from
firewall.models
import
(
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
from
firewall.models
import
(
Rule
,
VlanGroup
,
SwitchPort
)
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
Rule
,
VlanGroup
,
SwitchPort
,
Firewall
)
class
LinkButton
(
BaseInput
):
class
LinkButton
(
BaseInput
):
...
@@ -88,6 +90,21 @@ class DomainForm(ModelForm):
...
@@ -88,6 +90,21 @@ class DomainForm(ModelForm):
model
=
Domain
model
=
Domain
class
FirewallForm
(
ModelForm
):
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
Div
(
Fieldset
(
''
,
'name'
,
)),
FormActions
(
Submit
(
'submit'
,
_
(
"Save"
)),
LinkButton
(
'back'
,
_
(
"Back"
),
reverse_lazy
(
'network.firewall_list'
))
)
)
class
Meta
:
model
=
Firewall
class
GroupForm
(
ModelForm
):
class
GroupForm
(
ModelForm
):
helper
=
FormHelper
()
helper
=
FormHelper
()
helper
.
layout
=
Layout
(
helper
.
layout
=
Layout
(
...
...
circle/network/static/network/network.less
View file @
857316e0
...
@@ -12,6 +12,23 @@
...
@@ -12,6 +12,23 @@
width: 60px;
width: 60px;
}
}
body {
padding-top: 40px;
}
/* note: this doesn't really work */
a i:hover {
text-decoration: none;
}
footer {
margin-top: 45px;
}
.messagelist {
margin-top: 25px;
}
#rule-list-table {
#rule-list-table {
td {
td {
text-align: center;
text-align: center;
...
...
circle/network/tables.py
View file @
857316e0
...
@@ -245,3 +245,37 @@ class HostRecordsTable(Table):
...
@@ -245,3 +245,37 @@ class HostRecordsTable(Table):
fields
=
(
"type"
,
"fqdn"
)
fields
=
(
"type"
,
"fqdn"
)
order_by
=
(
"name"
,
)
order_by
=
(
"name"
,
)
empty_text
=
_
(
"No records."
)
empty_text
=
_
(
"No records."
)
class
FirewallTable
(
Table
):
pk
=
LinkColumn
(
'network.firewall'
,
args
=
[
A
(
'pk'
)],
verbose_name
=
"ID"
)
class
Meta
:
model
=
SwitchPort
attrs
=
{
'class'
:
'table table-striped'
}
fields
=
(
'pk'
,
'name'
,
)
order_by
=
'pk'
class
FirewallRuleTable
(
Table
):
color_desc
=
TemplateColumn
(
template_name
=
"network/columns/rule-short-description.html"
,
verbose_name
=
_
(
"Short description"
),
orderable
=
False
,
)
actions
=
TemplateColumn
(
template_name
=
"network/columns/firewall-rule-actions.html"
,
verbose_name
=
_
(
"Actions"
),
orderable
=
False
,
)
class
Meta
:
model
=
Rule
template
=
"django_tables2/table_no_page.html"
attrs
=
{
'class'
:
'table table-striped table-hover table-condensed'
,
'id'
:
"rule-list-table"
}
fields
=
(
'color_desc'
,
'extra'
,
'direction'
,
'action'
,
'proto'
,
'actions'
)
order_by
=
'-pk'
empty_text
=
_
(
"No related rules found."
)
circle/network/templates/network/base.html
View file @
857316e0
...
@@ -6,32 +6,6 @@
...
@@ -6,32 +6,6 @@
{% block title-site %}{% trans "Network" %} | CIRCLE{% endblock %}
{% block title-site %}{% trans "Network" %} | CIRCLE{% endblock %}
{% block extra_link %}
<link
href=
'//fonts.googleapis.com/css?family=Source+Sans+Pro:200,400&subset=latin,latin-ext'
rel=
'stylesheet'
type=
'text/css'
>
<link
href=
"{% static "
network
/
network
.
css
"
%}"
rel=
"stylesheet"
>
{% endblock %}
{% block extra_css %}
<style
type=
"text/css"
>
body
{
padding-top
:
40px
;
}
/* note: this doesn't really work */
a
i
:hover
{
text-decoration
:
none
;
}
footer
{
margin-top
:
45px
;
}
.messagelist
{
margin-top
:
25px
;
}
</style>
{% endblock %}
{% block navbar-brand %}
{% block navbar-brand %}
<a
class=
"navbar-brand"
href=
"{% url "
network
.
index
"
%}"
>
CIRCLE Network
</a>
<a
class=
"navbar-brand"
href=
"{% url "
network
.
index
"
%}"
>
CIRCLE Network
</a>
{% endblock %}
{% endblock %}
...
...
circle/network/templates/network/columns/firewall-rule-actions.html
0 → 100644
View file @
857316e0
{% load i18n %}
<div
style=
"white-space: nowrap;"
>
<a
href=
"{% url "
network
.
rule_delete
"
pk=
record.pk
%}?
next=
{{
request
.
path
}}"
><i
class=
"fa fa-times"
></i></a>
<a
href=
"{% url "
network
.
rule
"
pk=
record.pk
%}"
><i
class=
"fa fa-pencil"
></i></a>
</div>
circle/network/templates/network/columns/host-rule-action.html
View file @
857316e0
{% load i18n %}
{% load i18n %}
{% load l10n %}
{% load l10n %}
<div
style=
"white-space: nowrap;"
>
<div
style=
"white-space: nowrap;"
>
<a
href=
"{% url "
network
.
rule_delete
"
pk=
record.pk
%}?
from
=
{{
request
.
path
}}"
><i
class=
"fa fa-times"
></i></a>
<a
href=
"{% url "
network
.
rule_delete
"
pk=
record.pk
%}?
next
=
{{
request
.
path
}}"
><i
class=
"fa fa-times"
></i></a>
<a
href=
"{% url "
network
.
rule
"
pk=
record.pk
%}"
><i
class=
"fa fa-pencil"
></i></a>
<a
href=
"{% url "
network
.
rule
"
pk=
record.pk
%}"
><i
class=
"fa fa-pencil"
></i></a>
</div>
</div>
circle/network/templates/network/confirm/base_delete.html
View file @
857316e0
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
</div>
</div>
{% endif %}
{% endif %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
<input
type=
"hidden"
value=
"{{ request.GET.
from
}}"
name=
"next"
/>
<input
type=
"hidden"
value=
"{{ request.GET.
next
}}"
name=
"next"
/>
{% if confirmation %}
{% if confirmation %}
<label><p>
<label><p>
{% trans "If you are really sure, type in the object's name!" %}
{% trans "If you are really sure, type in the object's name!" %}
...
...
circle/network/templates/network/firewall-create.html
0 → 100644
View file @
857316e0
{% extends "network/base.html" %}
{% load i18n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title-page %}{% trans "Create" %} | {% trans "firewall" %}{% endblock %}
{% block content %}
<div
class=
"page-header"
>
<h2>
{% trans "Create a new firewall" %}
</h2>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-8"
>
{% crispy form %}
</div>
</div>
{% endblock %}
circle/network/templates/network/firewall-edit.html
0 → 100644
View file @
857316e0
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load staticfiles %}
{% load crispy_forms_tags %}
{% block title-page %}{{ object.name }} | {% trans "firewall" %}{% endblock %}
{% block content %}
<div
class=
"page-header"
>
<a
href=
"{% url "
network
.
firewall_delete
"
pk=
object.pk
%}"
class=
"btn btn-danger pull-right"
>
<i
class=
"fa fa-times-circle"
></i>
{% trans "Delete this firewall" %}
</a>
<h2>
{{ object.name }}
</h2>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-5"
>
{% crispy form %}
</div>
</div>
<div
class=
"page-header"
>
<h2>
{% trans "Related rules" %}
</h2>
</div>
<div
class=
"row"
>
<div
class=
"col-sm-12"
>
{% render_table rule_table %}
</div>
</div>
{% endblock %}
circle/network/templates/network/firewall-list.html
0 → 100644
View file @
857316e0
{% extends "network/base.html" %}
{% load render_table from django_tables2 %}
{% load i18n %}
{% load l10n %}
{% load staticfiles %}
{% block title-page %}{% trans "Firewalls" %}{% endblock %}
{% block content %}
<div
class=
"page-header"
>
<a
href=
"{% url "
network
.
firewall_create
"
%}"
class=
"btn btn-success pull-right"
>
<i
class=
"fa fa-plus-circle"
></i>
{% trans "Create a new firewall" %}
</a>
<h1>
{% trans "Firewalls" %}
</h1>
</div>
<div
class=
"table-responsive"
>
{% render_table table %}
</div>
{% endblock %}
circle/network/templates/network/host-edit.html
View file @
857316e0
...
@@ -35,7 +35,7 @@
...
@@ -35,7 +35,7 @@
{% for group in group_rule_list %}
{% for group in group_rule_list %}
<div>
<div>
<h4
id=
"{{ group.pk }}_group_pk"
>
{{ group.name }}
<h4
id=
"{{ group.pk }}_group_pk"
>
{{ group.name }}
<a
href=
"{% url "
network
.
remove_host_group
"
pk=
host_pk
group_pk=
group.pk
%}?
from
=
{{
request
.
path
}}"
>
<a
href=
"{% url "
network
.
remove_host_group
"
pk=
host_pk
group_pk=
group.pk
%}?
next
=
{{
request
.
path
}}"
>
<i
class=
"fa fa-times"
style=
"vertical-align: middle;"
></i></a>
<i
class=
"fa fa-times"
style=
"vertical-align: middle;"
></i></a>
<a
href=
"{% url "
network
.
group
"
group
.
pk
%}"
>
<a
href=
"{% url "
network
.
group
"
group
.
pk
%}"
>
<i
class=
"fa fa-pencil"
style=
"vertical-align: middle;"
></i></a>
<i
class=
"fa fa-pencil"
style=
"vertical-align: middle;"
></i></a>
...
...
circle/network/templates/network/menu.html
View file @
857316e0
...
@@ -22,25 +22,19 @@
...
@@ -22,25 +22,19 @@
{% url "network.switch_port_list" as u %}
{% url "network.switch_port_list" as u %}
{% trans "Switch ports" as t %}
{% trans "Switch ports" as t %}
{% include "network/menu-item.html" with href=u text=t %}
{% include "network/menu-item.html" with href=u text=t %}
{% url "network.firewall_list" as u %}
{% trans "Firewalls" as t %}
{% include "network/menu-item.html" with href=u text=t %}
<li
class=
"dropdown{% if "
groups
"
in
request
.
path
%}
active
{%
endif
%}"
>
<li
class=
"dropdown{% if "
groups
"
in
request
.
path
%}
active
{%
endif
%}"
>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Groups
<b
class=
"caret"
></b></a>
<a
href=
"#"
class=
"dropdown-toggle"
data-toggle=
"dropdown"
>
Groups
<b
class=
"caret"
></b></a>
<ul
class=
"dropdown-menu"
>
<ul
class=
"dropdown-menu"
>
{% url "network.vlan_group_list" as u %}
{% url "network.vlan_group_list" as u %}
{% trans "Vlan groups" as t %}
{% trans "Vlan groups" as t %}
{% include "network/menu-item.html" with href=u text=t %}
{% include "network/menu-item.html" with href=u text=t %}
{% url "network.group_list" as u %}
{% url "network.group_list" as u %}
{% trans "Host groups" as t %}
{% trans "Host groups" as t %}
{% include "network/menu-item.html" with href=u text=t %}
{% include "network/menu-item.html" with href=u text=t %}
</ul>
</ul>
</li>
</li>
{#
<li><a
href=
"/vlans/"
>
{% trans "Vlans" %}
</a></li>
#}
{#
<li><a
href=
"/vlangroups/"
>
{% trans "Vlan groups" %}
</a></li>
#}
{#
<li><a
href=
"/hostgroups/"
>
{% trans "Host groups" %}
</a></li>
#}
{#
<li><a
href=
"/hosts/"
>
{% trans "Hosts" %}
</a></li>
#}
{#
<li><a
href=
"/firewalls/"
>
{% trans "Firewalls" %}
</a></li>
#}
{#
<li><a
href=
"/domains/"
>
{% trans "Domains" %}
</a></li>
#}
{#
<li><a
href=
"/records/"
>
{% trans "DNS records" %}
</a></li>
#}
{#
<li><a
href=
"/blacklist/"
>
{% trans "Blacklist" %}
</a></li>
#}
circle/network/urls.py
View file @
857316e0
...
@@ -16,26 +16,27 @@
...
@@ -16,26 +16,27 @@
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
# with CIRCLE. If not, see <http://www.gnu.org/licenses/>.
from
django.conf.urls
import
patterns
,
url
from
django.conf.urls
import
patterns
,
url
from
.views
import
(
IndexView
,
from
.views
import
(
HostList
,
HostDetail
,
HostCreate
,
HostDelete
,
IndexView
,
VlanList
,
VlanDetail
,
VlanDelete
,
VlanCrea
te
,
HostList
,
HostDetail
,
HostCreate
,
HostDele
te
,
DomainList
,
DomainDetail
,
DomainDelete
,
Domai
nCreate
,
VlanList
,
VlanDetail
,
VlanDelete
,
Vla
nCreate
,
GroupList
,
GroupDetail
,
GroupDelete
,
Group
Create
,
DomainList
,
DomainDetail
,
DomainDelete
,
Domain
Create
,
RecordList
,
RecordDetail
,
RecordCreate
,
RecordDele
te
,
GroupList
,
GroupDetail
,
GroupDelete
,
GroupCrea
te
,
BlacklistList
,
BlacklistDetail
,
Blacklist
Delete
,
RecordList
,
RecordDetail
,
RecordCreate
,
Record
Delete
,
BlacklistCreate
,
BlacklistList
,
BlacklistDetail
,
BlacklistDelete
,
BlacklistCreate
,
RuleList
,
RuleDetail
,
RuleDelete
,
RuleCreate
,
RuleList
,
RuleDetail
,
RuleDelete
,
RuleCreate
,
SwitchPortList
,
SwitchPortDetail
,
SwitchPortCrea
te
,
SwitchPortList
,
SwitchPortDetail
,
SwitchPortCreate
,
SwitchPortDele
te
,
SwitchPortDele
te
,
VlanGroupList
,
VlanGroupDetail
,
VlanGroupDelete
,
VlanGroupCrea
te
,
VlanGroupList
,
VlanGroupDetail
,
VlanGroup
Delete
,
FirewallList
,
FirewallDetail
,
FirewallCreate
,
Firewall
Delete
,
VlanGroupCreate
,
remove_host_group
,
add_host_group
,
remove_host_group
,
add_host_group
,
remove_switch_port_device
,
add_switch_port_device
,
remove_switch_port_device
,
add_switch_port_device
,
VlanAclUpdateView
VlanAclUpdateView
)
)
urlpatterns
=
patterns
(
urlpatterns
=
patterns
(
''
,
''
,
url
(
'^$'
,
IndexView
.
as_view
(),
name
=
'network.index'
),
url
(
'^$'
,
IndexView
.
as_view
(),
name
=
'network.index'
),
# blacklist
url
(
'^blacklist/$'
,
BlacklistList
.
as_view
(),
url
(
'^blacklist/$'
,
BlacklistList
.
as_view
(),
name
=
'network.blacklist_list'
),
name
=
'network.blacklist_list'
),
url
(
'^blacklist/create$'
,
BlacklistCreate
.
as_view
(),
url
(
'^blacklist/create$'
,
BlacklistCreate
.
as_view
(),
...
@@ -44,6 +45,8 @@ urlpatterns = patterns(
...
@@ -44,6 +45,8 @@ urlpatterns = patterns(
name
=
'network.blacklist'
),
name
=
'network.blacklist'
),
url
(
'^blacklist/delete/(?P<pk>
\
d+)/$'
,
BlacklistDelete
.
as_view
(),
url
(
'^blacklist/delete/(?P<pk>
\
d+)/$'
,
BlacklistDelete
.
as_view
(),
name
=
"network.blacklist_delete"
),
name
=
"network.blacklist_delete"
),
# domain
url
(
'^domains/$'
,
DomainList
.
as_view
(),
name
=
'network.domain_list'
),
url
(
'^domains/$'
,
DomainList
.
as_view
(),
name
=
'network.domain_list'
),
url
(
'^domains/create$'
,
DomainCreate
.
as_view
(),
url
(
'^domains/create$'
,
DomainCreate
.
as_view
(),
name
=
'network.domain_create'
),
name
=
'network.domain_create'
),
...
@@ -51,17 +54,33 @@ urlpatterns = patterns(
...
@@ -51,17 +54,33 @@ urlpatterns = patterns(
name
=
'network.domain'
),
name
=
'network.domain'
),
url
(
'^domains/delete/(?P<pk>
\
d+)/$'
,
DomainDelete
.
as_view
(),
url
(
'^domains/delete/(?P<pk>
\
d+)/$'
,
DomainDelete
.
as_view
(),
name
=
"network.domain_delete"
),
name
=
"network.domain_delete"
),
# firewall
url
(
'^firewalls/$'
,
FirewallList
.
as_view
(),
name
=
'network.firewall_list'
),
url
(
'^firewalls/create$'
,
FirewallCreate
.
as_view
(),
name
=
'network.firewall_create'
),
url
(
'^firewalls/(?P<pk>
\
d+)/$'
,
FirewallDetail
.
as_view
(),
name
=
'network.firewall'
),
url
(
'^firewalls/delete/(?P<pk>
\
d+)/$'
,
FirewallDelete
.
as_view
(),
name
=
"network.firewall_delete"
),
# group (host)
url
(
'^groups/$'
,
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/$'
,
GroupList
.
as_view
(),
name
=
'network.group_list'
),
url
(
'^groups/create$'
,
GroupCreate
.
as_view
(),
url
(
'^groups/create$'
,
GroupCreate
.
as_view
(),
name
=
'network.group_create'
),
name
=
'network.group_create'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^groups/(?P<pk>
\
d+)/$'
,
GroupDetail
.
as_view
(),
name
=
'network.group'
),
url
(
'^groups/delete/(?P<pk>
\
d+)/$'
,
GroupDelete
.
as_view
(),
url
(
'^groups/delete/(?P<pk>
\
d+)/$'
,
GroupDelete
.
as_view
(),
name
=
"network.group_delete"
),
name
=
"network.group_delete"
),
# host
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/$'
,
HostList
.
as_view
(),
name
=
'network.host_list'
),
url
(
'^hosts/create$'
,
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/create$'
,
HostCreate
.
as_view
(),
name
=
'network.host_create'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/(?P<pk>
\
d+)/$'
,
HostDetail
.
as_view
(),
name
=
'network.host'
),
url
(
'^hosts/delete/(?P<pk>
\
d+)/$'
,
HostDelete
.
as_view
(),
url
(
'^hosts/delete/(?P<pk>
\
d+)/$'
,
HostDelete
.
as_view
(),
name
=
"network.host_delete"
),
name
=
"network.host_delete"
),
# record
url
(
'^records/$'
,
RecordList
.
as_view
(),
name
=
'network.record_list'
),
url
(
'^records/$'
,
RecordList
.
as_view
(),
name
=
'network.record_list'
),
url
(
'^records/create$'
,
RecordCreate
.
as_view
(),
url
(
'^records/create$'
,
RecordCreate
.
as_view
(),
name
=
'network.record_create'
),
name
=
'network.record_create'
),
...
@@ -69,10 +88,14 @@ urlpatterns = patterns(
...
@@ -69,10 +88,14 @@ urlpatterns = patterns(
name
=
'network.record'
),
name
=
'network.record'
),
url
(
'^records/delete/(?P<pk>
\
d+)/$'
,
RecordDelete
.
as_view
(),
url
(
'^records/delete/(?P<pk>
\
d+)/$'
,
RecordDelete
.
as_view
(),
name
=
"network.record_delete"
),
name
=
"network.record_delete"
),
# rule
url
(
'^rules/$'
,
RuleList
.
as_view
(),
name
=
'network.rule_list'
),
url
(
'^rules/$'
,
RuleList
.
as_view
(),
name
=
'network.rule_list'
),
url
(
'^rules/create$'
,
RuleCreate
.
as_view
(),
name
=
'network.rule_create'
),
url
(
'^rules/create$'
,
RuleCreate
.
as_view
(),
name
=
'network.rule_create'
),
url
(
'^rules/(?P<pk>
\
d+)/$'
,
RuleDetail
.
as_view
(),
url
(
'^rules/(?P<pk>
\
d+)/$'
,
RuleDetail
.
as_view
(),
name
=
'network.rule'
),
name
=
'network.rule'
),
# switchport
url
(
'^switchports/$'
,
SwitchPortList
.
as_view
(),
url
(
'^switchports/$'
,
SwitchPortList
.
as_view
(),
name
=
'network.switch_port_list'
),
name
=
'network.switch_port_list'
),
url
(
'^switchports/create$'
,
SwitchPortCreate
.
as_view
(),
url
(
'^switchports/create$'
,
SwitchPortCreate
.
as_view
(),
...
@@ -81,6 +104,8 @@ urlpatterns = patterns(
...
@@ -81,6 +104,8 @@ urlpatterns = patterns(
name
=
'network.switch_port'
),
name
=
'network.switch_port'
),
url
(
'^switchports/delete/(?P<pk>
\
d+)/$'
,
SwitchPortDelete
.
as_view
(),
url
(
'^switchports/delete/(?P<pk>
\
d+)/$'
,
SwitchPortDelete
.
as_view
(),
name
=
"network.switch_port_delete"
),
name
=
"network.switch_port_delete"
),
# vlan
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/$'
,
VlanList
.
as_view
(),
name
=
'network.vlan_list'
),
url
(
'^vlans/create$'
,
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/create$'
,
VlanCreate
.
as_view
(),
name
=
'network.vlan_create'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
url
(
'^vlans/(?P<vid>
\
d+)/$'
,
VlanDetail
.
as_view
(),
name
=
'network.vlan'
),
...
@@ -88,6 +113,8 @@ urlpatterns = patterns(
...
@@ -88,6 +113,8 @@ urlpatterns = patterns(
name
=
'network.vlan-acl'
),
name
=
'network.vlan-acl'
),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
VlanDelete
.
as_view
(),
url
(
'^vlans/delete/(?P<vid>
\
d+)/$'
,
VlanDelete
.
as_view
(),
name
=
"network.vlan_delete"
),
name
=
"network.vlan_delete"
),
# vlangroup
url
(
'^vlangroups/$'
,
VlanGroupList
.
as_view
(),
url
(
'^vlangroups/$'
,
VlanGroupList
.
as_view
(),
name
=
'network.vlan_group_list'
),
name
=
'network.vlan_group_list'
),
url
(
'^vlangroups/create$'
,
VlanGroupCreate
.
as_view
(),
url
(
'^vlangroups/create$'
,
VlanGroupCreate
.
as_view
(),
...
...
circle/network/views.py
View file @
857316e0
...
@@ -28,15 +28,20 @@ from django.db.models import Q
...
@@ -28,15 +28,20 @@ from django.db.models import Q
from
django_tables2
import
SingleTableView
from
django_tables2
import
SingleTableView
from
firewall.models
import
(
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
from
firewall.models
import
(
Rule
,
VlanGroup
,
SwitchPort
,
EthernetDevice
)
Host
,
Vlan
,
Domain
,
Group
,
Record
,
BlacklistItem
,
Rule
,
VlanGroup
,
SwitchPort
,
EthernetDevice
,
Firewall
)
from
vm.models
import
Interface
from
vm.models
import
Interface
from
.tables
import
(
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
,
from
.tables
import
(
GroupTable
,
RecordTable
,
BlacklistItemTable
,
RuleTable
,
HostTable
,
VlanTable
,
SmallHostTable
,
DomainTable
,
GroupTable
,
VlanGroupTable
,
SmallRuleTable
,
SmallGroupRuleTable
,
RecordTable
,
BlacklistItemTable
,
RuleTable
,
VlanGroupTable
,
SmallRecordTable
,
SwitchPortTable
,
SmallDhcpTable
,
)
SmallRuleTable
,
SmallGroupRuleTable
,
SmallRecordTable
,
SwitchPortTable
,
from
.forms
import
(
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
,
RecordForm
,
SmallDhcpTable
,
FirewallTable
,
FirewallRuleTable
,
BlacklistItemForm
,
RuleForm
,
VlanGroupForm
,
SwitchPortForm
)
)
from
.forms
import
(
HostForm
,
VlanForm
,
DomainForm
,
GroupForm
,
RecordForm
,
BlacklistItemForm
,
RuleForm
,
VlanGroupForm
,
SwitchPortForm
,
FirewallForm
)
from
django.contrib
import
messages
from
django.contrib
import
messages
from
django.contrib.messages.views
import
SuccessMessageMixin
from
django.contrib.messages.views
import
SuccessMessageMixin
...
@@ -287,6 +292,53 @@ class DomainDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
...
@@ -287,6 +292,53 @@ class DomainDelete(LoginRequiredMixin, SuperuserRequiredMixin, DeleteView):
return
context
return
context
class
FirewallList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
model
=
Firewall
table_class
=
FirewallTable
template_name
=
"network/firewall-list.html"
table_pagination
=
False
class
FirewallDetail
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
UpdateView
):
model
=
Firewall
template_name
=
"network/firewall-edit.html"
form_class
=
FirewallForm
success_message
=
_
(
u'Succesfully modified firewall.'
)
def
get_success_url
(
self
):
if
'pk'
in
self
.
kwargs
:
return
reverse_lazy
(
'network.firewall'
,
kwargs
=
self
.
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
FirewallDetail
,
self
)
.
get_context_data
(
**
kwargs
)
rules
=
Rule
.
objects
.
filter
(
firewall
=
self
.
object
)
context
[
'rule_table'
]
=
FirewallRuleTable
(
rules
,
request
=
self
.
request
)
return
context
class
FirewallCreate
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SuccessMessageMixin
,
CreateView
):
model
=
Firewall
template_name
=
"network/firewall-create.html"
form_class
=
FirewallForm
success_message
=
_
(
u'Successfully created firewall.'
)
class
FirewallDelete
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
DeleteView
):
model
=
Firewall
template_name
=
"network/confirm/base_delete.html"
def
get_success_url
(
self
):
next
=
self
.
request
.
POST
.
get
(
'next'
)
if
next
:
return
next
else
:
return
reverse_lazy
(
'network.firewall_list'
)
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
class
GroupList
(
LoginRequiredMixin
,
SuperuserRequiredMixin
,
SingleTableView
):
model
=
Group
model
=
Group
table_class
=
GroupTable
table_class
=
GroupTable
...
...
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