Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
inventory-provider
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
geant-swd
dashboardv3
inventory-provider
Commits
2caf4cba
Commit
2caf4cba
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Plain Diff
Finished feature add-poller-response-caching.
parents
c7724cc1
ab1e9d25
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/routes/poller.py
+19
-10
19 additions, 10 deletions
inventory_provider/routes/poller.py
test/test_junos_devices_query.py
+0
-0
0 additions, 0 deletions
test/test_junos_devices_query.py
with
19 additions
and
10 deletions
inventory_provider/routes/poller.py
+
19
−
10
View file @
2caf4cba
...
...
@@ -88,10 +88,9 @@ def poller_interface_oids(hostname):
@common.require_accepts_json
def
service_category_interfaces
(
category
):
def
_interfaces
():
r
=
common
.
get_current_redis
()
for
k
in
r
.
scan_iter
(
f
'
interface-services:
{
category
.
lower
()
}
:*
'
):
cached_ifc
=
r
.
get
(
k
.
decode
(
'
utf-8
'
)).
decode
(
'
utf-8
'
)
def
_interfaces
(
rc
,
cat
):
for
k
in
rc
.
scan_iter
(
f
'
interface-services:
{
cat
}
:*
'
):
cached_ifc
=
rc
.
get
(
k
.
decode
(
'
utf-8
'
)).
decode
(
'
utf-8
'
)
cached_ifc
=
json
.
loads
(
cached_ifc
)
basic_ifc_info
=
dict
()
for
k
in
[
'
description
'
,
'
interface
'
,
'
router
'
]:
...
...
@@ -104,12 +103,22 @@ def service_category_interfaces(category):
ifc
.
update
(
basic_ifc_info
)
yield
ifc
result
=
list
(
_interfaces
()
)
category
=
category
.
lower
()
if
not
result
:
return
Response
(
response
=
f
'
no info available for service category
{
category
}
'
,
status
=
404
,
mimetype
=
"
text/html
"
)
r
=
common
.
get_current_redis
()
cache_key
=
f
'
classifier-cache:poller:service:
{
category
}
'
result
=
r
.
get
(
cache_key
)
if
result
:
result
=
json
.
loads
(
result
.
decode
(
'
utf-8
'
))
else
:
result
=
list
(
_interfaces
(
r
,
category
))
if
result
:
r
.
set
(
cache_key
,
json
.
dumps
(
result
).
encode
(
'
utf-8
'
))
else
:
return
Response
(
response
=
f
'
no info available for service category
{
category
}
'
,
status
=
404
,
mimetype
=
"
text/html
"
)
return
jsonify
(
result
)
This diff is collapsed.
Click to expand it.
test/test_junos
space_io
.py
→
test/test_junos
_devices_query
.py
+
0
−
0
View file @
2caf4cba
File moved
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