Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
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
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.mysql'
,
# Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME'
:
'webadmin'
,
# Or path to database file if using sqlite3.
'USER'
:
'webadmin'
,
# 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.
'ENGINE'
:
'django.db.backends.mysql'
,
# Add 'postgresql_psycopg2',
# 'mysql', 'sqlite3' or 'oracle'.
'NAME'
:
'webadmin'
,
# Or path to database file if
# using sqlite3.
'USER'
:
'webadmin'
,
# 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
#import store.views
urlpatterns
=
patterns
(
''
,
url
(
r'^admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^$'
,
'one.views.home'
,
name
=
'home'
),
url
(
r'^login/$'
,
'school.views.login'
,
name
=
'login'
),
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/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/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
name
=
'vm_resume'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
name
=
'vm_power_off'
),
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
name
=
'vm_restart'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
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'
),
url
(
r'^admin/doc/'
,
include
(
'django.contrib.admindocs.urls'
)),
url
(
r'^admin/'
,
include
(
admin
.
site
.
urls
)),
url
(
r'^$'
,
'one.views.home'
,
name
=
'home'
),
url
(
r'^login/$'
,
'school.views.login'
,
name
=
'login'
),
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/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/stop/(?P<iid>\d+)/$'
,
'one.views.vm_stop'
,
name
=
'vm_stop'
),
url
(
r'^vm/resume/(?P<iid>\d+)/$'
,
'one.views.vm_resume'
,
name
=
'vm_resume'
),
url
(
r'^vm/power_off/(?P<iid>\d+)/$'
,
'one.views.vm_power_off'
,
name
=
'vm_power_off'
),
url
(
r'^vm/restart/(?P<iid>\d+)/$'
,
'one.views.vm_restart'
,
name
=
'vm_restart'
),
url
(
r'^vm/port_add/(?P<iid>\d+)/$'
,
'one.views.vm_port_add'
,
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):
model
=
Alias
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'
,
)
list_filter
=
(
'owner'
,
'vlan'
,
'groups'
)
search_fields
=
(
'hostname'
,
'description'
,
'ipv4'
,
'ipv6'
,
'mac'
)
...
...
@@ -16,16 +18,21 @@ class HostAdmin(admin.ModelAdmin):
class
HostInline
(
contrib
.
admin
.
TabularInline
):
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
):
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'
,
)
inlines
=
(
HostInline
,
)
class
RuleAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'r_type'
,
'color_desc'
,
'description'
,
'vlan_l'
,
'owner'
,
'extra'
,
'direction'
,
'accept'
,
'proto'
,
'sport'
,
'dport'
,
'nat'
,
'nat_dport'
)
list_filter
=
(
'r_type'
,
'vlan'
,
'owner'
,
'direction'
,
'accept'
,
'proto'
,
'nat'
)
list_display
=
(
'r_type'
,
'color_desc'
,
'description'
,
'vlan_l'
,
'owner'
,
'extra'
,
'direction'
,
'accept'
,
'proto'
,
'sport'
,
'dport'
,
'nat'
,
'nat_dport'
)
list_filter
=
(
'r_type'
,
'vlan'
,
'owner'
,
'direction'
,
'accept'
,
'proto'
,
'nat'
)
class
AliasAdmin
(
admin
.
ModelAdmin
):
list_display
=
(
'alias'
,
'host'
)
...
...
firewall/fields.py
View file @
458553dc
...
...
@@ -25,7 +25,7 @@ class MACAddressField(models.Field):
super
(
MACAddressField
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
def
get_internal_type
(
self
):
return
"CharField"
return
'CharField'
def
formfield
(
self
,
**
kwargs
):
defaults
=
{
'form_class'
:
MACAddressFormField
}
...
...
@@ -34,13 +34,19 @@ class MACAddressField(models.Field):
add_introspection_rules
([],
[
"firewall
\
.fields
\
.MACAddressField"
])
def
val_alfanum
(
value
):
if
not
alfanum_re
.
search
(
value
):
raise
ValidationError
(
u'
%
s - csak betut, kotojelet, alahuzast, szamot tartalmazhat!'
%
value
)
if
alfanum_re
.
search
(
value
)
is
None
:
raise
ValidationError
(
_
(
u'
%
s - only letters, numbers, underscores and hyphens are '
'allowed!'
)
%
value
)
def
val_domain
(
value
):
if
not
domain_re
.
search
(
value
)
:
raise
ValidationError
(
u'
%
s - helytelen domain'
%
value
)
if
domain_re
.
search
(
value
)
is
None
:
raise
ValidationError
(
_
(
u'
%
s - invalid domain'
)
%
value
)
def
ipv4_2_ipv6
(
ipv4
):
"""Convert IPv4 addr. string to IPv6 addr. string."""
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