Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b86b3414
authored
May 09, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: pep8 for president!
parent
cc3c83ac
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
3 deletions
+19
-3
firewall_gui/views.py
+19
-3
No files found.
firewall_gui/views.py
View file @
b86b3414
...
...
@@ -5,9 +5,11 @@ from django.contrib.auth.models import User
from
firewall.fw
import
*
from
firewall.models
import
*
def
index
(
request
):
return
render
(
request
,
'firewall/index.html'
)
def
list_rules
(
request
):
rules
=
[{
'id'
:
rule
.
id
,
...
...
@@ -51,13 +53,14 @@ def list_rules(request):
}
for
rule
in
Rule
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
rules
),
content_type
=
'application/json'
)
def
list_hosts
(
request
):
hosts
=
[{
'id'
:
host
.
id
,
'reverse'
:
host
.
reverse
,
'name'
:
host
.
hostname
,
'ipv4'
:
host
.
ipv4
,
'pub'
:
'foo'
,
#
ide kell valami!
'pub'
:
'foo'
,
#
ide kell valami!
'shared_ip'
:
host
.
shared_ip
,
'description'
:
host
.
description
,
'comment'
:
host
.
comment
,
...
...
@@ -79,6 +82,7 @@ def list_hosts(request):
}
for
host
in
Host
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
hosts
),
content_type
=
'application/json'
)
def
list_vlans
(
request
):
vlans
=
[{
'id'
:
vlan
.
id
,
...
...
@@ -95,6 +99,7 @@ def list_vlans(request):
}
for
vlan
in
Vlan
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
vlans
),
content_type
=
'application/json'
)
def
list_vlangroups
(
request
):
vlangroups
=
[{
'id'
:
group
.
id
,
...
...
@@ -113,6 +118,7 @@ def list_vlangroups(request):
}
for
group
in
VlanGroup
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
vlangroups
),
content_type
=
'application/json'
)
def
list_hostgroups
(
request
):
groups
=
[{
'id'
:
group
.
id
,
...
...
@@ -127,6 +133,7 @@ def list_hostgroups(request):
}
for
group
in
Group
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
groups
),
content_type
=
'application/json'
)
def
list_firewalls
(
request
):
firewalls
=
[{
'id'
:
firewall
.
id
,
...
...
@@ -134,6 +141,7 @@ def list_firewalls(request):
}
for
firewall
in
Firewall
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
firewalls
),
content_type
=
'application/json'
)
def
list_domains
(
request
):
domains
=
[{
'id'
:
domain
.
id
,
...
...
@@ -149,6 +157,7 @@ def list_domains(request):
}
for
domain
in
Domain
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
domains
),
content_type
=
'application/json'
)
def
list_records
(
request
):
records
=
[{
'id'
:
record
.
id
,
...
...
@@ -174,6 +183,7 @@ def list_records(request):
}
for
record
in
Record
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
records
),
content_type
=
'application/json'
)
def
list_blacklists
(
request
):
blacklists
=
[{
'id'
:
blacklist
.
id
,
...
...
@@ -190,6 +200,7 @@ def list_blacklists(request):
}
for
blacklist
in
Blacklist
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
blacklists
),
content_type
=
'application/json'
)
def
show_rule
(
request
,
id
):
rule
=
get_object_or_404
(
Rule
,
id
=
id
)
rule
=
{
...
...
@@ -244,6 +255,7 @@ def show_rule(request, id):
}
return
HttpResponse
(
json
.
dumps
(
rule
),
content_type
=
'application/json'
)
def
show_host
(
request
,
id
):
host
=
get_object_or_404
(
Host
,
id
=
id
)
host
=
{
...
...
@@ -253,7 +265,7 @@ def show_host(request, id):
'mac'
:
host
.
mac
,
'ipv4'
:
host
.
ipv4
,
'ipv6'
:
host
.
ipv6
,
'pub_ipv4'
:
host
.
pub_ipv4
,
'pub_ipv4'
:
host
.
pub_ipv4
,
'shared_ip'
:
host
.
shared_ip
,
'description'
:
host
.
description
,
'comment'
:
host
.
comment
,
...
...
@@ -286,6 +298,7 @@ def show_host(request, id):
}
return
HttpResponse
(
json
.
dumps
(
host
),
content_type
=
'application/json'
)
def
show_vlan
(
request
,
id
):
vlan
=
get_object_or_404
(
Vlan
,
id
=
id
)
vlan
=
{
...
...
@@ -324,6 +337,7 @@ def show_vlan(request, id):
}
return
HttpResponse
(
json
.
dumps
(
vlan
),
content_type
=
'application/json'
)
def
show_vlangroup
(
request
,
id
):
group
=
get_object_or_404
(
VlanGroup
,
id
=
id
)
group
=
{
...
...
@@ -354,6 +368,7 @@ def show_vlangroup(request, id):
}
return
HttpResponse
(
json
.
dumps
(
group
),
content_type
=
'application/json'
)
def
show_hostgroup
(
request
,
id
):
group
=
get_object_or_404
(
Group
,
id
=
id
)
group
=
{
...
...
@@ -446,7 +461,8 @@ def save_rule(request):
rule
.
host
=
get_object_or_404
(
Host
,
hostname
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'host'
else
None
rule
.
hostgroup
=
get_object_or_404
(
Group
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'hostgroup'
else
None
rule
.
vlan
=
get_object_or_404
(
Vlan
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'vlan'
else
None
rule
.
vlangroup
=
get_object_or_404
(
VlanGroup
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'vlangroup'
else
None
rule
.
vlangroup
=
get_object_or_404
(
VlanGroup
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'vlangroup'
else
None
rule
.
firewall
=
get_object_or_404
(
Firewall
,
name
=
data
[
'target'
][
'name'
])
if
data
[
'target'
][
'type'
]
==
'firewall'
else
None
rule
.
foreign_network
=
get_object_or_404
(
VlanGroup
,
name
=
data
[
'foreignNetwork'
][
'name'
])
rule
.
save
()
...
...
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