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
1bf78e22
Commit
1bf78e22
authored
2 years ago
by
David Schmitz
Browse files
Options
Downloads
Patches
Plain Diff
fix/checksync_use_getconfig_cache
parent
2174a639
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flowspec/models.py
+18
-7
18 additions, 7 deletions
flowspec/models.py
flowspec/tasks.py
+10
-1
10 additions, 1 deletion
flowspec/tasks.py
with
28 additions
and
8 deletions
flowspec/models.py
+
18
−
7
View file @
1bf78e22
...
...
@@ -467,18 +467,27 @@ class Route(models.Model):
self
.
save
()
def
check_sync
(
self
):
if
not
self
.
is_synced
():
def
check_sync
(
self
,
netconf_device_queried
=
None
):
if
not
self
.
is_synced
(
netconf_device_queried
=
netconf_device_queried
):
#self.status = "OUTOFSYNC"
#self.save()
self
.
update_status
(
"
OUTOFSYNC
"
)
def
is_synced
(
self
):
def
is_synced
(
self
,
netconf_device_queried
=
None
):
logger
.
info
(
'
models::is_synced(): self=
'
+
str
(
self
))
found
=
False
try
:
get_device
=
PR
.
Retriever
()
device
=
get_device
.
fetch_device
()
routes
=
device
.
routing_options
[
0
].
routes
# allows for caching of NETCONF GetConfig query, e.g., during tasks::check_sync
if
netconf_device_queried
==
None
:
logger
.
info
(
"
models::is_synced(): querying routes newly from NETCONF router
"
)
get_device
=
PR
.
Retriever
()
parsed_netconf_xml__device_obj
=
get_device
.
fetch_device
()
else
:
logger
.
info
(
"
models::is_synced(): reusing cached query from NETCONF router
"
)
parsed_netconf_xml__device_obj
=
netconf_device_queried
parsed_netconf_xml__flows
=
parsed_netconf_xml__device_obj
.
routing_options
#logger.info('models::is_synced(): parsed_netconf_xml__flows='+str(parsed_netconf_xml__flows))
except
Exception
as
e
:
#self.status = "EXPIRED"
#self.save()
...
...
@@ -486,7 +495,9 @@ class Route(models.Model):
logger
.
error
(
'
models::is_synced(): No routing options on device. Exception: %s
'
%
e
)
return
True
for
route
in
routes
:
for
flow
in
parsed_netconf_xml__flows
:
for
route
in
flow
.
routes
:
#logger.debug('models::is_synced(): loop flow='+str(flow)+' route='+str(route))
if
route
.
name
==
self
.
name
:
found
=
True
logger
.
debug
(
'
models::is_synced(): Found a matching rule name
'
)
...
...
This diff is collapsed.
Click to expand it.
flowspec/tasks.py
+
10
−
1
View file @
1bf78e22
...
...
@@ -278,6 +278,15 @@ def check_sync(route_name=None, selected_routes=[]):
routes
=
selected_routes
if
route_name
:
routes
=
routes
.
filter
(
name
=
route_name
)
try
:
logger
.
info
(
"
tasks::check_sync(): making single query whose result is to be used during loop processing
"
)
get_device
=
PR
.
Retriever
()
device
=
get_device
.
fetch_device
()
except
Exception
as
e
:
logger
.
info
(
"
tasks::check_sync(): exception occured during get active routes on router:
"
+
str
(
e
))
return
for
route
in
routes
:
if
route
.
has_expired
()
and
(
route
.
status
!=
'
EXPIRED
'
and
route
.
status
!=
'
ADMININACTIVE
'
and
route
.
status
!=
'
INACTIVE
'
and
route
.
status
!=
'
INACTIVE_TODELETE
'
and
route
.
status
!=
'
PENDING_TODELETE
'
):
if
route
.
status
!=
'
ERROR
'
:
...
...
@@ -286,7 +295,7 @@ def check_sync(route_name=None, selected_routes=[]):
else
:
if
route
.
status
!=
'
EXPIRED
'
:
old_status
=
route
.
status
route
.
check_sync
()
route
.
check_sync
(
netconf_device_queried
=
device
)
new_status
=
route
.
status
if
old_status
!=
new_status
:
logger
.
info
(
'
status of rule changed during check_sync %s : %s -> %s
'
%
(
route
.
name
,
old_status
,
new_status
))
...
...
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