-
Notifications
You must be signed in to change notification settings - Fork 0
Netdev
sjherrick edited this page Nov 5, 2019
·
1 revision
router = {
'username': USERNAME,
'password': PASSWORD,
'host': 192.168.0.1,
'device_type': 'cisco_ios'
}
async with netdev.create(**router) as host:
output = await host.send_command('sh ip int br')
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
sema = asyncio.BoundedSemaphore(value=40)
tasks = [task(router, sema) for router in routers]
results = loop.run_until_complete(
asyncio.gather(*tasks)
)
async def task(router, sema):
# Create netdev object and run commands
try:
async with sema, netdev.create(**mdf) as host:
output = await host.send_command('sh ip int br')
return output, None
except Exception as e:
return None, str(e)