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

added a service category enum for readability

parent 54d3cc18
No related branches found
No related tags found
No related merge requests found
import enum
import json
import logging
import os
......@@ -654,14 +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'):
yield 'mdvpn'
yield PollerServiceCategory.MDVPN
if 'LHCONE' in ifc['description']:
yield 'lhcone'
yield PollerServiceCategory.LHCONE
update_callback('loading all known interfaces')
interfaces = data.build_service_interface_user_list(InventoryTask.config)
......@@ -673,9 +679,9 @@ def _build_service_category_interface_list(update_callback=lambda s: None):
rp = r.pipeline()
for ifc in interfaces:
for service_type in _classify(ifc):
for service_category in _classify(ifc):
rp.set(
f'interface-services:{service_type}'
f'interface-services:{service_category.value}'
f':{ifc["router"]}:{ifc["interface"]}',
json.dumps(ifc))
......
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