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
52bf75f0
Commit
52bf75f0
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Plain Diff
Finished feature DBOARD-328-handle-unknown-router.
parents
59b04681
a0d2b219
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
-10
8 additions, 10 deletions
inventory_provider/routes/classifier.py
test/test_classifier_routes.py
+23
-1
23 additions, 1 deletion
test/test_classifier_routes.py
with
31 additions
and
11 deletions
inventory_provider/routes/classifier.py
+
8
−
10
View file @
52bf75f0
...
...
@@ -33,24 +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
None
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
[]
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
):
...
...
@@ -206,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
)
...
...
@@ -340,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
+
23
−
1
View file @
52bf75f0
...
...
@@ -174,7 +174,7 @@ JUNIPER_LINK_METADATA = {
},
"
locations
"
:
{
"
$ref
"
:
"
#/definitions/locations-list
"
}
},
#
"required": ["interface"],
"
required
"
:
[
"
interface
"
,
"
locations
"
],
"
additionalProperties
"
:
False
}
...
...
@@ -216,6 +216,28 @@ def test_juniper_link_info_not_found(client):
}
def
test_juniper_link_unknown_router
(
client
):
rv
=
client
.
get
(
'
/classifier/juniper-link-info/
'
'
unknown-router/unknown-interface-name
'
,
headers
=
DEFAULT_REQUEST_HEADERS
)
assert
rv
.
status_code
==
200
assert
rv
.
is_json
response_data
=
json
.
loads
(
rv
.
data
.
decode
(
'
utf-8
'
))
jsonschema
.
validate
(
response_data
,
JUNIPER_LINK_METADATA
)
assert
response_data
==
{
'
interface
'
:
{
'
name
'
:
'
unknown-interface-name
'
,
'
description
'
:
''
,
'
ipv4
'
:
[],
'
ipv6
'
:
[],
'
bundle
'
:
[],
'
bundle_members
'
:
[]
},
'
locations
'
:
[]
}
VPN_RR_PEER_INFO_KEYS
=
{
'
vpn-rr-peer-info
'
,
'
locations
'
}
IX_PUBLIC_PEER_INFO_KEYS
=
{
'
ix-public-peer-info
'
,
'
interfaces
'
,
'
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