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
e937cc4a
Commit
e937cc4a
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
removed redundant functions
parent
45555c53
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/ims_classifier.py
+13
-46
13 additions, 46 deletions
inventory_provider/routes/ims_classifier.py
with
13 additions
and
46 deletions
inventory_provider/routes/ims_classifier.py
+
13
−
46
View file @
e937cc4a
...
@@ -41,25 +41,6 @@ def _remove_duplicates_from_list(all):
...
@@ -41,25 +41,6 @@ def _remove_duplicates_from_list(all):
return
list
(
tmp_dict
.
values
())
return
list
(
tmp_dict
.
values
())
def
_locations_from_router
(
router_name
,
r
):
result
=
r
.
get
(
f
'
ims:location:
{
router_name
}
'
)
if
not
result
:
logger
.
error
(
f
'
error looking up location for
{
router_name
}
'
)
return
[]
result
=
json
.
loads
(
result
.
decode
(
'
utf-8
'
))
if
not
result
:
logger
.
error
(
f
'
sanity failure: empty list for location
{
router_name
}
'
)
return
[]
return
[{
'
a
'
:
_LOCATION
(
equipment
=
result
[
0
][
'
equipment-name
'
],
name
=
result
[
0
][
'
pop
'
][
'
name
'
],
abbreviation
=
result
[
0
][
'
pop
'
][
'
abbreviation
'
])
}]
# once the switchover is done then will refactor to get rid of
# once the switchover is done then will refactor to get rid of
# _locations_from_router
# _locations_from_router
def
_location_from_equipment
(
equipment_name
,
r
):
def
_location_from_equipment
(
equipment_name
,
r
):
...
@@ -88,26 +69,6 @@ def _location_from_services(services, r):
...
@@ -88,26 +69,6 @@ def _location_from_services(services, r):
yield
build_locations
(
loc_a
,
loc_b
)
yield
build_locations
(
loc_a
,
loc_b
)
# def _location_from_service_dict(s):
# location = {
# 'a': _LOCATION(
# equipment=s['equipment'],
# name=s['pop_name'],
# abbreviation=s['pop_abbreviation'])
# }
#
# if all(s[n] for n in (
# 'other_end_equipment',
# 'other_end_pop_name',
# 'other_end_pop_abbreviation')):
# location['b'] = _LOCATION(
# equipment=s['other_end_equipment'],
# name=s['other_end_pop_name'],
# abbreviation=s['other_end_pop_abbreviation'])
#
# return location
class
ClassifierRequestError
(
Exception
):
class
ClassifierRequestError
(
Exception
):
status_code
=
500
status_code
=
500
...
@@ -399,7 +360,8 @@ def peer_info(address):
...
@@ -399,7 +360,8 @@ def peer_info(address):
info
=
json
.
loads
(
info
)
info
=
json
.
loads
(
info
)
result
[
'
ix-public-peer-info
'
]
=
ix_peering_info
(
info
)
result
[
'
ix-public-peer-info
'
]
=
ix_peering_info
(
info
)
result
[
'
locations
'
].
append
(
build_locations
(
result
[
'
locations
'
].
append
(
build_locations
(
_location_from_equipment
(
info
[
'
router
'
],
r
)))
_location_from_equipment
(
get_ims_equipment_name
(
info
[
'
router
'
]),
r
)))
info
=
r
.
get
(
f
'
vpn_rr_peer:
{
address
}
'
)
info
=
r
.
get
(
f
'
vpn_rr_peer:
{
address
}
'
)
if
info
:
if
info
:
...
@@ -407,23 +369,28 @@ def peer_info(address):
...
@@ -407,23 +369,28 @@ def peer_info(address):
info
=
json
.
loads
(
info
)
info
=
json
.
loads
(
info
)
result
[
'
vpn-rr-peer-info
'
]
=
info
result
[
'
vpn-rr-peer-info
'
]
=
info
result
[
'
locations
'
].
append
(
build_locations
(
result
[
'
locations
'
].
append
(
build_locations
(
_location_from_equipment
(
info
[
'
router
'
],
r
)))
_location_from_equipment
(
get_ims_equipment_name
(
info
[
'
router
'
]),
r
)))
interfaces
=
list
(
find_interfaces_and_services
(
address
))
interfaces
=
list
(
find_interfaces_and_services
(
address
))
rs_dict
=
{}
if
interfaces
:
if
interfaces
:
result
[
'
interfaces
'
]
=
interfaces
result
[
'
interfaces
'
]
=
interfaces
for
i
in
interfaces
:
for
i
in
interfaces
:
for
s
in
i
[
'
services
'
]:
for
s
in
i
[
'
services
'
]:
# use a dict to get rid of duplicates
for
rs
in
get_related_services
(
s
[
'
equipment
'
],
s
[
'
interface_name
'
],
r
):
rs_dict
[
rs
[
'
id
'
]]
=
rs
result
[
'
locations
'
].
append
(
result
[
'
locations
'
].
append
(
build_locations
(
build_locations
(
_location_from_equipment
(
s
[
'
router
'
],
r
),
_location_from_equipment
(
s
[
'
equipment
'
],
r
),
_location_from_equipment
(
_location_from_equipment
(
s
[
'
other_end_equipment
'
],
r
))
s
[
'
other_end_equipment
'
],
r
))
)
)
# result['locations'] += \
result
[
'
related-services
'
]
=
list
(
rs_dict
.
values
())
# _location_from_equipment(s['equipment'], r)
# result['locations'] += \
# _location_from_equipment(s['other_end_equipment'], r)
result
[
'
locations
'
]
=
_remove_duplicates_from_list
(
result
[
'
locations
'
])
result
[
'
locations
'
]
=
_remove_duplicates_from_list
(
result
[
'
locations
'
])
result
=
json
.
dumps
(
result
)
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