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
97868f60
Commit
97868f60
authored
11 months ago
by
Bjarke Madsen
Browse files
Options
Downloads
Patches
Plain Diff
Remove caching for /msr/services endpoint
parent
bee28384
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/routes/msr.py
+7
-10
7 additions, 10 deletions
inventory_provider/routes/msr.py
with
7 additions
and
10 deletions
inventory_provider/routes/msr.py
+
7
−
10
View file @
97868f60
...
...
@@ -944,8 +944,6 @@ def get_peering_services():
return
Response
(
response
,
mimetype
=
"
application/json
"
)
# TODO: @functools.cache is only available in py3.9
@functools.lru_cache
(
maxsize
=
None
)
def
_load_all_interfaces
():
"""
loads all ip interfaces in the network and returns as a dict
...
...
@@ -972,8 +970,6 @@ def _load_all_interfaces():
return
result
# TODO: @functools.cache is only available in py3.9
@functools.lru_cache
(
maxsize
=
None
)
def
_load_redundant_access_peers
():
"""
load all peers that should be considered
...
...
@@ -997,7 +993,7 @@ def _load_redundant_access_peers():
return
result
def
_ip_endpoint_extractor
(
endpoint_details
:
d
ict
):
def
_ip_endpoint_extractor
(
all_interfaces
:
Dict
,
endpoint_details
:
D
ict
):
"""
special-purpose method used only by _endpoint_extractor
...
...
@@ -1019,7 +1015,6 @@ def _ip_endpoint_extractor(endpoint_details: dict):
'
interface
'
:
interface
,
}
all_interfaces
=
_load_all_interfaces
()
# sanity: should have already been checked
assert
hostname
in
all_interfaces
...
...
@@ -1039,7 +1034,7 @@ def _ip_endpoint_extractor(endpoint_details: dict):
return
ip_endpoint
def
_endpoint_extractor
(
endpoint_details
:
Dict
):
def
_endpoint_extractor
(
all_interfaces
:
Dict
,
endpoint_details
:
Dict
):
"""
special-purpose method used only by get_system_correlation_services
...
...
@@ -1057,9 +1052,9 @@ def _endpoint_extractor(endpoint_details: Dict):
return
potential_hostname
=
ims_equipment_to_hostname
(
endpoint_details
[
'
equipment
'
])
all_routers
=
_load_
all_interfaces
()
.
keys
()
all_routers
=
all_interfaces
.
keys
()
if
potential_hostname
in
all_routers
:
return
_ip_endpoint_extractor
(
endpoint_details
)
return
_ip_endpoint_extractor
(
all_interfaces
,
endpoint_details
)
else
:
return
{
'
equipment
'
:
endpoint_details
[
'
equipment
'
],
...
...
@@ -1107,6 +1102,8 @@ def get_system_correlation_services():
response
=
_ignore_cache_or_retrieve
(
request
,
cache_key
,
r
)
if
not
response
:
all_interfaces
=
_load_all_interfaces
()
sid_services
=
json
.
loads
(
r
.
get
(
'
ims:sid_services
'
).
decode
(
'
utf-8
'
))
response
=
[]
...
...
@@ -1123,7 +1120,7 @@ def get_system_correlation_services():
service_info
[
'
service_type
'
]
=
d
[
'
service_type
'
]
service_info
[
'
customer
'
]
=
d
[
'
customer
'
]
endpoint
=
_endpoint_extractor
(
d
)
endpoint
=
_endpoint_extractor
(
all_interfaces
,
d
)
if
endpoint
:
service_info
[
'
endpoints
'
].
append
(
endpoint
)
...
...
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