Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FoD
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Schmitz
FoD
Commits
8d6abe10
Commit
8d6abe10
authored
3 years ago
by
Tomáš Čejka
Browse files
Options
Downloads
Patches
Plain Diff
delete: reworked and simplified - return after delete and don't save again
parent
abc2b0dc
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
flowspec/tasks.py
+18
-24
18 additions, 24 deletions
flowspec/tasks.py
with
18 additions
and
24 deletions
flowspec/tasks.py
+
18
−
24
View file @
8d6abe10
...
...
@@ -125,38 +125,32 @@ def delete(routepk, **kwargs):
route
=
Route
.
objects
.
get
(
pk
=
routepk
)
initial_status
=
route
.
status
try
:
#username = request.user.username
#user_is_admin = request.user.is_superuser()
#logger.info("tasks::delete(): username="+str(username)+" route="+str(route)+" initial_status="+str(initial_status))
applier
=
PR
.
Applier
(
route_object
=
route
)
commit
,
response
=
applier
.
apply
(
operation
=
"
delete
"
)
reason_text
=
''
logger
.
info
(
"
tasks::delete(): initial_status=
"
+
str
(
initial_status
))
fully_deleted
=
False
if
commit
and
initial_status
==
"
PENDING_TODELETE
"
:
# special new case for fully deleting a rule via REST API
fully_deleted
=
True
route
.
status
=
"
INACTIVE
"
route
.
delete
()
msg1
=
"
[%s] Fully deleted route : %s%s- Result %s
"
%
(
route
.
applier
,
route
.
name
,
reason_text
,
response
)
logger
.
info
(
"
tasks::delete(): DELETED msg=
"
+
msg1
)
announce
(
msg1
,
route
.
applier
,
route
)
if
commit
:
status
=
"
INACTIVE
"
if
"
reason
"
in
kwargs
and
kwargs
[
'
reason
'
]
==
'
EXPIRED
'
:
status
=
'
EXPIRED
'
reason_text
=
"
Reason: %s
"
%
status
route
.
status
=
"
INACTIVE
"
msg1
=
"
[%s] Fully deleted route : %s%s- Result %s
"
%
(
route
.
applier
,
route
.
name
,
reason_text
,
response
)
logger
.
info
(
"
tasks::delete(): DELETED msg=
"
+
msg1
)
announce
(
msg1
,
route
.
applier
,
route
)
try
:
#snmp_add_initial_zero_value.delay(str(route.id), False)
snmp_add_initial_zero_value
(
str
(
route
.
id
),
False
)
snmp_add_initial_zero_value
(
str
(
route
.
id
),
False
)
except
Exception
as
e
:
logger
.
error
(
"
edit(): route=
"
+
str
(
route
)
+
"
, INACTIVE, add_null_value failed:
"
+
str
(
e
))
logger
.
error
(
"
edit(): route=
"
+
str
(
route
)
+
"
, INACTIVE, add_null_value failed:
"
+
str
(
e
))
route
.
delete
()
return
else
:
status
=
"
ERROR
"
if
not
fully_deleted
:
route
.
status
=
status
route
.
response
=
response
route
.
save
()
announce
(
"
[%s] Suspending rule : %s%s- Result %s
"
%
(
route
.
applier_username_nice
,
route
.
name
,
reason_text
,
response
),
route
.
applier
,
route
)
# NETCONF "delete" operation failed, keep the object in DB
if
"
reason
"
in
kwargs
and
kwargs
[
'
reason
'
]
==
'
EXPIRED
'
:
status
=
'
EXPIRED
'
reason_text
=
"
Reason: %s
"
%
status
else
:
status
=
"
ERROR
"
route
.
status
=
status
route
.
response
=
response
route
.
save
()
announce
(
"
[%s] Suspending rule : %s%s- Result %s
"
%
(
route
.
applier_username_nice
,
route
.
name
,
reason_text
,
response
),
route
.
applier
,
route
)
except
TimeLimitExceeded
:
route
.
status
=
"
ERROR
"
route
.
response
=
"
Task timeout
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment