From f586802df490c12bf88ae069ce0b840423da6925 Mon Sep 17 00:00:00 2001
From: "pre-commit-ci[bot]"
<66853113+pre-commit-ci[bot]@users.noreply.github.com>
Date: Wed, 11 Dec 2024 16:09:16 +0000
Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
---
.../fix_purge_and_overridden_operations.yaml | 1 -
docs/cisco.ios.ios_vlans_module.rst | 315 +++++++++++++++---
.../modules/network/ios/test_ios_vlans.py | 52 +--
3 files changed, 300 insertions(+), 68 deletions(-)
diff --git a/changelogs/fragments/fix_purge_and_overridden_operations.yaml b/changelogs/fragments/fix_purge_and_overridden_operations.yaml
index 6caa7d6b1..3bd498f6f 100644
--- a/changelogs/fragments/fix_purge_and_overridden_operations.yaml
+++ b/changelogs/fragments/fix_purge_and_overridden_operations.yaml
@@ -4,4 +4,3 @@ bugfixes:
- Fix overridden state operations to ensure excluded VLANs in the provided configuration are removed, thus overriding the VLAN configuration.
- Improve documentation to provide clarity on the "shutdown" variable.
- Improve unit tests to align with the changes made.
-
diff --git a/docs/cisco.ios.ios_vlans_module.rst b/docs/cisco.ios.ios_vlans_module.rst
index 78fa5ec97..1ed4c1d23 100644
--- a/docs/cisco.ios.ios_vlans_module.rst
+++ b/docs/cisco.ios.ios_vlans_module.rst
@@ -229,7 +229,10 @@ Parameters
- Shutdown VLAN switching.
+ Specifies whether VLAN switching should be administratively enabled or disabled.
+ When set to enabled , the VLAN interface is administratively shut down, which prevents it from forwarding traffic.
+ When set to disabled , the VLAN interface is administratively enabled by issuing the internal no shutdown command, allowing it to forward traffic.
+ The operational state of the VLAN depends on both the administrative state (shutdown or no shutdown ) and the physical link status.
|
@@ -448,100 +451,330 @@ Examples
# Before state:
# -------------
#
- # vios_l2#show vlan
+ # S1#show vlan
+
# VLAN Name Status Ports
# ---- -------------------------------- --------- -------------------------------
- # 1 default active Gi0/1, Gi0/2
- # 10 vlan_10 active
- # 20 vlan_20 act/lshut
- # 30 vlan_30 sus/lshut
+ # 1 default active Gi0/0, Gi0/1, Gi0/2, Gi0/3
+ # 10 Vlan_10 active
+ # 20 Vlan_20 active
+ # 30 Vlan_30 suspended
+ # 44 Vlan_44 suspended
# 1002 fddi-default act/unsup
# 1003 token-ring-default act/unsup
# 1004 fddinet-default act/unsup
# 1005 trnet-default act/unsup
- #
+
# VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
# ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
# 1 enet 100001 1500 - - - - - 0 0
# 10 enet 100010 1500 - - - - - 0 0
# 20 enet 100020 610 - - - - - 0 0
# 30 enet 100030 1500 - - - - - 0 0
+ # 44 enet 100044 1500 - - - - - 0 0
# 1002 fddi 101002 1500 - - - - - 0 0
# 1003 tr 101003 1500 - - - - - 0 0
# 1004 fdnet 101004 1500 - - - ieee - 0 0
# 1005 trnet 101005 1500 - - - ibm - 0 0
- #
+
# Remote SPAN VLANs
# ------------------------------------------------------------------------------
- # 10
+
+
+ # Primary Secondary Type Ports
+ # ------- --------- ----------------- ------------------------------------------
+ # S1#
+
- name: Override device configuration of all VLANs with provided configuration
cisco.ios.ios_vlans:
config:
- - name: Vlan_10
- vlan_id: 10
- mtu: 1000
+ - name: Vlan_2020
+ state: active
+ vlan_id: 20
+ shutdown: disabled
state: overridden
+ # Task output:
+ # ------------
+
+ # after:
+ # - mtu: 1500
+ # name: default
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 1
+ # - mtu: 1500
+ # name: Vlan_2020
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 20
+ # - mtu: 1500
+ # name: fddi-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1002
+ # - mtu: 1500
+ # name: token-ring-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1003
+ # - mtu: 1500
+ # name: fddinet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1004
+ # - mtu: 1500
+ # name: trnet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1005
+
+ # before:
+ # - mtu: 1500
+ # name: default
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 1
+ # - mtu: 1500
+ # name: Vlan_10
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 10
+ # - mtu: 610
+ # name: Vlan_20
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 20
+ # - mtu: 1500
+ # name: Vlan_30
+ # shutdown: disabled
+ # state: suspend
+ # vlan_id: 30
+ # - mtu: 1500
+ # name: Vlan_44
+ # shutdown: disabled
+ # state: suspend
+ # vlan_id: 44
+ # - mtu: 1500
+ # name: fddi-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1002
+ # - mtu: 1500
+ # name: token-ring-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1003
+ # - mtu: 1500
+ # name: fddinet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1004
+ # - mtu: 1500
+ # name: trnet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1005
+
+ # commands:
+ # - no vlan 1
+ # - no vlan 10
+ # - no vlan 30
+ # - no vlan 44
+ # - no vlan 1002
+ # - no vlan 1003
+ # - no vlan 1004
+ # - no vlan 1005
+ # - vlan 20
+ # - name Vlan_2020
+ # - no mtu 610
+ # - no vlan configuration 1
+ # - no vlan configuration 10
+ # - no vlan configuration 30
+ # - no vlan configuration 44
+ # - no vlan configuration 1002
+ # - no vlan configuration 1003
+ # - no vlan configuration 1004
+ # - no vlan configuration 1005
+
# After state:
# ------------
#
# vios_l2#show vlan
# VLAN Name Status Ports
# ---- -------------------------------- --------- -------------------------------
- # 1 default active Gi0/1, Gi0/2
- # 10 Vlan_10 active
+ # 1 default active Gi0/0, Gi0/1, Gi0/2, Gi0/3
+ # 20 Vlan_2020 active
# 1002 fddi-default act/unsup
# 1003 token-ring-default act/unsup
# 1004 fddinet-default act/unsup
# 1005 trnet-default act/unsup
- #
+
# VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
# ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
# 1 enet 100001 1500 - - - - - 0 0
- # 10 enet 100010 1000 - - - - - 0 0
+ # 20 enet 100020 1500 - - - - - 0 0
# 1002 fddi 101002 1500 - - - - - 0 0
# 1003 tr 101003 1500 - - - - - 0 0
# 1004 fdnet 101004 1500 - - - ieee - 0 0
# 1005 trnet 101005 1500 - - - ibm - 0 0
+ # Remote SPAN VLANs
+ # ------------------------------------------------------------------------------
- # Using overridden
+
+ # Primary Secondary Type Ports
+ # ------- --------- ----------------- ------------------------------------------
+
+ # Using purged
# Before state:
# -------------
#
- # Leaf-01#show run nve | sec ^vlan configuration
- # vlan configuration 101
- # member evpn-instance 101 vni 10101
- # vlan configuration 102
- # member evpn-instance 102 vni 10102
- # vlan configuration 201
- # member evpn-instance 201 vni 10201
- # vlan configuration 901
- # member vni 50901
+ # S1#show vlan
- - name: Override device configuration of all VLANs with provided configuration
+ # VLAN Name Status Ports
+ # ---- -------------------------------- --------- -------------------------------
+ # 1 default active Gi0/0, Gi0/1, Gi0/2, Gi0/3
+ # 20 Vlan_2020 active
+ # 1002 fddi-default act/unsup
+ # 1003 token-ring-default act/unsup
+ # 1004 fddinet-default act/unsup
+ # 1005 trnet-default act/unsup
+
+ # VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
+ # ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
+ # 1 enet 100001 1500 - - - - - 0 0
+ # 20 enet 100020 1500 - - - - - 0 0
+ # 1002 fddi 101002 1500 - - - - - 0 0
+ # 1003 tr 101003 1500 - - - - - 0 0
+ # 1004 fdnet 101004 1500 - - - ieee - 0 0
+ # 1005 trnet 101005 1500 - - - ibm - 0 0
+
+ # Remote SPAN VLANs
+ # ------------------------------------------------------------------------------
+
+
+ # Primary Secondary Type Ports
+ # ------- --------- ----------------- ------------------------------------------
+
+ # S1#show running-config | section ^vlan configuration .+
+ # vlan configuration 20
+
+
+ - name: Purge all vlans configuration
cisco.ios.ios_vlans:
config:
- - vlan_id: 101
- member:
- vni: 10102
- evi: 102
- - vlan_id: 102
- member:
- vni: 10101
- evi: 101
- state: overridden
+ state: purged
+
+ # Task output:
+ # ------------
+
+ # after:
+ # - mtu: 1500
+ # name: default
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 1
+ # - mtu: 1500
+ # name: fddi-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1002
+ # - mtu: 1500
+ # name: token-ring-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1003
+ # - mtu: 1500
+ # name: fddinet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1004
+ # - mtu: 1500
+ # name: trnet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1005
+
+ # before:
+ # - mtu: 1500
+ # name: default
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 1
+ # - mtu: 1500
+ # name: Vlan_2020
+ # shutdown: disabled
+ # state: active
+ # vlan_id: 20
+ # - mtu: 1500
+ # name: fddi-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1002
+ # - mtu: 1500
+ # name: token-ring-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1003
+ # - mtu: 1500
+ # name: fddinet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1004
+ # - mtu: 1500
+ # name: trnet-default
+ # shutdown: enabled
+ # state: active
+ # vlan_id: 1005
+
+ # commands:
+ # - no vlan 1
+ # - no vlan 20
+ # - no vlan 1002
+ # - no vlan 1003
+ # - no vlan 1004
+ # - no vlan 1005
+ # - no vlan configuration 1
+ # - no vlan configuration 20
+ # - no vlan configuration 1002
+ # - no vlan configuration 1003
+ # - no vlan configuration 1004
+ # - no vlan configuration 1005
# After state:
# ------------
#
- # Leaf-01#show run nve | sec ^vlan configuration
- # vlan configuration 101
- # member evpn-instance 102 vni 10102
- # vlan configuration 102
- # member evpn-instance 101 vni 10101
+ # S1#show vlan
+
+ # VLAN Name Status Ports
+ # ---- -------------------------------- --------- -------------------------------
+ # 1 default active Gi0/0, Gi0/1, Gi0/2, Gi0/3
+ # 1002 fddi-default act/unsup
+ # 1003 token-ring-default act/unsup
+ # 1004 fddinet-default act/unsup
+ # 1005 trnet-default act/unsup
+
+ # VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
+ # ---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
+ # 1 enet 100001 1500 - - - - - 0 0
+ # 1002 fddi 101002 1500 - - - - - 0 0
+ # 1003 tr 101003 1500 - - - - - 0 0
+ # 1004 fdnet 101004 1500 - - - ieee - 0 0
+ # 1005 trnet 101005 1500 - - - ibm - 0 0
+
+ # Remote SPAN VLANs
+ # ------------------------------------------------------------------------------
+
+
+ # Primary Secondary Type Ports
+ # ------- --------- ----------------- ------------------------------------------
+
+ # S1#show running-config | section ^vlan configuration .+
+ # S1#
+
# Using replaced
diff --git a/tests/unit/modules/network/ios/test_ios_vlans.py b/tests/unit/modules/network/ios/test_ios_vlans.py
index 14dd434c3..a48a6fd16 100644
--- a/tests/unit/modules/network/ios/test_ios_vlans.py
+++ b/tests/unit/modules/network/ios/test_ios_vlans.py
@@ -511,32 +511,32 @@ def test_ios_vlans_overridden(self):
)
result = self.execute_module(changed=True)
commands = [
- 'no vlan 1',
- 'no vlan 150',
- 'no vlan 888',
- 'no vlan 1002',
- 'no vlan 1003',
- 'no vlan 1004',
- 'no vlan 1005',
- 'vlan 200',
- 'name test_vlan_200',
- 'state active',
- 'remote-span',
- 'no shutdown',
- 'vlan 123',
- 'name Override_RemoteIsInMyName',
- 'no state active',
- 'no mtu 610',
- 'remote-span',
- 'shutdown',
- 'no vlan configuration 1',
- 'no vlan configuration 150',
- 'no vlan configuration 888',
- 'no vlan configuration 1002',
- 'no vlan configuration 1003',
- 'no vlan configuration 1004',
- 'no vlan configuration 1005'
- ]
+ "no vlan 1",
+ "no vlan 150",
+ "no vlan 888",
+ "no vlan 1002",
+ "no vlan 1003",
+ "no vlan 1004",
+ "no vlan 1005",
+ "vlan 200",
+ "name test_vlan_200",
+ "state active",
+ "remote-span",
+ "no shutdown",
+ "vlan 123",
+ "name Override_RemoteIsInMyName",
+ "no state active",
+ "no mtu 610",
+ "remote-span",
+ "shutdown",
+ "no vlan configuration 1",
+ "no vlan configuration 150",
+ "no vlan configuration 888",
+ "no vlan configuration 1002",
+ "no vlan configuration 1003",
+ "no vlan configuration 1004",
+ "no vlan configuration 1005",
+ ]
self.assertEqual(result["commands"], commands)