diff --git a/inventory_provider/routes/jobs.py b/inventory_provider/routes/jobs.py index db71dfe21f7d7827927532a8d166a84e4305ef68..a3f3925f5abf21e72e48e9ad87199fb805c19976 100644 --- a/inventory_provider/routes/jobs.py +++ b/inventory_provider/routes/jobs.py @@ -15,13 +15,23 @@ def update(): config = current_app.config["INVENTORY_PROVIDER_CONFIG"] for r in config["routers"]: - task_logger.info("fetching router details for: %r" % r) - task_logger.debug('launching task: ' - 'inventory_provider' - '.tasks.worker.netconf_refresh_config' - '(%s)' % r['hostname']) + + task_logger.info("fetching details for: %r" % r) + + task_logger.debug( + 'launching task: ' + 'inventory_provider.tasks.worker.netconf_refresh_config' + '(%s)' % r['hostname']) app.send_task( 'inventory_provider.tasks.worker.netconf_refresh_config', args=[r["hostname"]]) + task_logger.debug( + 'launching task: ' + 'inventory_provider.tasks.worker.snmp_refresh_interfaces' + '(%s)' % r['hostname']) + app.send_task( + 'inventory_provider.tasks.worker.snmp_refresh_interfaces', + args=[r["hostname"], r["community"]]) + return Response("OK") diff --git a/inventory_provider/tasks/worker.py b/inventory_provider/tasks/worker.py index b450f560b71669e837e6b699cd566378399df9ea..4f83d159323c175f4e1ff99e6ae199f20397d51e 100644 --- a/inventory_provider/tasks/worker.py +++ b/inventory_provider/tasks/worker.py @@ -51,7 +51,7 @@ class InventoryTask(Task): InventoryTask.save_key( hostname, key, - etree.tostring(data, encoding='utf-8')) + etree.tostring(data, encoding='unicode')) class WorkerArgs(bootsteps.Step): @@ -74,28 +74,28 @@ app.user_options['worker'].add(worker_args) app.steps['worker'].add(WorkerArgs) -@app.task(bind=InventoryTask) -def juniper_refresh_bgp(self, hostname): - InventoryTask.save_key_json( - hostname, - "bgp", - juniper.fetch_bgp_config(hostname, InventoryTask.config["ssh"])) - - -@app.task(bind=InventoryTask) -def juniper_refresh_vrr(self, hostname): - InventoryTask.save_key_json( - hostname, - "vrr", - juniper.fetch_vrr_config(hostname, InventoryTask.config["ssh"])) - - -@app.task(bind=InventoryTask) -def juniper_refresh_interfaces(self, hostname): - InventoryTask.save_key_json( - hostname, - "interfaces", - juniper.fetch_interfaces(hostname, InventoryTask.config["ssh"])) +# @app.task(bind=InventoryTask) +# def juniper_refresh_bgp(self, hostname): +# InventoryTask.save_key_json( +# hostname, +# "bgp", +# juniper.fetch_bgp_config(hostname, InventoryTask.config["ssh"])) +# +# +# @app.task(bind=InventoryTask) +# def juniper_refresh_vrr(self, hostname): +# InventoryTask.save_key_json( +# hostname, +# "vrr", +# juniper.fetch_vrr_config(hostname, InventoryTask.config["ssh"])) +# +# +# @app.task(bind=InventoryTask) +# def juniper_refresh_interfaces(self, hostname): +# InventoryTask.save_key_json( +# hostname, +# "interfaces", +# juniper.fetch_interfaces(hostname, InventoryTask.config["ssh"])) @app.task(bind=InventoryTask) @@ -115,4 +115,3 @@ def netconf_refresh_config(self, hostname): hostname, "netconf", netconf.load_config(hostname, InventoryTask.config["ssh"])) -