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

Finished feature multi-valued-poller-categories.

parents 2770eefe 4b6cd012
No related branches found
No related tags found
No related merge requests found
import enum
import json
import logging
import os
......@@ -654,15 +655,19 @@ def refresh_finalizer(self, pending_task_ids_json):
self.log_info('latched current/next dbs')
class PollerServiceCategory(str, enum.Enum):
MDVPN = 'mdvpn'
LHCONE = 'lhcone'
@log_task_entry_and_exit
def _build_service_category_interface_list(update_callback=lambda s: None):
def _classify(ifc):
if ifc['description'].startswith('SRV_MDVPN'):
return 'mdvpn'
yield PollerServiceCategory.MDVPN
if 'LHCONE' in ifc['description']:
return 'lhcone'
return None
yield PollerServiceCategory.LHCONE
update_callback('loading all known interfaces')
interfaces = data.build_service_interface_user_list(InventoryTask.config)
......@@ -674,13 +679,11 @@ def _build_service_category_interface_list(update_callback=lambda s: None):
rp = r.pipeline()
for ifc in interfaces:
service_type = _classify(ifc)
if not service_type:
continue
rp.set(
f'interface-services:{service_type}'
f':{ifc["router"]}:{ifc["interface"]}',
json.dumps(ifc))
for service_category in _classify(ifc):
rp.set(
f'interface-services:{service_category.value}'
f':{ifc["router"]}:{ifc["interface"]}',
json.dumps(ifc))
rp.execute()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment