reboot_network_device command not working inside while loop

CITS
Just browsing

reboot_network_device command not working inside while loop

I have been trying to get this script running that will reboot all access points in an organization nightly. All code for discovering access points works correctly. At the end I have a loop to go through all the discovered APs and issue the reboot command to each one.

 

while n < len(serials):
#print(n+1, ' - ', serials[n])
reboot['network_id'] = rebootnetids[n]
reboot['serial'] = serials[n]
devices_controller.reboot_network_device(reboot)
n += 1
#print(reboot)

The script will run with no errors, and the lines I have commented out here will print all the correct info when not commented. I have also tried just a single reboot command for a single device outside the while loop and that worked. It seems putting it inside a loop breaks the command. What am I missing?

2 Replies 2
PhilipDAth
Kind of a big deal
Kind of a big deal

Try wrapping a:

try:
   ...
except APIException as e: 
   print(e)

 

Around it and see if any errors are thrown. 

I revised my code

 

while n < len(serials):
print(n+1, ' - ', serials[n])
reboot['network_id'] = rebootnetids[n]
reboot['serial'] = serials[n]
try:
devices_controller.reboot_network_device(reboot)
except APIException as e:
print(e)
n += 1
print(reboot)

 The code executes the same. No exceptions thrown, but still no reboots to be seen on the dashboard.

Get notified when there are additional replies to this discussion.