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
a0d2b219
Commit
a0d2b219
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
don't return dummy location for unknown routers
parent
4d51292f
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/classifier.py
+8
-21
8 additions, 21 deletions
inventory_provider/routes/classifier.py
test/test_classifier_routes.py
+2
-8
2 additions, 8 deletions
test/test_classifier_routes.py
with
10 additions
and
29 deletions
inventory_provider/routes/classifier.py
+
8
−
21
View file @
a0d2b219
...
...
@@ -33,35 +33,24 @@ def _remove_duplicates_from_list(all):
return
list
(
tmp_dict
.
values
())
def
_location_from_router
(
router_name
):
def
_location
s
_from_router
(
router_name
):
r
=
common
.
get_current_redis
()
result
=
r
.
get
(
f
'
opsdb:location:
{
router_name
}
'
)
if
not
result
:
logger
.
error
(
f
'
error looking up location for
{
router_name
}
'
)
return
{
'
a
'
:
_LOCATION
(
equipment
=
router_name
,
name
=
'
?
'
,
abbreviation
=
'
?
'
)
}
return
[]
result
=
json
.
loads
(
result
.
decode
(
'
utf-8
'
))
if
not
result
:
logger
.
error
(
f
'
sanity failure: empty list for location
{
router_name
}
'
)
return
None
return
{
'
a
'
:
_LOCATION
(
equipment
=
router_name
,
name
=
'
?
'
,
abbreviation
=
'
?
'
)
}
return
[]
return
{
return
[
{
'
a
'
:
_LOCATION
(
equipment
=
result
[
0
][
'
equipment-name
'
],
name
=
result
[
0
][
'
pop
'
][
'
name
'
],
abbreviation
=
result
[
0
][
'
pop
'
][
'
abbreviation
'
])
}
}
]
def
_location_from_service_dict
(
s
):
...
...
@@ -217,7 +206,7 @@ def get_juniper_link_info(source_equipment, interface):
result
[
'
related-services
'
]
=
top_level_services
if
not
result
[
'
locations
'
]:
result
[
'
locations
'
]
=
[
_location_from_router
(
source_equipment
)
]
result
[
'
locations
'
]
=
_location
s
_from_router
(
source_equipment
)
result
[
'
locations
'
]
=
_remove_duplicates_from_list
(
result
[
'
locations
'
])
result
=
json
.
dumps
(
result
)
...
...
@@ -351,16 +340,14 @@ def peer_info(address):
info
=
info
.
decode
(
'
utf-8
'
)
info
=
json
.
loads
(
info
)
result
[
'
ix-public-peer-info
'
]
=
ix_peering_info
(
info
)
router_location
=
_location_from_router
(
info
[
'
router
'
])
result
[
'
locations
'
]
+=
[
router_location
]
result
[
'
locations
'
]
+=
_locations_from_router
(
info
[
'
router
'
])
info
=
r
.
get
(
'
vpn_rr_peer:%s
'
%
address
)
if
info
:
info
=
info
.
decode
(
'
utf-8
'
)
info
=
json
.
loads
(
info
)
result
[
'
vpn-rr-peer-info
'
]
=
info
router_location
=
_location_from_router
(
info
[
'
router
'
])
result
[
'
locations
'
]
+=
[
router_location
]
result
[
'
locations
'
]
+=
_locations_from_router
(
info
[
'
router
'
])
interfaces
=
list
(
find_interfaces_and_services
(
address
))
if
interfaces
:
...
...
This diff is collapsed.
Click to expand it.
test/test_classifier_routes.py
+
2
−
8
View file @
a0d2b219
...
...
@@ -30,8 +30,7 @@ LOCATIONS_DEFINITIONS = {
},
"
locations-list
"
:
{
"
type
"
:
"
array
"
,
"
items
"
:
{
"
$ref
"
:
"
#/definitions/location
"
},
"
minitems
"
:
1
"
items
"
:
{
"
$ref
"
:
"
#/definitions/location
"
}
}
}
...
...
@@ -235,12 +234,7 @@ def test_juniper_link_unknown_router(client):
'
bundle
'
:
[],
'
bundle_members
'
:
[]
},
'
locations
'
:
[{
'
a
'
:
{
'
equipment
'
:
'
unknown-router
'
,
'
name
'
:
'
?
'
,
'
abbreviation
'
:
'
?
'
}
}]
'
locations
'
:
[]
}
...
...
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