Fix IOS_VLANS override operation for new VLANs (#63624)
* fix vlans override state * adding code comment
This commit is contained in:
parent
684e70c8d7
commit
4f2665810f
5 changed files with 26 additions and 2 deletions
|
@ -146,16 +146,28 @@ class Vlans(ConfigBase):
|
|||
"""
|
||||
commands = []
|
||||
|
||||
want_local = want
|
||||
for each in have:
|
||||
for every in want:
|
||||
count = 0
|
||||
for every in want_local:
|
||||
if each['vlan_id'] == every['vlan_id']:
|
||||
break
|
||||
count += 1
|
||||
else:
|
||||
# We didn't find a matching desired state, which means we can
|
||||
# pretend we recieved an empty desired state.
|
||||
commands.extend(self._clear_config(every, each, state))
|
||||
continue
|
||||
commands.extend(self._set_config(every, each))
|
||||
# as the pre-existing VLAN are now configured by
|
||||
# above set_config call, deleting the respective
|
||||
# VLAN entry from the want_local list
|
||||
del want_local[count]
|
||||
|
||||
# Iterating through want_local list which now only have new VLANs to be
|
||||
# configured
|
||||
for each in want_local:
|
||||
commands.extend(self._set_config(each, dict()))
|
||||
|
||||
return commands
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@
|
|||
no vlan 10
|
||||
no vlan 20
|
||||
no vlan 30
|
||||
no vlan 40
|
||||
when: ansible_net_version != "15.6(2)T"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
vlan_id: 10
|
||||
state: active
|
||||
shutdown: disabled
|
||||
remote_span: 10
|
||||
remote_span: True
|
||||
- name: Vlan_20
|
||||
vlan_id: 20
|
||||
mtu: 610
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
- name: VLAN_10
|
||||
vlan_id: 10
|
||||
mtu: 1000
|
||||
- name: VLAN_40
|
||||
vlan_id: 40
|
||||
mtu: 850
|
||||
state: overridden
|
||||
register: result
|
||||
|
||||
|
|
|
@ -228,6 +228,9 @@ overridden:
|
|||
- "mtu 1000"
|
||||
- "no vlan 20"
|
||||
- "no vlan 30"
|
||||
- "vlan 40"
|
||||
- "name VLAN_40"
|
||||
- "mtu 850"
|
||||
|
||||
after:
|
||||
- mtu: 1500
|
||||
|
@ -240,6 +243,11 @@ overridden:
|
|||
shutdown: disabled
|
||||
state: active
|
||||
vlan_id: 10
|
||||
- mtu: 850
|
||||
name: VLAN_40
|
||||
shutdown: disabled
|
||||
state: active
|
||||
vlan_id: 40
|
||||
- mtu: 1500
|
||||
name: fddi-default
|
||||
shutdown: enabled
|
||||
|
|
Loading…
Reference in a new issue