Skip to content
Snippets Groups Projects
Commit e8ecb39a authored by Erik Reid's avatar Erik Reid
Browse files

added ?no-lab param to /poller/interfaces

parent bc4eea18
Branches
Tags
No related merge requests found
......@@ -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)
......
......@@ -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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment