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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
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
...
@@ -5,9 +5,11 @@ from django.contrib.auth.models import User
from
firewall.fw
import
*
from
firewall.fw
import
*
from
firewall.models
import
*
from
firewall.models
import
*
def
index
(
request
):
def
index
(
request
):
return
render
(
request
,
'firewall/index.html'
)
return
render
(
request
,
'firewall/index.html'
)
def
list_rules
(
request
):
def
list_rules
(
request
):
rules
=
[{
rules
=
[{
'id'
:
rule
.
id
,
'id'
:
rule
.
id
,
...
@@ -51,13 +53,14 @@ def list_rules(request):
...
@@ -51,13 +53,14 @@ def list_rules(request):
}
for
rule
in
Rule
.
objects
.
all
()]
}
for
rule
in
Rule
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
rules
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
rules
),
content_type
=
'application/json'
)
def
list_hosts
(
request
):
def
list_hosts
(
request
):
hosts
=
[{
hosts
=
[{
'id'
:
host
.
id
,
'id'
:
host
.
id
,
'reverse'
:
host
.
reverse
,
'reverse'
:
host
.
reverse
,
'name'
:
host
.
hostname
,
'name'
:
host
.
hostname
,
'ipv4'
:
host
.
ipv4
,
'ipv4'
:
host
.
ipv4
,
'pub'
:
'foo'
,
#
ide kell valami!
'pub'
:
'foo'
,
#
ide kell valami!
'shared_ip'
:
host
.
shared_ip
,
'shared_ip'
:
host
.
shared_ip
,
'description'
:
host
.
description
,
'description'
:
host
.
description
,
'comment'
:
host
.
comment
,
'comment'
:
host
.
comment
,
...
@@ -79,6 +82,7 @@ def list_hosts(request):
...
@@ -79,6 +82,7 @@ def list_hosts(request):
}
for
host
in
Host
.
objects
.
all
()]
}
for
host
in
Host
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
hosts
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
hosts
),
content_type
=
'application/json'
)
def
list_vlans
(
request
):
def
list_vlans
(
request
):
vlans
=
[{
vlans
=
[{
'id'
:
vlan
.
id
,
'id'
:
vlan
.
id
,
...
@@ -95,6 +99,7 @@ def list_vlans(request):
...
@@ -95,6 +99,7 @@ def list_vlans(request):
}
for
vlan
in
Vlan
.
objects
.
all
()]
}
for
vlan
in
Vlan
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
vlans
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
vlans
),
content_type
=
'application/json'
)
def
list_vlangroups
(
request
):
def
list_vlangroups
(
request
):
vlangroups
=
[{
vlangroups
=
[{
'id'
:
group
.
id
,
'id'
:
group
.
id
,
...
@@ -113,6 +118,7 @@ def list_vlangroups(request):
...
@@ -113,6 +118,7 @@ def list_vlangroups(request):
}
for
group
in
VlanGroup
.
objects
.
all
()]
}
for
group
in
VlanGroup
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
vlangroups
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
vlangroups
),
content_type
=
'application/json'
)
def
list_hostgroups
(
request
):
def
list_hostgroups
(
request
):
groups
=
[{
groups
=
[{
'id'
:
group
.
id
,
'id'
:
group
.
id
,
...
@@ -127,6 +133,7 @@ def list_hostgroups(request):
...
@@ -127,6 +133,7 @@ def list_hostgroups(request):
}
for
group
in
Group
.
objects
.
all
()]
}
for
group
in
Group
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
groups
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
groups
),
content_type
=
'application/json'
)
def
list_firewalls
(
request
):
def
list_firewalls
(
request
):
firewalls
=
[{
firewalls
=
[{
'id'
:
firewall
.
id
,
'id'
:
firewall
.
id
,
...
@@ -134,6 +141,7 @@ def list_firewalls(request):
...
@@ -134,6 +141,7 @@ def list_firewalls(request):
}
for
firewall
in
Firewall
.
objects
.
all
()]
}
for
firewall
in
Firewall
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
firewalls
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
firewalls
),
content_type
=
'application/json'
)
def
list_domains
(
request
):
def
list_domains
(
request
):
domains
=
[{
domains
=
[{
'id'
:
domain
.
id
,
'id'
:
domain
.
id
,
...
@@ -149,6 +157,7 @@ def list_domains(request):
...
@@ -149,6 +157,7 @@ def list_domains(request):
}
for
domain
in
Domain
.
objects
.
all
()]
}
for
domain
in
Domain
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
domains
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
domains
),
content_type
=
'application/json'
)
def
list_records
(
request
):
def
list_records
(
request
):
records
=
[{
records
=
[{
'id'
:
record
.
id
,
'id'
:
record
.
id
,
...
@@ -174,6 +183,7 @@ def list_records(request):
...
@@ -174,6 +183,7 @@ def list_records(request):
}
for
record
in
Record
.
objects
.
all
()]
}
for
record
in
Record
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
records
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
records
),
content_type
=
'application/json'
)
def
list_blacklists
(
request
):
def
list_blacklists
(
request
):
blacklists
=
[{
blacklists
=
[{
'id'
:
blacklist
.
id
,
'id'
:
blacklist
.
id
,
...
@@ -190,6 +200,7 @@ def list_blacklists(request):
...
@@ -190,6 +200,7 @@ def list_blacklists(request):
}
for
blacklist
in
Blacklist
.
objects
.
all
()]
}
for
blacklist
in
Blacklist
.
objects
.
all
()]
return
HttpResponse
(
json
.
dumps
(
blacklists
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
blacklists
),
content_type
=
'application/json'
)
def
show_rule
(
request
,
id
):
def
show_rule
(
request
,
id
):
rule
=
get_object_or_404
(
Rule
,
id
=
id
)
rule
=
get_object_or_404
(
Rule
,
id
=
id
)
rule
=
{
rule
=
{
...
@@ -244,6 +255,7 @@ def show_rule(request, id):
...
@@ -244,6 +255,7 @@ def show_rule(request, id):
}
}
return
HttpResponse
(
json
.
dumps
(
rule
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
rule
),
content_type
=
'application/json'
)
def
show_host
(
request
,
id
):
def
show_host
(
request
,
id
):
host
=
get_object_or_404
(
Host
,
id
=
id
)
host
=
get_object_or_404
(
Host
,
id
=
id
)
host
=
{
host
=
{
...
@@ -253,7 +265,7 @@ def show_host(request, id):
...
@@ -253,7 +265,7 @@ def show_host(request, id):
'mac'
:
host
.
mac
,
'mac'
:
host
.
mac
,
'ipv4'
:
host
.
ipv4
,
'ipv4'
:
host
.
ipv4
,
'ipv6'
:
host
.
ipv6
,
'ipv6'
:
host
.
ipv6
,
'pub_ipv4'
:
host
.
pub_ipv4
,
'pub_ipv4'
:
host
.
pub_ipv4
,
'shared_ip'
:
host
.
shared_ip
,
'shared_ip'
:
host
.
shared_ip
,
'description'
:
host
.
description
,
'description'
:
host
.
description
,
'comment'
:
host
.
comment
,
'comment'
:
host
.
comment
,
...
@@ -286,6 +298,7 @@ def show_host(request, id):
...
@@ -286,6 +298,7 @@ def show_host(request, id):
}
}
return
HttpResponse
(
json
.
dumps
(
host
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
host
),
content_type
=
'application/json'
)
def
show_vlan
(
request
,
id
):
def
show_vlan
(
request
,
id
):
vlan
=
get_object_or_404
(
Vlan
,
id
=
id
)
vlan
=
get_object_or_404
(
Vlan
,
id
=
id
)
vlan
=
{
vlan
=
{
...
@@ -324,6 +337,7 @@ def show_vlan(request, id):
...
@@ -324,6 +337,7 @@ def show_vlan(request, id):
}
}
return
HttpResponse
(
json
.
dumps
(
vlan
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
vlan
),
content_type
=
'application/json'
)
def
show_vlangroup
(
request
,
id
):
def
show_vlangroup
(
request
,
id
):
group
=
get_object_or_404
(
VlanGroup
,
id
=
id
)
group
=
get_object_or_404
(
VlanGroup
,
id
=
id
)
group
=
{
group
=
{
...
@@ -354,6 +368,7 @@ def show_vlangroup(request, id):
...
@@ -354,6 +368,7 @@ def show_vlangroup(request, id):
}
}
return
HttpResponse
(
json
.
dumps
(
group
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
group
),
content_type
=
'application/json'
)
def
show_hostgroup
(
request
,
id
):
def
show_hostgroup
(
request
,
id
):
group
=
get_object_or_404
(
Group
,
id
=
id
)
group
=
get_object_or_404
(
Group
,
id
=
id
)
group
=
{
group
=
{
...
@@ -446,7 +461,8 @@ def save_rule(request):
...
@@ -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
.
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
.
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
.
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
.
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
.
foreign_network
=
get_object_or_404
(
VlanGroup
,
name
=
data
[
'foreignNetwork'
][
'name'
])
rule
.
save
()
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