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
35633e42
Commit
35633e42
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
corrected loading coriant details
parent
b9f7486f
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/db/ims_data.py
+9
-6
9 additions, 6 deletions
inventory_provider/db/ims_data.py
inventory_provider/routes/ims_classifier.py
+16
-49
16 additions, 49 deletions
inventory_provider/routes/ims_classifier.py
with
25 additions
and
55 deletions
inventory_provider/db/ims_data.py
+
9
−
6
View file @
35633e42
...
...
@@ -134,6 +134,11 @@ def get_port_id_services(ds: IMS):
_circuit
[
'
port_a_id
'
],
_circuit
[
'
port_b_id
'
]
=
\
_circuit
[
'
port_b_id
'
],
_circuit
[
'
port_a_id
'
]
yield
_circuit
if
len
(
port_ids
)
>
2
:
_circuit
.
pop
(
'
port_b_id
'
,
None
)
for
p
in
port_ids
[
1
:
-
1
]:
_circuit
[
'
port_a_id
'
]
=
p
yield
_circuit
for
circuit
in
circuits
:
cd
=
{
...
...
@@ -147,15 +152,13 @@ def get_port_id_services(ds: IMS):
}
ports
=
[]
if
circuit
[
'
internalports
'
]:
tmp_
ports
=
sorted
(
ports
=
sorted
(
circuit
[
'
internalports
'
],
key
=
lambda
x
:
x
[
'
sequencenumber
'
])
ports
=
[
tmp_ports
[
0
][
'
id
'
],
tmp_ports
[
-
1
][
'
id
'
]
]
ports
=
[
p
[
'
id
'
]
for
p
in
ports
]
elif
circuit
[
'
ports
'
]:
tmp_
ports
=
sorted
(
ports
=
sorted
(
circuit
[
'
ports
'
],
key
=
lambda
x
:
x
[
'
sequencenumber
'
])
ports
=
[
tmp_ports
[
0
][
'
id
'
],
tmp_ports
[
-
1
][
'
id
'
]]
# elif circuit['internalportaid'] or circuit['internalportbid']:
# ports = [circuit['internalportaid'], circuit['internalportbid']]
ports
=
[
p
[
'
id
'
]
for
p
in
ports
]
elif
circuit
[
'
portaid
'
]
or
circuit
[
'
portbid
'
]:
ports
=
[
circuit
[
'
portaid
'
],
circuit
[
'
portbid
'
]]
yield
from
_populate_end_info
(
cd
,
ports
)
...
...
This diff is collapsed.
Click to expand it.
inventory_provider/routes/ims_classifier.py
+
16
−
49
View file @
35633e42
...
...
@@ -197,7 +197,6 @@ def get_related_services(source_equipment: str, interface: str, r) -> dict:
yield
from
get_top_level_services
(
s
[
'
id
'
],
r
)
for
related
in
related_interfaces
(
source_equipment
,
interface
):
ims_interface
=
get_ims_interface
(
related
)
logger
.
debug
(
f
'
Related Interface:
{
ims_interface
}
'
)
rif_services
=
r
.
get
(
f
'
ims:interface_services:
{
ims_source_equipment
}
:
{
ims_interface
}
'
)
if
rif_services
:
...
...
@@ -661,10 +660,12 @@ def get_fiberlink_trap_metadata(ne_name_str: str, object_name_str: str) \
@common.require_accepts_json
def
get_coriant_info
(
equipment_name
:
str
,
entity_string
:
str
)
->
Response
:
r
=
common
.
get_current_redis
()
equipment_name
=
get_ims_equipment_name
(
equipment_name
)
cache_key
=
'
ims-classifier-cache:coriant:%s:%s
'
%
(
equipment_name
,
entity_string
)
ims_source_equipment
=
get_ims_equipment_name
(
equipment_name
)
ims_interface
=
get_ims_interface
(
entity_string
)
cache_key
=
'
ims-classifier-cache:coriant:
'
\
f
'
{
ims_source_equipment
}
:
{
ims_interface
}
'
ignore_cache
=
request
.
args
.
get
(
'
ignore-cache
'
,
default
=
'
false
'
,
type
=
str
)
try
:
...
...
@@ -680,61 +681,27 @@ def get_coriant_info(equipment_name: str, entity_string: str) -> Response:
result
=
result
.
decode
(
'
utf-8
'
)
else
:
m
=
re
.
match
(
r
'
^(\d+\-\d+)\.(\d+)
'
,
entity_string
)
m
=
re
.
match
(
r
'
^(\d+\-\d+)\.(\d+)
'
,
ims_interface
)
if
not
m
:
logger
.
error
(
'
invalid coriant entity string format:
%r
'
%
entity_string
)
f
'
invalid coriant entity string format:
{
ims_interface
}
'
)
return
Response
(
response
=
"
no available info for
'
{}
'
'
{}
'"
.
format
(
equipment_name
,
entity_string
)
,
response
=
"
no available info for
"
f
"'
{
ims_source_equipment
}
'
'
{
ims_interface
}
'"
,
status
=
404
,
mimetype
=
"
text/html
"
)
result
=
{
'
equipment name
'
:
equipment
_name
,
'
equipment name
'
:
ims_source_
equipment
,
'
card id
'
:
m
.
group
(
1
).
replace
(
'
-
'
,
'
/
'
),
'
port number
'
:
m
.
group
(
2
),
'
locations
'
:
[]
'
port number
'
:
m
.
group
(
2
)
}
interface_name
=
f
'
{
result
[
"
card id
"
]
}
/
{
result
[
"
port number
"
]
}
'
top_level_services
=
[]
services
=
r
.
get
(
f
'
ims:interface_services:
{
equipment_name
}
:
{
interface_name
}
'
)
if
services
:
result
[
'
services
'
]
=
json
.
loads
(
services
.
decode
(
'
utf=8
'
))
for
s
in
result
[
'
services
'
]:
top_level_services
.
extend
(
get_top_level_services
(
s
[
'
id
'
],
r
))
result
[
'
locations
'
]
+=
\
_location_from_equipment
(
s
[
'
equipment
'
],
r
)
result
[
'
locations
'
]
+=
\
_location_from_equipment
(
s
[
'
other_end_equipment
'
],
r
)
def
_related_services
():
for
related
in
related_interfaces
(
equipment_name
,
interface_name
):
logger
.
debug
(
f
'
Related Interface:
{
related
}
'
)
rs
=
r
.
get
(
f
'
ims:interface_services:
{
equipment_name
}
:
'
f
'
{
related
.
upper
()
}
'
)
if
rs
:
for
s
in
json
.
loads
(
rs
.
decode
(
'
utf-8
'
)):
top_level_services
.
extend
(
get_top_level_services
(
s
[
'
id
'
],
r
))
yield
{
'
name
'
:
s
[
'
name
'
],
'
status
'
:
s
[
'
status
'
],
'
circuit_type
'
:
s
[
'
circuit_type
'
],
'
project
'
:
s
[
'
project
'
]
}
related_services
=
list
(
_related_services
())
if
related_services
:
top_level_services
.
extend
(
related_services
)
if
top_level_services
:
result
[
'
related-services
'
]
=
top_level_services
if
not
result
[
'
locations
'
]:
result
[
'
locations
'
]
=
_location_from_equipment
(
equipment_name
,
r
)
result
.
update
(
get_interface_services_and_locs
(
ims_source_equipment
,
interface_name
,
r
))
result
[
'
locations
'
]
=
_remove_duplicates_from_list
(
result
[
'
locations
'
])
result
=
json
.
dumps
(
result
)
...
...
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