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

turn _classify into a generator

parent 2770eefe
No related branches found
No related tags found
No related merge requests found
......@@ -659,10 +659,9 @@ def _build_service_category_interface_list(update_callback=lambda s: None):
def _classify(ifc):
if ifc['description'].startswith('SRV_MDVPN'):
return 'mdvpn'
yield 'mdvpn'
if 'LHCONE' in ifc['description']:
return 'lhcone'
return None
yield 'lhcone'
update_callback('loading all known interfaces')
interfaces = data.build_service_interface_user_list(InventoryTask.config)
......@@ -674,13 +673,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_type in _classify(ifc):
rp.set(
f'interface-services:{service_type}'
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.
Please register or to comment