Skip to content
Snippets Groups Projects
Commit 147b003c authored by Robert Latta's avatar Robert Latta
Browse files

added task logging for failed netconf load

parent 4f0d0f77
No related branches found
No related tags found
No related merge requests found
...@@ -1264,7 +1264,9 @@ def reload_lab_router_config_chorded(self, hostname): ...@@ -1264,7 +1264,9 @@ def reload_lab_router_config_chorded(self, hostname):
@log_task_entry_and_exit @log_task_entry_and_exit
def reload_router_config_chorded(self, hostname): def reload_router_config_chorded(self, hostname):
self.log_info(f'loading netconf data for {hostname} RL') self.log_info(f'loading netconf data for {hostname} RL')
netconf_str = retrieve_and_persist_netconf_config(hostname) netconf_str = retrieve_and_persist_netconf_config(
hostname, self.log_warning)
netconf_doc = etree.fromstring(netconf_str) netconf_doc = etree.fromstring(netconf_str)
# clear cached classifier responses for this router, and # clear cached classifier responses for this router, and
...@@ -1291,7 +1293,8 @@ def reload_router_config_chorded(self, hostname): ...@@ -1291,7 +1293,8 @@ def reload_router_config_chorded(self, hostname):
# new # new
def retrieve_and_persist_netconf_config(hostname, lab=False): def retrieve_and_persist_netconf_config(
hostname, lab=False, update_callback=lambda s: None):
redis_key = f'netconf:{hostname}' redis_key = f'netconf:{hostname}'
if lab: if lab:
redis_key = f'lab:{redis_key}' redis_key = f'lab:{redis_key}'
...@@ -1303,6 +1306,7 @@ def retrieve_and_persist_netconf_config(hostname, lab=False): ...@@ -1303,6 +1306,7 @@ def retrieve_and_persist_netconf_config(hostname, lab=False):
except (ConnectionError, juniper.NetconfHandlingError): except (ConnectionError, juniper.NetconfHandlingError):
msg = f'error loading netconf data from {hostname}' msg = f'error loading netconf data from {hostname}'
logger.exception(msg) logger.exception(msg)
update_callback(msg)
r = get_current_redis(InventoryTask.config) r = get_current_redis(InventoryTask.config)
netconf_str = r.get(redis_key) netconf_str = r.get(redis_key)
...@@ -1311,6 +1315,7 @@ def retrieve_and_persist_netconf_config(hostname, lab=False): ...@@ -1311,6 +1315,7 @@ def retrieve_and_persist_netconf_config(hostname, lab=False):
f'netconf error with {hostname}' f'netconf error with {hostname}'
f' and no cached netconf data found') f' and no cached netconf data found')
logger.info(f'Returning cached netconf data for {hostname}') logger.info(f'Returning cached netconf data for {hostname}')
update_callback(f'Returning cached netconf data for {hostname}')
r = get_next_redis(InventoryTask.config) r = get_next_redis(InventoryTask.config)
r.set(redis_key, netconf_str) r.set(redis_key, netconf_str)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment