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
4fdd1e16
Commit
4fdd1e16
authored
4 years ago
by
Robert Latta
Browse files
Options
Downloads
Patches
Plain Diff
used existing code to ix and vpnrr info
parent
04b67088
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/ims_classifier.py
+10
-55
10 additions, 55 deletions
inventory_provider/routes/ims_classifier.py
with
10 additions
and
55 deletions
inventory_provider/routes/ims_classifier.py
+
10
−
55
View file @
4fdd1e16
...
...
@@ -14,7 +14,7 @@ from redis import Redis
from
inventory_provider.db.ims
import
IMS_SERVICE_NAMES
from
inventory_provider.routes
import
common
from
inventory_provider.routes.classifier
import
_asn_group_info
,
\
_link_interface_info
_link_interface_info
,
_ix_peering_info
,
_vpn_rr_peering_info
routes
=
Blueprint
(
"
ims-inventory-data-classifier-support-routes
"
,
__name__
)
...
...
@@ -341,48 +341,6 @@ def get_juniper_link_info(source_equipment: str, interface: str) -> Response:
return
Response
(
result
,
mimetype
=
"
application/json
"
)
def
ix_peering_info
(
peer_info
:
dict
)
->
dict
:
"""
TODO: this is probably the least efficient way of doing this
(if it
'
s a problem, pre-compute these lists)
:param peer_info: an element from ix_public_peer:address
:return:
"""
result
=
{
'
peer
'
:
peer_info
,
'
group
'
:
[],
'
router
'
:
[]
}
try
:
ipaddress
.
ip_address
(
peer_info
[
'
name
'
])
except
ValueError
:
raise
ClassifierProcessingError
(
f
'
unable to parse
{
peer_info
[
"
name
"
]
}
as an ip address
'
)
description
=
peer_info
[
'
description
'
]
assert
description
is
not
None
# sanity
keyword
=
description
.
split
(
'
'
)[
0
]
# regex needed??? (e.g. tabs???)
for
doc
in
common
.
load_json_docs
(
config_params
=
current_app
.
config
[
'
INVENTORY_PROVIDER_CONFIG
'
],
key_pattern
=
'
ix_public_peer:*
'
,
num_threads
=
10
):
other
=
doc
[
'
value
'
]
if
other
[
'
router
'
]
==
peer_info
[
'
router
'
]:
result
[
'
router
'
].
append
(
other
[
'
name
'
])
assert
other
[
'
description
'
]
is
not
None
# sanity: as above...
if
other
[
'
description
'
].
startswith
(
keyword
):
result
[
'
group
'
].
append
(
other
[
'
name
'
])
return
result
def
find_interfaces
(
address
)
->
Iterator
:
"""
TODO: this is probably the least efficient way of doing this
...
...
@@ -439,23 +397,20 @@ def peer_info(address_str: str) -> Response:
'
locations
'
:
[],
}
info
=
r
.
get
(
f
'
ix_public_peer:
{
address_str
}
'
)
if
info
:
info
=
info
.
decode
(
'
utf-8
'
)
info
=
json
.
loads
(
info
)
result
[
'
ix-public-peer-info
'
]
=
ix_peering_info
(
info
)
ix_peering_info
=
_ix_peering_info
(
r
,
address_str
)
if
ix_peering_info
:
result
[
'
ix-public-peer-info
'
]
=
ix_peering_info
result
[
'
locations
'
].
append
(
build_locations
(
_location_from_equipment
(
get_ims_equipment_name
(
info
[
'
router
'
]),
r
)))
get_ims_equipment_name
(
ix_peering_info
[
'
peer
'
][
'
router
'
]),
r
)))
info
=
r
.
get
(
f
'
vpn_rr_peer:
{
address_str
}
'
)
if
info
:
info
=
info
.
decode
(
'
utf-8
'
)
info
=
json
.
loads
(
info
)
result
[
'
vpn-rr-peer-info
'
]
=
info
vpn_rr_peering_info
=
_vpn_rr_peering_info
(
r
,
address_str
)
if
vpn_rr_peering_info
:
result
[
'
vpn-rr-peer-info
'
]
=
vpn_rr_peering_info
result
[
'
locations
'
].
append
(
build_locations
(
_location_from_equipment
(
get_ims_equipment_name
(
info
[
'
router
'
]),
r
)))
get_ims_equipment_name
(
vpn_rr_peering_
info
[
'
router
'
]),
r
)))
asn_group_info
=
_asn_group_info
(
r
,
address_str
)
if
asn_group_info
:
...
...
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