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
a5dd6ba4
Commit
a5dd6ba4
authored
6 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
move nested function to global
parent
2fe76e87
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
+28
-25
28 additions, 25 deletions
inventory_provider/routes/classifier.py
with
28 additions
and
25 deletions
inventory_provider/routes/classifier.py
+
28
−
25
View file @
a5dd6ba4
...
...
@@ -46,36 +46,39 @@ def get_trap_metadata(source_equipment, interface):
return
Response
(
result
,
mimetype
=
"
application/json
"
)
@routes.route
(
"
/peer-info/<address>
"
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
def
peer_info
(
address
):
def
ix_peering_group
(
ix_public_peer_info
):
"""
TODO: this is probably the least efficient way of doing this
(if it
'
s a problem, pre-compute these lists)
def
_related_ix_peers
(
ix_public_peer_info
):
"""
TODO: this is probably the least efficient way of doing this
(if it
'
s a problem, pre-compute these lists)
:param ix_public_peer_info: ix public peer info loaded for address
:return:
"""
:param ix_public_peer_info: ix public peer info loaded for address
:return:
"""
address
=
ix_public_peer_info
[
'
name
'
]
protocol
=
type
(
ipaddress
.
ip_address
(
address
)).
__name__
protocol
=
type
(
ipaddress
.
ip_address
(
address
)).
__name__
description
=
ix_public_peer_info
[
'
description
'
]
assert
description
is
not
None
# sanity: at least empty string
keyword
=
description
.
split
(
'
'
)[
0
]
# regex needed??? (e.g. tabs???)
r
=
common
.
get_redis
()
description
=
ix_public_peer_info
[
'
description
'
]
assert
description
is
not
None
# sanity: at least empty string
keyword
=
description
.
split
(
'
'
)[
0
]
# regex needed??? (e.g. tabs???)
for
k
in
r
.
keys
(
'
ix_public_peer:*
'
):
peer
=
r
.
get
(
k
.
decode
(
'
utf-8
'
)).
decode
(
'
utf-8
'
)
peer
=
json
.
loads
(
peer
)
assert
peer
[
'
description
'
]
is
not
None
# sanity: as above...
if
not
peer
[
'
description
'
].
startswith
(
keyword
):
continue
peer_address
=
ipaddress
.
ip_address
(
peer
[
'
name
'
])
if
protocol
==
type
(
peer_address
).
__name__
:
yield
peer
[
'
name
'
]
r
=
common
.
get_redis
()
for
k
in
r
.
keys
(
'
ix_public_peer:*
'
):
peer
=
r
.
get
(
k
.
decode
(
'
utf-8
'
)).
decode
(
'
utf-8
'
)
peer
=
json
.
loads
(
peer
)
assert
peer
[
'
description
'
]
is
not
None
# sanity: as above...
if
not
peer
[
'
description
'
].
startswith
(
keyword
):
continue
peer_address
=
ipaddress
.
ip_address
(
peer
[
'
name
'
])
if
protocol
==
type
(
peer_address
).
__name__
:
yield
peer
[
'
name
'
]
@routes.route
(
"
/peer-info/<address>
"
,
methods
=
[
'
GET
'
,
'
POST
'
])
@common.require_accepts_json
def
peer_info
(
address
):
r
=
common
.
get_redis
()
...
...
@@ -86,7 +89,7 @@ def peer_info(address):
info
=
info
.
decode
(
'
utf-8
'
)
result
[
'
ix-public-peer-info
'
]
=
json
.
loads
(
info
)
result
[
'
ix-public-peer-group
'
]
=
list
(
_related_ix_peers
(
result
[
'
ix-public-peer-info
'
]))
ix_peering_group
(
result
[
'
ix-public-peer-info
'
]))
info
=
r
.
get
(
'
vpn_rr_peer:%s
'
%
address
)
if
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