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

get basic info from lab routers

parent e5984519
No related branches found
No related tags found
No related merge requests found
......@@ -108,6 +108,10 @@ CONFIG_SCHEMA = {
"items": {"type": "integer"}
},
"managed-routers": {"type": "string"},
"lab-routers": {
"type": "array",
"items": {"type": "string"}
},
"unmanaged-interfaces": {
"type": "array",
"items": {"$ref": "#/definitions/interface-address"}
......
......@@ -469,6 +469,32 @@ def refresh_juniper_interface_list(hostname, netconf):
rp.execute()
@app.task(base=InventoryTask, bind=True, name='reload_router_config')
@log_task_entry_and_exit
def reload_lab_router_config(self, hostname):
self.log_info(f'loading netconf data for lab {hostname}')
# load new netconf data, in this thread
netconf_refresh_config.apply(args=[hostname])
netconf_doc = load_netconf_data(hostname)
# load snmp indexes
community = juniper.snmp_community_string(netconf_doc)
if not community:
raise InventoryTaskError(
f'error extracting community string for {hostname}')
else:
self.log_info(f'refreshing snmp interface indexes for {hostname}')
logical_systems = juniper.logical_systems(netconf_doc)
# load snmp data, in this thread
snmp_refresh_interfaces.apply(
args=[hostname, community, logical_systems])
self.log_info(f'updated configuration for lab {hostname}')
@app.task(base=InventoryTask, bind=True, name='reload_router_config')
@log_task_entry_and_exit
def reload_router_config(self, hostname):
......@@ -483,6 +509,8 @@ def reload_router_config(self, hostname):
logger.debug(
'current netconf timestamp: %r' % current_netconf_timestamp)
except InventoryTaskError:
# NOTE: should always reach here,
# since we always erase everything before starting
pass # ok at this point if not found
# load new netconf data, in this thread
......@@ -562,6 +590,11 @@ def internal_refresh_phase_2(self):
logger.debug('queueing router refresh jobs for %r' % hostname)
subtasks.append(reload_router_config.apply_async(args=[hostname]))
lab_routers = InventoryTask.config.get('lab-routers', [])
for hostname in lab_routers:
logger.debug('queueing router refresh jobs for lab %r' % hostname)
subtasks.append(reload_lab_router_config.apply_async(args=[hostname]))
pending_task_ids = [x.id for x in subtasks]
refresh_finalizer.apply_async(args=[json.dumps(pending_task_ids)])
......
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