Using various methods, I can get a list of VLAN on a switch port. The list looks like the following:
“vlans”: “1,134,170,175,540,605,819-820,911-912,930-932,945,952,955,959-960,1200-1201,1400”
I would like to check to see if VLAN 931 is in the list. In this case its between 930-932 in the list. Is there a filter or function that I can use to see if its in the list?
Is there some other way I can get this info?
For a single VLAN number I can use when: 'item in vlans" if in a loop but 'in" looks for exact match.
Using various methods, I can get a list of VLAN on a switch port. The list looks like the following:
"vlans": "1,134,170,175,540,605,819-820,911-912,930-932,945,952,955,959-960,1200-1201,1400"
I would like to check to see if VLAN 931 is in the list. In this case its between 930-932 in the list. Is there a filter or function that I can use to see if its in the list?
Is there some other way I can get this info?
For a single VLAN number I can use when: 'item in vlans" if in a loop but 'in" looks for exact match.
It is probably happening because your switch does not return a
nice list. 911-912 is a single entry in your list. I would first
convert entries like 930-932 into 930,931,932.
You can create a "real" list of all the vlans that this range-list contains.
Once that is done it's trivial to do your check: