
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 12:39 AM - edited 02-22-2023 12:46 AM
Hi
I am using the following python code to connect to a bunch of devices. Right now I am doing it one by one but it takes a lot of time, is there anyway to connec to multible devices at once and have it run the commands on them in parallel?
testbed = load("empty-testbed.yaml")
for device in allDevices:
# Helper function to add devices to the testbed
dev = add_device(device.name, "ios", testbed, ip_addr=device.ip)
dev.connect(log_stdout=False, connection_timeout=10)
stp = dev.parse('show spanning-tree detail')
instances = stp['mstp']['mst_instances']
Instead of looping through the list and run the commands one by one, I just want to add all devices to the testbed and have it run the commands on all devices at once.
Solved! Go to Solution.
- Labels:
-
pyATS
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 01:30 AM
you need to use multiprocess example :
https://pubhub.devnetcloud.com/media/pyats/docs/async/multiprocessing.html
make sure you enough process when you run same time multi processs, it may freeze CPU if you overload test with limited multi process.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2023 01:30 AM
you need to use multiprocess example :
https://pubhub.devnetcloud.com/media/pyats/docs/async/multiprocessing.html
make sure you enough process when you run same time multi processs, it may freeze CPU if you overload test with limited multi process.
