Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
circlestack
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
0d875b08
authored
Aug 22, 2015
by
Czémán Arnold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
firewall: add logger for add_rule command
parent
8dd2391b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
circle/firewall/management/commands/add_rule.py
+17
-6
No files found.
circle/firewall/management/commands/add_rule.py
View file @
0d875b08
...
@@ -15,10 +15,13 @@
...
@@ -15,10 +15,13 @@
from
__future__
import
unicode_literals
,
absolute_import
from
__future__
import
unicode_literals
,
absolute_import
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.base
import
BaseCommand
,
CommandError
import
logging
from
firewall.models
import
Vlan
,
VlanGroup
,
Rule
from
firewall.models
import
Vlan
,
VlanGroup
,
Rule
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
class
Command
(
BaseCommand
):
...
@@ -103,8 +106,12 @@ class Command(BaseCommand):
...
@@ -103,8 +106,12 @@ class Command(BaseCommand):
if
port
:
if
port
:
self
.
validate_port
(
port
)
self
.
validate_port
(
port
)
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
)
try
:
rule
.
save
()
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
)
rule
.
save
()
except
Warning
as
e
:
logger
.
warning
(
e
)
else
:
else
:
lower
=
min
(
range
)
lower
=
min
(
range
)
higher
=
max
(
range
)
higher
=
max
(
range
)
...
@@ -114,9 +121,12 @@ class Command(BaseCommand):
...
@@ -114,9 +121,12 @@ class Command(BaseCommand):
rules
=
[]
rules
=
[]
for
port
in
xrange
(
lower
,
higher
+
1
):
for
port
in
xrange
(
lower
,
higher
+
1
):
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
try
:
owner
,
vlan
,
fnet
)
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
rules
.
append
(
rule
)
owner
,
vlan
,
fnet
)
rules
.
append
(
rule
)
except
Warning
as
e
:
logger
.
warning
(
e
)
Rule
.
objects
.
bulk_create
(
rules
)
Rule
.
objects
.
bulk_create
(
rules
)
...
@@ -126,7 +136,8 @@ class Command(BaseCommand):
...
@@ -126,7 +136,8 @@ class Command(BaseCommand):
vlan
=
vlan
,
foreign_network
=
fnet
,
owner
=
owner
)
vlan
=
vlan
,
foreign_network
=
fnet
,
owner
=
owner
)
if
self
.
is_exist
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
):
if
self
.
is_exist
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
):
raise
CommandError
(
'Rule does exist, yet:
%
s'
%
unicode
(
rule
))
raise
Warning
((
'Rule does exist:
%
s'
%
unicode
(
rule
))
.
encode
(
'utf-8'
))
rule
.
full_clean
()
rule
.
full_clean
()
...
...
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