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
458553dc
authored
Jan 30, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enforszolgatom a gájdlájnokat
parent
83fcd17c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
35 deletions
+59
-35
cloud/settings.py
+10
-6
cloud/urls.py
+25
-18
firewall/admin.py
+12
-5
firewall/fields.py
+12
-6
No files found.
cloud/settings.py
View file @
458553dc
...
@@ -12,12 +12,16 @@ MANAGERS = ADMINS
...
@@ -12,12 +12,16 @@ MANAGERS = ADMINS
DATABASES
=
{
DATABASES
=
{
'default'
:
{
'default'
:
{
'ENGINE'
:
'django.db.backends.mysql'
,
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'ENGINE'
:
'django.db.backends.mysql'
,
# Add 'postgresql_psycopg2',
'NAME'
:
'webadmin'
,
# Or path to database file if using sqlite3.
# 'mysql', 'sqlite3' or 'oracle'.
'USER'
:
'webadmin'
,
# Not used with sqlite3.
'NAME'
:
'webadmin'
,
# Or path to database file if
'PASSWORD'
:
'asjklddfjklqjf'
,
# Not used with sqlite3.
# using sqlite3.
'HOST'
:
''
,
# Set to empty string for localhost. Not used with sqlite3.
'USER'
:
'webadmin'
,
# Not used with sqlite3.
'PORT'
:
''
,
# Set to empty string for default. Not used with sqlite3.
'PASSWORD'
:
'asjklddfjklqjf'
,
# Not used with sqlite3.
'HOST'
:
''
,
# Set to empty string for localhost.
# Not used with sqlite3.
'PORT'
:
''
,
# Set to empty string for default.
# Not used with sqlite3.
}
}
}
}
...
...
cloud/urls.py
View file @
458553dc
...
@@ -8,22 +8,29 @@ import firewall.views
...
@@ -8,22 +8,29 @@ import firewall.views
#import store.views
#import store.views
urlpatterns
=
patterns
(
''
,
urlpatterns
=
patterns
(
''
,
url
(
r'^admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r'^admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^$'
,
'one.views.home'
,
name
=
'home'
),
url
(
r'^$'
,
'one.views.home'
,
name
=
'home'
),
url
(
r'^login/$'
,
'school.views.login'
,
name
=
'login'
),
url
(
r'^login/$'
,
'school.views.login'
,
name
=
'login'
),
url
(
r'^logout/$'
,
'school.views.logout'
,
name
=
'logout'
),
url
(
r'^logout/$'
,
'school.views.logout'
,
name
=
'logout'
),
url
(
r'^vm/new/(?P<template>\d+)/$'
,
'one.views.vm_new'
,
name
=
'vm_new'
),
url
(
r'^vm/new/(?P<template>\d+)/$'
,
'one.views.vm_new'
,
name
=
'vm_new'
),
url
(
r'^vm/show/(?P<iid>\d+)/$'
,
'one.views.vm_show'
,
name
=
'vm_show'
),
url
(
r'^vm/show/(?P<iid>\d+)/$'
,
'one.views.vm_show'
,
name
=
'vm_show'
),
url
(
r'^vm/delete/(?P<iid>\d+)/$'
,
'one.views.vm_delete'
,
name
=
'vm_delete'
),
url
(
r'^vm/delete/(?P<iid>\d+)/$'
,
'one.views.vm_delete'
,
url
(
r'^vm/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
name
=
'vm_delete'
),
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
name
=
'vm_resume'
),
url
(
r'^vm/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
name
=
'vm_power_off'
),
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
name
=
'vm_restart'
),
name
=
'vm_resume'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
name
=
'vm_port_add'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
url
(
r'^vm/port_del/(?P<iid>\d+)/(?P<proto>tcp|udp)/(?P<public>\d+)/$'
,
'one.views.vm_port_del'
,
name
=
'vm_port_del'
),
name
=
'vm_power_off'
),
url
(
r'^reload/$'
,
'firewall.views.reload_firewall'
,
name
=
'reload_firewall'
),
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
url
(
r'^fwapi/$'
,
'firewall.views.firewall_api'
,
name
=
'firewall_api'
),
name
=
'vm_restart'
),
url
(
r'^store/$'
,
'store.views.index'
,
name
=
'store_index'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
url
(
r'^store/top/$'
,
'store.views.toplist'
,
name
=
'store_top'
),
name
=
'vm_port_add'
),
url
(
r'^vm/port_del/(?P<iid>\d+)/(?P<proto>tcp|udp)/(?P<public>\d+)/$'
,
'one.views.vm_port_del'
,
name
=
'vm_port_del'
),
url
(
r'^reload/$'
,
'firewall.views.reload_firewall'
,
name
=
'reload_firewall'
),
url
(
r'^fwapi/$'
,
'firewall.views.firewall_api'
,
name
=
'firewall_api'
),
url
(
r'^store/$'
,
'store.views.index'
,
name
=
'store_index'
),
url
(
r'^store/top/$'
,
'store.views.toplist'
,
name
=
'store_top'
),
)
)
firewall/admin.py
View file @
458553dc
...
@@ -7,7 +7,9 @@ class AliasInline(contrib.admin.TabularInline):
...
@@ -7,7 +7,9 @@ class AliasInline(contrib.admin.TabularInline):
model
=
Alias
model
=
Alias
class
HostAdmin
(
admin
.
ModelAdmin
):
class
HostAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'hostname'
,
'vlan'
,
'ipv4'
,
'ipv6'
,
'pub_ipv4'
,
'mac'
,
'shared_ip'
,
'owner'
,
'groups_l'
,
'rules_l'
,
'description'
,
'reverse'
)
list_display
=
(
'hostname'
,
'vlan'
,
'ipv4'
,
'ipv6'
,
'pub_ipv4'
,
'mac'
,
'shared_ip'
,
'owner'
,
'groups_l'
,
'rules_l'
,
'description'
,
'reverse'
)
ordering
=
(
'hostname'
,
)
ordering
=
(
'hostname'
,
)
list_filter
=
(
'owner'
,
'vlan'
,
'groups'
)
list_filter
=
(
'owner'
,
'vlan'
,
'groups'
)
search_fields
=
(
'hostname'
,
'description'
,
'ipv4'
,
'ipv6'
,
'mac'
)
search_fields
=
(
'hostname'
,
'description'
,
'ipv4'
,
'ipv6'
,
'mac'
)
...
@@ -16,16 +18,21 @@ class HostAdmin(admin.ModelAdmin):
...
@@ -16,16 +18,21 @@ class HostAdmin(admin.ModelAdmin):
class
HostInline
(
contrib
.
admin
.
TabularInline
):
class
HostInline
(
contrib
.
admin
.
TabularInline
):
model
=
Host
model
=
Host
fields
=
(
'hostname'
,
'ipv4'
,
'ipv6'
,
'pub_ipv4'
,
'mac'
,
'shared_ip'
,
'owner'
,
'reverse'
)
fields
=
(
'hostname'
,
'ipv4'
,
'ipv6'
,
'pub_ipv4'
,
'mac'
,
'shared_ip'
,
'owner'
,
'reverse'
)
class
VlanAdmin
(
admin
.
ModelAdmin
):
class
VlanAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'vid'
,
'name'
,
'rules_l'
,
'ipv4'
,
'net_ipv4'
,
'ipv6'
,
'net_ipv6'
,
'description'
,
'domain'
,
'snat_ip'
,
'snat_to_l'
)
list_display
=
(
'vid'
,
'name'
,
'rules_l'
,
'ipv4'
,
'net_ipv4'
,
'ipv6'
,
'net_ipv6'
,
'description'
,
'domain'
,
'snat_ip'
,
'snat_to_l'
)
ordering
=
(
'vid'
,
)
ordering
=
(
'vid'
,
)
inlines
=
(
HostInline
,
)
inlines
=
(
HostInline
,
)
class
RuleAdmin
(
admin
.
ModelAdmin
):
class
RuleAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'r_type'
,
'color_desc'
,
'description'
,
'vlan_l'
,
'owner'
,
'extra'
,
'direction'
,
'accept'
,
'proto'
,
'sport'
,
'dport'
,
'nat'
,
'nat_dport'
)
list_display
=
(
'r_type'
,
'color_desc'
,
'description'
,
'vlan_l'
,
list_filter
=
(
'r_type'
,
'vlan'
,
'owner'
,
'direction'
,
'accept'
,
'proto'
,
'nat'
)
'owner'
,
'extra'
,
'direction'
,
'accept'
,
'proto'
,
'sport'
,
'dport'
,
'nat'
,
'nat_dport'
)
list_filter
=
(
'r_type'
,
'vlan'
,
'owner'
,
'direction'
,
'accept'
,
'proto'
,
'nat'
)
class
AliasAdmin
(
admin
.
ModelAdmin
):
class
AliasAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'alias'
,
'host'
)
list_display
=
(
'alias'
,
'host'
)
...
...
firewall/fields.py
View file @
458553dc
...
@@ -25,7 +25,7 @@ class MACAddressField(models.Field):
...
@@ -25,7 +25,7 @@ class MACAddressField(models.Field):
super
(
MACAddressField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
MACAddressField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
get_internal_type
(
self
):
def
get_internal_type
(
self
):
return
"CharField"
return
'CharField'
def
formfield
(
self
,
**
kwargs
):
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
MACAddressFormField
}
defaults
=
{
'form_class'
:
MACAddressFormField
}
...
@@ -34,13 +34,19 @@ class MACAddressField(models.Field):
...
@@ -34,13 +34,19 @@ class MACAddressField(models.Field):
add_introspection_rules
([],
[
"firewall
\
.fields
\
.MACAddressField"
])
add_introspection_rules
([],
[
"firewall
\
.fields
\
.MACAddressField"
])
def
val_alfanum
(
value
):
def
val_alfanum
(
value
):
if
not
alfanum_re
.
search
(
value
):
if
alfanum_re
.
search
(
value
)
is
None
:
raise
ValidationError
(
u'
%
s - csak betut, kotojelet, alahuzast, szamot tartalmazhat!'
%
value
)
raise
ValidationError
(
_
(
u'
%
s - only letters, numbers, underscores and hyphens are '
'allowed!'
)
%
value
)
def
val_domain
(
value
):
def
val_domain
(
value
):
if
not
domain_re
.
search
(
value
)
:
if
domain_re
.
search
(
value
)
is
None
:
raise
ValidationError
(
u'
%
s - helytelen domain'
%
value
)
raise
ValidationError
(
_
(
u'
%
s - invalid domain'
)
%
value
)
def
ipv4_2_ipv6
(
ipv4
):
def
ipv4_2_ipv6
(
ipv4
):
"""Convert IPv4 addr. string to IPv6 addr. string."""
m
=
ipv4_re
.
match
(
ipv4
)
m
=
ipv4_re
.
match
(
ipv4
)
return
"2001:738:2001:4031:
%
s:
%
s:
%
s:0"
%
(
m
.
group
(
1
),
m
.
group
(
2
),
m
.
group
(
3
))
if
m
is
None
:
raise
ValidationError
(
_
(
u'
%
s - not an IPv4 address'
)
%
ipv4
)
return
(
"2001:738:2001:4031:
%
s:
%
s:
%
s:0"
%
(
m
.
group
(
1
),
m
.
group
(
2
),
m
.
group
(
3
)))
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