Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow handling of vlan ID values containing more then one digit. #460

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/460-stp-long-int-vlan-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- sonic_stp - Change the criteria for converting vlans and vlan ranges to handle vlan IDs with more than one digit (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/460).
6 changes: 3 additions & 3 deletions plugins/module_utils/network/sonic/config/stp/stp.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,10 @@ def convert_vlans_list(self, vlans):
converted_vlans = []

for vlan in vlans:
if len(vlan) == 1:
converted_vlans.append(int(vlan))
else:
if '-' in vlan:
converted_vlans.append(vlan.replace('-', '..'))
else:
converted_vlans.append(int(vlan))

return converted_vlans

Expand Down
48 changes: 24 additions & 24 deletions tests/regression/roles/sonic_stp/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ tests:
- mst_id: 1
bridge_priority: 2048
vlans:
- 1
- 301
interfaces:
- intf_name: '{{ interface1 }}'
cost: 60
port_priority: 65
- mst_id: 2
bridge_priority: 1024
vlans:
- 2
- 302
interfaces:
- intf_name: '{{ interface2 }}'
cost: 50
Expand All @@ -82,7 +82,7 @@ tests:
- mst_id: 1
bridge_priority: 1024
vlans:
- 2-3
- 302-303
- mst_id: 2
interfaces:
- intf_name: '{{ interface2 }}'
Expand Down Expand Up @@ -118,15 +118,15 @@ tests:
mst_instances:
- mst_id: 1
vlans:
- 1
- 301
interfaces:
- intf_name: '{{ interface1 }}'
cost: 70
port_priority: 75
- mst_id: 2
bridge_priority: 2048
vlans:
- 1-3
- 301-303
interfaces:
- intf_name: '{{ interface2 }}'
cost: 52
Expand All @@ -150,7 +150,7 @@ tests:
- mst_id: 2
bridge_priority: 2048
vlans:
- 2
- 302
interfaces:
- intf_name: '{{ interface2 }}'
cost: 52
Expand All @@ -176,7 +176,7 @@ tests:
fwd_delay: 20
bridge_priority: 4096
pvst:
- vlan_id: 1
- vlan_id: 301
hello_time: 4
max_age: 6
fwd_delay: 8
Expand All @@ -185,7 +185,7 @@ tests:
- intf_name: '{{ interface1 }}'
cost: 10
port_priority: 50
- vlan_id: 2
- vlan_id: 302
hello_time: 5
max_age: 7
fwd_delay: 9
Expand All @@ -202,12 +202,12 @@ tests:
state: replaced
input:
pvst:
- vlan_id: 1
- vlan_id: 301
hello_time: 7
max_age: 8
fwd_delay: 9
bridge_priority: 8192
- vlan_id: 2
- vlan_id: 302
interfaces:
- intf_name: '{{ interface2 }}'
cost: 2
Expand All @@ -220,12 +220,12 @@ tests:
state: merged
input:
pvst:
- vlan_id: 1
- vlan_id: 301
interfaces:
- intf_name: '{{ interface1 }}'
cost: 11
port_priority: 51
- vlan_id: 2
- vlan_id: 302
hello_time: 3
max_age: 9
fwd_delay: 11
Expand All @@ -235,15 +235,15 @@ tests:
state: deleted
input:
pvst:
- vlan_id: 1
- vlan_id: 301
hello_time: 7
max_age: 8
fwd_delay: 9
bridge_priority: 8192
interfaces:
- intf_name: '{{ interface1 }}'
cost: 11
- vlan_id: 2
- vlan_id: 302
interfaces:
- intf_name: '{{ interface2 }}'
- intf_name: '{{ interface3 }}'
Expand All @@ -268,7 +268,7 @@ tests:
fwd_delay: 20
bridge_priority: 4096
rapid_pvst:
- vlan_id: 1
- vlan_id: 301
hello_time: 4
max_age: 6
fwd_delay: 8
Expand All @@ -277,7 +277,7 @@ tests:
- intf_name: '{{ interface1 }}'
cost: 10
port_priority: 50
- vlan_id: 2
- vlan_id: 302
hello_time: 5
max_age: 7
fwd_delay: 9
Expand All @@ -294,12 +294,12 @@ tests:
state: replaced
input:
rapid_pvst:
- vlan_id: 1
- vlan_id: 301
hello_time: 7
max_age: 8
fwd_delay: 9
bridge_priority: 8192
- vlan_id: 2
- vlan_id: 302
interfaces:
- intf_name: '{{ interface2 }}'
cost: 2
Expand All @@ -312,12 +312,12 @@ tests:
state: merged
input:
rapid_pvst:
- vlan_id: 1
- vlan_id: 301
interfaces:
- intf_name: '{{ interface1 }}'
cost: 11
port_priority: 51
- vlan_id: 2
- vlan_id: 302
hello_time: 3
max_age: 9
fwd_delay: 11
Expand All @@ -327,7 +327,7 @@ tests:
state: deleted
input:
rapid_pvst:
- vlan_id: 1
- vlan_id: 301
hello_time: 7
max_age: 8
fwd_delay: 9
Expand All @@ -336,7 +336,7 @@ tests:
- intf_name: '{{ interface1 }}'
cost: 11
port_priority: 51
- vlan_id: 2
- vlan_id: 302
interfaces:
- intf_name: '{{ interface2 }}'
- intf_name: '{{ interface3 }}'
Expand Down Expand Up @@ -507,15 +507,15 @@ tests:
- mst_id: 1
bridge_priority: 2048
vlans:
- 1
- 301
interfaces:
- intf_name: '{{ interface1 }}'
cost: 60
port_priority: 65
- mst_id: 2
bridge_priority: 1024
vlans:
- 2
- 302
interfaces:
- intf_name: '{{ interface2 }}'
cost: 50
Expand Down
18 changes: 9 additions & 9 deletions tests/regression/roles/sonic_stp/tasks/preparation_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
- name: Add VLANs
sonic_vlans:
config:
- vlan_id: 1
- vlan_id: 2
- vlan_id: 3
- vlan_id: 4
- vlan_id: 5
- vlan_id: 6
- vlan_id: 301
- vlan_id: 302
- vlan_id: 303
- vlan_id: 304
- vlan_id: 305
- vlan_id: 306
state: merged
ignore_errors: yes

Expand All @@ -34,14 +34,14 @@
- name: '{{ interface1 }}'
trunk:
allowed_vlans:
- vlan: 1-3
- vlan: 301-303
- name: '{{ interface2 }}'
trunk:
allowed_vlans:
- vlan: 1-3
- vlan: 301-303
- name: '{{ interface3 }}'
trunk:
allowed_vlans:
- vlan: 1-3
- vlan: 301-303
state: merged
ignore_errors: yes
Loading
Loading