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
0dc8745e
Commit
0dc8745e
authored
4 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
return asn group members with peer-info
parent
52623546
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/classifier.py
+47
-0
47 additions, 0 deletions
inventory_provider/routes/classifier.py
with
47 additions
and
0 deletions
inventory_provider/routes/classifier.py
+
47
−
0
View file @
0dc8745e
...
...
@@ -243,6 +243,49 @@ def get_juniper_link_info(source_equipment, interface):
return
Response
(
result
,
mimetype
=
'
application/json
'
)
def
_asn_group_info
(
redis
,
address
):
"""
:param redis: a redis db connection
:param address: the remote peer address
:return:
"""
try
:
address
=
ipaddress
.
ip_address
(
address
).
exploded
except
ValueError
:
raise
ClassifierProcessingError
(
f
'
unable to parse
{
address
}
as an ip address
'
)
all_peerings
=
redis
.
get
(
f
'
juniper-peerings:remote:
{
address
}
'
)
if
not
all_peerings
:
return
None
all_peerings
=
json
.
loads
(
all_peerings
.
decode
(
'
utf-8
'
))
all_asn
=
{
p
[
'
remote-asn
'
]
for
p
in
all_peerings
if
'
remote-asn
'
in
p
}
if
not
all_asn
:
return
None
peer_asn
=
all_asn
.
pop
()
if
all_asn
:
logger
.
error
(
f
'
found multiple asn
''
s for {address},
'
f
'
using
{
peer_asn
}
and ignoring
{
all_asn
}
'
)
peerings_this_asn
=
redis
.
get
(
f
'
juniper-peerings:peer-asn:
{
peer_asn
}
'
)
if
not
peerings_this_asn
:
logger
.
error
(
f
'
internal data corruption, no peerings found for asn
{
peer_asn
}
'
)
return
None
peerings_this_asn
=
json
.
loads
(
peerings_this_asn
.
decode
(
'
utf-8
'
))
return
{
'
asn
'
:
peer_asn
,
'
peers
'
:
[
{
'
router
'
:
p
[
'
hostname
'
],
'
address
'
:
p
[
'
address
'
]}
for
p
in
peerings_this_asn
]
}
def
_vpn_rr_peering_info
(
redis
,
address
):
"""
:param redis: a redis db connection
...
...
@@ -457,6 +500,10 @@ def peer_info(address):
result
[
'
locations
'
]
+=
_locations_from_router
(
vpn_rr_peering_info
[
'
router
'
])
asn_group_info
=
_asn_group_info
(
r
,
address
)
if
asn_group_info
:
result
[
'
asn
'
]
=
asn_group_info
interfaces
=
list
(
find_interfaces_and_services
(
address
))
if
interfaces
:
result
[
'
interfaces
'
]
=
interfaces
...
...
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