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
c698abbd
Commit
c698abbd
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added id to service response, and return ordered
parent
032f60bb
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/routes/msr.py
+14
-9
14 additions, 9 deletions
inventory_provider/routes/msr.py
test/test_msr_routes.py
+21
-19
21 additions, 19 deletions
test/test_msr_routes.py
with
35 additions
and
28 deletions
inventory_provider/routes/msr.py
+
14
−
9
View file @
c698abbd
...
...
@@ -144,6 +144,7 @@ PEERING_ADDRESS_SERVICES_LIST = {
'
definitions
'
:
{
'
service
'
:
{
'
properties
'
:
{
'
id
'
:
{
'
type
'
:
'
integer
'
},
'
name
'
:
{
'
type
'
:
'
string
'
},
'
type
'
:
{
'
type
'
:
'
string
'
},
'
status
'
:
{
'
type
'
:
'
string
'
}
...
...
@@ -445,6 +446,15 @@ def _get_subnet_interfaces(address, r):
def
_get_peer_address_services
(
address
:
str
,
r
:
'
StrictRedis
'
):
def
_formatted_service
(
s
):
return
{
'
id
'
:
s
[
'
id
'
],
'
name
'
:
s
[
'
name
'
],
'
type
'
:
s
[
'
service_type
'
],
'
status
'
:
s
[
'
status
'
]
}
for
ifc_info
in
_get_subnet_interfaces
(
address
,
r
):
ims_source_equipment
=
get_ims_equipment_name
(
ifc_info
[
'
router
'
],
r
)
...
...
@@ -452,20 +462,15 @@ def _get_peer_address_services(address: str, r: 'StrictRedis'):
service_info
=
get_interface_services_and_loc
(
ims_source_equipment
,
ims_interface
,
r
)
# make a dict to de-dup the services list
services_dict
=
{}
for
s
in
service_info
.
get
(
'
services
'
,
[]):
services_dict
[
s
[
'
id
'
]]
=
{
'
name
'
:
s
[
'
name
'
],
'
type
'
:
s
[
'
service_type
'
],
'
status
'
:
s
[
'
status
'
]
}
services
=
service_info
.
get
(
'
services
'
,
[])
services
=
map
(
_formatted_service
,
services
)
services
=
sorted
(
services
,
key
=
lambda
x
:
x
[
'
name
'
])
yield
{
'
address
'
:
address
,
'
hostname
'
:
ifc_info
[
'
router
'
],
'
interface
'
:
ifc_info
[
'
interface name
'
],
'
services
'
:
list
(
services
_dict
.
values
()
)
'
services
'
:
list
(
services
)
}
...
...
This diff is collapsed.
Click to expand it.
test/test_msr_routes.py
+
21
−
19
View file @
c698abbd
...
...
@@ -139,8 +139,28 @@ def test_peerings_group_list(client, uri):
assert
response_data
# test data is non-empty
# taken from a sample splunk query
@pytest.mark.parametrize
(
'
address
'
,
[
'
62.40.127.141
'
,
'
62.40.127.139
'
])
def
test_lookup_services_for_address
(
address
,
mocked_redis
):
_redis_instance
=
_get_redis
({
'
redis
'
:
{
'
hostname
'
:
None
,
'
port
'
:
None
},
'
redis-databases
'
:
[
9
,
7
,
5
]
})
info
=
list
(
_get_peer_address_services
(
address
,
r
=
_redis_instance
))
jsonschema
.
validate
(
info
,
PEERING_ADDRESS_SERVICES_LIST
)
# sanity check to be sure we have interesting test data
assert
all
(
x
[
'
services
'
]
for
x
in
info
)
_OUTAGE_PEER_ADDRESSES
=
[
# taken from a sample splunk query result
'
83.97.93.247
'
,
'
146.48.78.13
'
,
'
185.6.36.40
'
,
...
...
@@ -244,24 +264,6 @@ _OUTAGE_PEER_ADDRESSES = [
]
@pytest.mark.parametrize
(
'
address
'
,
[
'
62.40.127.141
'
,
'
62.40.127.139
'
])
def
test_lookup_peer_services
(
address
,
mocked_redis
):
_redis_instance
=
_get_redis
({
'
redis
'
:
{
'
hostname
'
:
None
,
'
port
'
:
None
},
'
redis-databases
'
:
[
0
,
7
]
})
info
=
list
(
_get_peer_address_services
(
address
,
r
=
_redis_instance
))
jsonschema
.
validate
(
info
,
PEERING_ADDRESS_SERVICES_LIST
)
assert
all
(
x
[
'
services
'
]
for
x
in
info
)
def
test_peering_services
(
client
):
headers
=
{
'
Content-Type
'
:
'
application/json
'
}
headers
.
update
(
DEFAULT_REQUEST_HEADERS
)
...
...
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