Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
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
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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
circle/firewall/management/commands/add_rule.py
+13
-2
No files found.
circle/firewall/management/commands/add_rule.py
View file @
0d875b08
...
...
@@ -15,10 +15,13 @@
from
__future__
import
unicode_literals
,
absolute_import
from
django.core.management.base
import
BaseCommand
,
CommandError
import
logging
from
firewall.models
import
Vlan
,
VlanGroup
,
Rule
from
django.contrib.auth.models
import
User
logger
=
logging
.
getLogger
(
__name__
)
class
Command
(
BaseCommand
):
...
...
@@ -103,8 +106,12 @@ class Command(BaseCommand):
if
port
:
self
.
validate_port
(
port
)
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
)
try
:
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
)
rule
.
save
()
except
Warning
as
e
:
logger
.
warning
(
e
)
else
:
lower
=
min
(
range
)
higher
=
max
(
range
)
...
...
@@ -114,9 +121,12 @@ class Command(BaseCommand):
rules
=
[]
for
port
in
xrange
(
lower
,
higher
+
1
):
try
:
rule
=
self
.
make_rule
(
port
,
proto
,
action
,
dir
,
owner
,
vlan
,
fnet
)
rules
.
append
(
rule
)
except
Warning
as
e
:
logger
.
warning
(
e
)
Rule
.
objects
.
bulk_create
(
rules
)
...
...
@@ -126,7 +136,8 @@ class Command(BaseCommand):
vlan
=
vlan
,
foreign_network
=
fnet
,
owner
=
owner
)
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
()
...
...
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