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

added import_unmanaged_interfaces task

parent 14b1680f
No related branches found
No related tags found
No related merge requests found
......@@ -117,6 +117,40 @@ def update_interfaces_to_services(self):
logger.debug('<<< update_interfaces_to_services')
@app.task(base=InventoryTask, bind=True)
def import_unmanaged_interfaces(self):
logger.debug('>>> import_unmanaged_interfaces')
def _convert(d):
# the config file keys are more readable than
# the keys used in redis
return {
'name': d['address'],
'interface address': d['network'],
'interface name': d['interface'],
'router': d['router']
}
interfaces = [
_convert(ifc) for ifc
in InventoryTask.config.get('unmanaged-interfaces', [])
]
if interfaces:
r = get_next_redis(InventoryTask.config)
rp = r.pipeline()
for ifc in interfaces:
rp.set(
f'reverse_interface_addresses:{ifc["name"]}',
json.dumps(ifc))
rp.set(
f'subnets:{ifc["interface address"]}',
json.dumps([ifc]))
rp.execute()
logger.debug('<<< import_unmanaged_interfaces')
@app.task(base=InventoryTask, bind=True)
def update_access_services(self):
logger.debug('>>> update_access_services')
......@@ -533,7 +567,8 @@ def launch_refresh_cache_all(config):
subtasks = [
update_equipment_locations.apply_async(),
update_lg_routers.apply_async(),
update_access_services.apply_async()
update_access_services.apply_async(),
import_unmanaged_interfaces.apply_async()
]
for hostname in _derive_router_hostnames(config):
logger.debug('queueing router refresh jobs for %r' % hostname)
......
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