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
e01052c4
authored
May 28, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall_gui: save new vlans
parent
bc2a90c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
41 deletions
+66
-41
cloud/urls.py
+1
-1
firewall_gui/views.py
+65
-40
No files found.
cloud/urls.py
View file @
e01052c4
...
@@ -119,7 +119,7 @@ urlpatterns = patterns('',
...
@@ -119,7 +119,7 @@ urlpatterns = patterns('',
url
(
r'^firewall/rules/new/$'
,
'firewall_gui.views.show_rule'
),
url
(
r'^firewall/rules/new/$'
,
'firewall_gui.views.show_rule'
),
url
(
r'^firewall/hosts/new/$'
,
'firewall_gui.views.show_host'
),
url
(
r'^firewall/hosts/new/$'
,
'firewall_gui.views.show_host'
),
# url(r'^firewall/vlans/save/$', 'firewall_gui.views.save
_vlan'),
url
(
r'^firewall/vlans/new/$'
,
'firewall_gui.views.show
_vlan'
),
# url(r'^firewall/vlangroups/save/$', 'firewall_gui.views.save_vlangroup'),
# url(r'^firewall/vlangroups/save/$', 'firewall_gui.views.save_vlangroup'),
# url(r'^firewall/hostgroups/save/$', 'firewall_gui.views.save_hostgroup'),
# url(r'^firewall/hostgroups/save/$', 'firewall_gui.views.save_hostgroup'),
# url(r'^firewall/domains/save/$', 'firewall_gui.views.save_domain'),
# url(r'^firewall/domains/save/$', 'firewall_gui.views.save_domain'),
...
...
firewall_gui/views.py
View file @
e01052c4
...
@@ -320,46 +320,71 @@ def show_host(request, id=None):
...
@@ -320,46 +320,71 @@ def show_host(request, id=None):
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
=
None
):
vlan
=
get_object_or_404
(
Vlan
,
id
=
id
)
try
:
vlan
=
{
vlan
=
Vlan
.
objects
.
get
(
id
=
id
)
'id'
:
vlan
.
id
,
vlan
=
{
'vid'
:
vlan
.
vid
,
'name'
:
vlan
.
name
,
'ipv4'
:
vlan
.
ipv4
+
'/'
+
str
(
vlan
.
prefix4
),
'ipv6'
:
vlan
.
ipv6
+
'/'
+
str
(
vlan
.
prefix6
),
'nat'
:
vlan
.
snat_ip
,
'description'
:
vlan
.
description
,
'comment'
:
vlan
.
comment
,
'reverse_domain'
:
vlan
.
reverse_domain
,
'dhcp_pool'
:
vlan
.
dhcp_pool
,
'interface'
:
vlan
.
interface
,
'created_at'
:
vlan
.
created_at
.
isoformat
(),
'modified_at'
:
vlan
.
modified_at
.
isoformat
(),
'owner'
:
{
'name'
:
str
(
vlan
.
owner
),
'id'
:
vlan
.
owner
.
id
}
if
vlan
.
owner
else
None
,
'domain'
:
{
'id'
:
vlan
.
domain
.
id
,
'name'
:
vlan
.
domain
.
name
,
},
'rules'
:
[{
'id'
:
rule
.
id
,
'direction'
:
rule
.
get_direction_display
(),
'proto'
:
rule
.
proto
,
'owner'
:
{
'id'
:
rule
.
owner
.
id
,
'name'
:
str
(
rule
.
owner
),
},
'accept'
:
rule
.
accept
,
'nat'
:
rule
.
nat
}
for
rule
in
vlan
.
rules
.
all
()],
'vlans'
:
[{
'id'
:
vlan
.
id
,
'id'
:
vlan
.
id
,
'vid'
:
vlan
.
vid
,
'name'
:
vlan
.
name
,
'name'
:
vlan
.
name
,
}
for
vlan
in
vlan
.
snat_to
.
all
()]
'ipv4'
:
vlan
.
ipv4
+
'/'
+
str
(
vlan
.
prefix4
),
}
'ipv6'
:
vlan
.
ipv6
+
'/'
+
str
(
vlan
.
prefix6
),
'nat'
:
vlan
.
snat_ip
,
'description'
:
vlan
.
description
,
'comment'
:
vlan
.
comment
,
'reverse_domain'
:
vlan
.
reverse_domain
,
'dhcp_pool'
:
vlan
.
dhcp_pool
,
'interface'
:
vlan
.
interface
,
'created_at'
:
vlan
.
created_at
.
isoformat
(),
'modified_at'
:
vlan
.
modified_at
.
isoformat
(),
'owner'
:
{
'name'
:
str
(
vlan
.
owner
),
'id'
:
vlan
.
owner
.
id
}
if
vlan
.
owner
else
None
,
'domain'
:
{
'id'
:
vlan
.
domain
.
id
,
'name'
:
vlan
.
domain
.
name
,
},
'rules'
:
[{
'id'
:
rule
.
id
,
'direction'
:
rule
.
get_direction_display
(),
'proto'
:
rule
.
proto
,
'owner'
:
{
'id'
:
rule
.
owner
.
id
,
'name'
:
str
(
rule
.
owner
),
},
'accept'
:
rule
.
accept
,
'nat'
:
rule
.
nat
}
for
rule
in
vlan
.
rules
.
all
()],
'vlans'
:
[{
'id'
:
vlan
.
id
,
'name'
:
vlan
.
name
,
}
for
vlan
in
vlan
.
snat_to
.
all
()]
}
except
:
vlan
=
{
'id'
:
None
,
'vid'
:
None
,
'name'
:
None
,
'ipv4'
:
None
,
'ipv6'
:
None
,
'nat'
:
''
,
'description'
:
''
,
'comment'
:
''
,
'reverse_domain'
:
''
,
'dhcp_pool'
:
''
,
'interface'
:
''
,
'created_at'
:
None
,
'modified_at'
:
None
,
'owner'
:
{
'name'
:
None
,
},
'domain'
:
{
'name'
:
None
,
},
'rules'
:
[],
'vlans'
:
[]
}
return
HttpResponse
(
json
.
dumps
(
vlan
),
content_type
=
'application/json'
)
return
HttpResponse
(
json
.
dumps
(
vlan
),
content_type
=
'application/json'
)
...
@@ -589,9 +614,9 @@ def save_vlan(request):
...
@@ -589,9 +614,9 @@ def save_vlan(request):
errors
=
{}
errors
=
{}
vlan
.
vid
=
data
[
'vid'
]
vlan
.
vid
=
data
[
'vid'
]
vlan
.
name
=
data
[
'name'
]
vlan
.
name
=
data
[
'name'
]
vlan
.
ipv4
=
data
[
'ipv4'
]
.
split
(
'/'
)[
0
]
vlan
.
ipv4
=
vlan
.
net4
=
data
[
'ipv4'
]
.
split
(
'/'
)[
0
]
vlan
.
prefix4
=
data
[
'ipv4'
]
.
split
(
'/'
)[
1
]
vlan
.
prefix4
=
data
[
'ipv4'
]
.
split
(
'/'
)[
1
]
vlan
.
ipv6
=
data
[
'ipv6'
]
.
split
(
'/'
)[
0
]
vlan
.
ipv6
=
vlan
.
net6
=
data
[
'ipv6'
]
.
split
(
'/'
)[
0
]
vlan
.
prefix6
=
data
[
'ipv6'
]
.
split
(
'/'
)[
1
]
vlan
.
prefix6
=
data
[
'ipv6'
]
.
split
(
'/'
)[
1
]
vlan
.
snat_ip
=
data
[
'nat'
]
vlan
.
snat_ip
=
data
[
'nat'
]
vlan
.
description
=
data
[
'description'
]
vlan
.
description
=
data
[
'description'
]
...
...
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