diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index ee817b29c3d1084490b6316e3d42f33975347696..96917adf34987378f6399ef0670e04ee9aaf1ff5 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -249,7 +249,7 @@ def load_netconf_data(hostname): r = get_redis(InventoryTask.config) netconf = r.get('netconf:' + hostname) if not netconf: - return None + raise InventoryTaskError('no netconf data found for %r' % hostname) return etree.fromstring(netconf.decode('utf-8')) @@ -313,20 +313,19 @@ def reload_router_config(self, hostname): # get the timestamp for the current netconf data current_netconf_timestamp = None - netconf_doc = load_netconf_data(hostname) - if netconf_doc: + try: + netconf_doc = load_netconf_data(hostname) current_netconf_timestamp \ = juniper.netconf_changed_timestamp(netconf_doc) logger.debug( 'current netconf timestamp: %r' % current_netconf_timestamp) + except InventoryTaskError as e: + pass # ok at this point if not found # load new netconf data netconf_refresh_config.apply(args=[hostname]) netconf_doc = load_netconf_data(hostname) - if netconf_doc is None: - raise InventoryTaskError( - 'failure loading netconf data for %r' % hostname) # return if new timestamp is the same as the original timestamp new_netconf_timestamp = juniper.netconf_changed_timestamp(netconf_doc)