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