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
e8ecb39a
Commit
e8ecb39a
authored
3 years ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
added ?no-lab param to /poller/interfaces
parent
bc4eea18
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inventory_provider/routes/poller.py
+10
-1
10 additions, 1 deletion
inventory_provider/routes/poller.py
test/test_general_poller_routes.py
+15
-0
15 additions, 0 deletions
test/test_general_poller_routes.py
with
25 additions
and
1 deletion
inventory_provider/routes/poller.py
+
10
−
1
View file @
e8ecb39a
...
...
@@ -402,7 +402,9 @@ def _load_interfaces(hostname):
base_key_pattern
=
f
'
netconf:
{
hostname
}
*
'
if
hostname
else
'
netconf:*
'
yield
from
_load_docs
(
base_key_pattern
)
yield
from
_load_docs
(
f
'
lab:
{
base_key_pattern
}
'
)
no_lab
=
common
.
get_bool_request_arg
(
'
no-lab
'
,
False
)
if
not
no_lab
:
yield
from
_load_docs
(
f
'
lab:
{
base_key_pattern
}
'
)
def
_add_bundle_parents
(
interfaces
,
hostname
=
None
):
...
...
@@ -495,6 +497,9 @@ def interfaces(hostname=None):
which returns information for either all interfaces
or those on the requested hostname.
The optional `no-lab` parameter omits lab routers
if it
'
s truthiness evaluates to True.
The response is a list of information for all
interfaces that should be polled, including service
information and snmp information.
...
...
@@ -509,6 +514,10 @@ def interfaces(hostname=None):
cache_key
=
f
'
classifier-cache:poller-interfaces:
{
hostname
}
'
\
if
hostname
else
'
classifier-cache:poller-interfaces:all
'
no_lab
=
common
.
get_bool_request_arg
(
'
no-lab
'
,
False
)
if
no_lab
:
cache_key
=
f
'
{
cache_key
}
:no_lab
'
r
=
common
.
get_current_redis
()
result
=
_ignore_cache_or_retrieve
(
request
,
cache_key
,
r
)
...
...
This diff is collapsed.
Click to expand it.
test/test_general_poller_routes.py
+
15
−
0
View file @
e8ecb39a
...
...
@@ -20,6 +20,21 @@ def test_get_all_interfaces(client):
response_routers
=
{
ifc
[
'
router
'
]
for
ifc
in
response_data
}
assert
len
(
response_routers
)
>
1
,
\
'
there should data from be lots of routers
'
assert
any
(
'
.lab.
'
in
name
for
name
in
response_routers
)
def
test_get_all_interfaces_no_lab
(
client
):
rv
=
client
.
get
(
'
/poller/interfaces?no-lab=1
'
,
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
,
poller
.
INTERFACE_LIST_SCHEMA
)
response_routers
=
{
ifc
[
'
router
'
]
for
ifc
in
response_data
}
assert
len
(
response_routers
)
>
1
,
\
'
there should data from be lots of routers
'
assert
all
(
'
.lab.
'
not
in
name
for
name
in
response_routers
)
def
test_all_router_interface_speeds
(
client
):
...
...
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