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
9a47f5e1
Commit
9a47f5e1
authored
3 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
added route for tnms fibre trap classification
parent
90963544
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inventory_provider/routes/classifier.py
+97
-0
97 additions, 0 deletions
inventory_provider/routes/classifier.py
with
97 additions
and
0 deletions
inventory_provider/routes/classifier.py
+
97
−
0
View file @
9a47f5e1
...
...
@@ -883,6 +883,103 @@ def get_fiberlink_trap_metadata(ne_name_str: str, object_name_str: str) \
return
Response
(
result
,
mimetype
=
"
application/json
"
)
@routes.route
(
"
/tnms-fibre-info/<path:enms_pc_name>
"
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
def
get_tnms_fibre_trap_metadata
(
enms_pc_name
:
str
)
->
Response
:
"""
Handler for /classifier/infinera-fiberlink-info that
returns metadata for a particular opitical path segment.
TODO: no schema is declared, and there are no validation tests
:param enms_pc_name: both node names separated by a forward slash
:return:
"""
r
=
common
.
get_current_redis
()
# double check that we only need to check the two nodes and not the objects
cache_key
=
f
'
classifier-cache:fiberlink:
{
enms_pc_name
}
'
result
=
_ignore_cache_or_retrieve
(
request
,
cache_key
,
r
)
if
not
result
:
logger
.
debug
(
"
1
"
)
try
:
equipment_a
,
equipment_b
=
enms_pc_name
.
split
(
"
/
"
)
logger
.
debug
(
f
"
{
equipment_a
}
-
{
equipment_b
}
"
)
except
ValueError
:
raise
ClassifierProcessingError
(
f
'
unable to parse
{
enms_pc_name
}
'
'
into two elements
'
)
circuits
=
r
.
get
(
f
'
ims:node_pair_services:
{
enms_pc_name
}
'
)
all_frs
=
{}
all_tls
=
{}
contacts
=
set
()
if
circuits
:
circuits
=
json
.
loads
(
circuits
.
decode
(
'
utf-8
'
))
for
c
in
circuits
:
contacts
.
update
(
c
[
'
contacts
'
])
for
fr
in
c
[
'
fibre-routes
'
]:
all_frs
[
fr
[
'
id
'
]]
=
fr
for
fr
in
c
[
'
related-services
'
]:
all_tls
[
fr
[
'
id
'
]]
=
fr
fibre_routes
=
list
(
all_frs
.
values
())
top_level_services
=
list
(
all_tls
.
values
())
if
fibre_routes
:
location_a
=
_location_from_equipment
(
equipment_a
,
r
)
location_b
=
_location_from_equipment
(
equipment_b
,
r
)
if
location_a
:
loc_a
=
location_a
else
:
loc_a
=
_LOCATION
(
equipment_a
,
''
,
''
)
if
location_b
:
loc_b
=
location_b
else
:
loc_b
=
_LOCATION
(
equipment_b
,
''
,
''
)
# added locations in preparation for refactoring to be in-line
# with other location data. Once Dashboard has been altered to
# use this for fiberlink alarms the 'ends' attribute can be
# removed
result
=
{
'
locations
'
:
[
build_locations
(
loc_a
,
loc_b
)
],
'
ends
'
:
{
'
a
'
:
{
'
pop
'
:
loc_a
[
'
name
'
],
'
pop_abbreviation
'
:
loc_a
[
'
abbreviation
'
],
'
equipment
'
:
loc_a
[
'
equipment
'
]
},
'
b
'
:
{
'
pop
'
:
loc_b
[
'
name
'
],
'
pop_abbreviation
'
:
loc_b
[
'
abbreviation
'
],
'
equipment
'
:
loc_b
[
'
equipment
'
]
},
},
'
df_route
'
:
fibre_routes
[
0
],
'
related-services
'
:
top_level_services
,
'
contacts
'
:
sorted
(
list
(
contacts
))
}
for
rs
in
result
[
'
related-services
'
]:
rs
.
pop
(
'
id
'
,
None
)
result
=
json
.
dumps
(
result
)
r
.
set
(
cache_key
,
result
)
if
not
result
:
return
Response
(
response
=
f
"
no available info for
{
enms_pc_name
}
"
,
status
=
404
,
mimetype
=
"
text/html
"
)
return
Response
(
result
,
mimetype
=
"
application/json
"
)
@routes.route
(
'
/coriant-info/<equipment_name>/<path:entity_string>
'
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
...
...
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