cancel
Showing results for 
Search instead for 
Did you mean: 

Looping stops if the number of devices selected is above 9

Looping stops if the number of devices selected is above 9

Nealo
New Contributor
Hello,

I've been trying to do a looping workflow where all devices do something one after the other, and not all at the same time. The objective behind that is to make two lists of devices, one where they have a specific VLAN, and one where it doesn't. With those two lists, I could make signals saying which are the devices without the wanted VLAN, and still continue with the rest of the workflow.

For that, I came up with a loop, incrementing a number until it reaches the number of selected devices as the above limit.
But, If the number of selected devices is greater or equal than 10, the loop doesn't work as intended anymore, and it stops after 2 loop turns.

da9ed46ee2c84feda68e97164e858cf3_8336a71e-7b7a-4e12-9275-a046d01bed51.png


I added the workflow variables number and maxNumber, as Number, and devicesList as a String.

The script named Set variables as the following code :
code:
# set the initial value to 0
emc_results.put("number", "0")


# Get the list of devices, only separated by a coma
devicesListRaw = emc_vars["devices"].encode('ascii', 'ignore')
devicesListRaw = devicesListRaw.replace("[", "")
devicesListRaw = devicesListRaw.replace("]", "")
devicesListRaw = devicesListRaw.replace(" ", "")
emc_results.put("devicesList", devicesListRaw)


# Set the maximum loop value to the number of selected devices
emc_results.put("maxNumber", str(len(devicesListRaw.split(","))))


The script named Increment number as the following code :
code:
# Get values from the workflow variables
devicesListRaw = emc_vars["devicesList"].encode('ascii', 'encode')
deviceIP = emc_vars["deviceIP"].encode('ascii', 'ignore')
number = int(emc_vars["number"].encode('ascii', 'ignore'))


# If the device's IP is in the list of all devices (as a string),
# increment number by 1.
if deviceIP in devicesListRaw:
print("Last number is : " + str(number))
print("Max number is : " + str(maxNumber))
number += 1
# Set the new value of number into the variable
emc_results.put("number", str(number))


Both conditions are on Custom :
code:
number < maxNumber       and         number >= maxNumber


The results of 9 and 10 devices are the following :
code:
       9 devices        |         10 devices

Last number is : 8 | Last number is : 1
Max number is : 9 | Max number is : 10



Would anyone have an idea about why it's happening ?

The version running is the : Extreme Management Center 8.2.4.55
0 REPLIES 0
GTM-P2G8KFN