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

add snmp interface query task

parent 34e97e64
No related branches found
No related tags found
No related merge requests found
......@@ -68,12 +68,12 @@ def walk(agent_hostname, community, base_oid):
yield {"oid": "." + str(oid), "value": val.prettyPrint()}
def get_router_interfaces(router, config):
def get_router_interfaces(hostname, community, config):
oid_map = config["oids"]
details = {}
for name, oid in oid_map.items():
details[name] = walk(router["hostname"], router["community"], oid)
details[name] = walk(hostname, community, oid)
details[name] = list(details[name])
v4IfcNames = {}
......
......@@ -5,7 +5,7 @@ import redis
from inventory_provider.tasks.app import app
from inventory_provider import config
from inventory_provider import juniper
from inventory_provider import juniper, snmp
class InventoryTask(Task):
......@@ -69,3 +69,10 @@ def juniper_refresh_interfaces(self, hostname):
"interfaces",
juniper.fetch_interfaces(hostname, InventoryTask.config["ssh"]))
@app.task(bind=InventoryTask)
def snmp_refresh_interfaces(self, hostname, community):
InventoryTask.save_key(
hostname,
"interfaces",
list(snmp.get_router_interfaces(hostname, community, InventoryTask.config)))
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