From 8798b23ed72f24cd32b5220c80f0cd52190d0ad3 Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Tue, 23 Apr 2024 22:06:33 +0200 Subject: [PATCH 1/6] Add `generate_switchport_trunk` func This should fix #1061 by splitting switchport vlan commands into several if resulted vlan lexeme will be more than 220 symbols. --- .../ios/config/l2_interfaces/l2_interfaces.py | 8 ++--- .../module_utils/network/ios/utils/utils.py | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/plugins/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py b/plugins/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py index 653b837eb..2cec3779f 100644 --- a/plugins/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py +++ b/plugins/module_utils/network/ios/config/l2_interfaces/l2_interfaces.py @@ -31,6 +31,7 @@ L2_interfacesTemplate, ) from ansible_collections.cisco.ios.plugins.module_utils.network.ios.utils.utils import ( + generate_switchport_trunk, normalize_interface, vlan_list_to_range, vlan_range_to_list, @@ -136,11 +137,10 @@ def compare_list(self, want, have): ), ) if self.state != "deleted" and cmd_always: # add configuration needed - add = "add " if have.get("trunk", {}).get(vlan, []) else "" - self.commands.append( - "switchport trunk {0} vlan {1}{2}".format( + self.commands.extend( + generate_switchport_trunk( vlan.split("_", maxsplit=1)[0], - add, + have.get("trunk", {}).get(vlan, []), vlan_list_to_range(sorted(cmd_always)), ), ) diff --git a/plugins/module_utils/network/ios/utils/utils.py b/plugins/module_utils/network/ios/utils/utils.py index 1deea535b..fbe9f1fab 100644 --- a/plugins/module_utils/network/ios/utils/utils.py +++ b/plugins/module_utils/network/ios/utils/utils.py @@ -422,3 +422,35 @@ def sort_dict(dictionary): else: sorted_dict[key] = value return sorted_dict + + +def generate_switchport_trunk(type, add, vlans_range): + """ + Generates a list of switchport commands based on the trunk type and VLANs range. + Ensures that the length of VLANs lexeme in a command does not exceed 220 characters. + """ + + def append_command(): + command_prefix = f"switchport trunk {type} vlan " + if add or commands: + command_prefix += "add " + commands.append(command_prefix + ",".join(current_chunk)) + + commands = [] + current_chunk = [] + current_length = 0 + + for vrange in vlans_range.split(","): + next_addition = vrange if not current_chunk else "," + vrange + if current_length + len(next_addition) <= 220: + current_chunk.append(vrange) + current_length += len(next_addition) + else: + append_command() + current_chunk = [vrange] + current_length = len(vrange) + + if current_chunk: + append_command() + + return commands From bcb0db698d93fb7995b8757a52fa0c2936a956f6 Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Sun, 26 May 2024 13:17:38 +0200 Subject: [PATCH 2/6] test(l2_interface): add test for multiline trunk generation --- .../network/ios/test_ios_l2_interfaces.py | 169 ++++++++++++++++++ 1 file changed, 169 insertions(+) diff --git a/tests/unit/modules/network/ios/test_ios_l2_interfaces.py b/tests/unit/modules/network/ios/test_ios_l2_interfaces.py index e84846aeb..14cd5b37e 100644 --- a/tests/unit/modules/network/ios/test_ios_l2_interfaces.py +++ b/tests/unit/modules/network/ios/test_ios_l2_interfaces.py @@ -793,3 +793,172 @@ def test_ios_l2_interfaces_fiveGibBit(self): result = self.execute_module(changed=True) self.maxDiff = None self.assertEqual(sorted(result["commands"]), sorted(commands)) + + def test_ios_l2_interfaces_trunk_multiline_merge(self): + self.execute_show_command.return_value = dedent( + """\ + interface GigabitEthernet0/2 + switchport trunk allowed vlan 10-20,40 + switchport trunk encapsulation dot1q + switchport trunk native vlan 10 + switchport trunk pruning vlan 10,20 + switchport mode trunk + """, + ) + set_module_args( + dict( + config=[ + dict( + mode="trunk", + name="GigabitEthernet0/2", + trunk=dict( + allowed_vlans=["60-70"] + [str(vlan) for vlan in range(101, 500, 2)], + encapsulation="isl", + native_vlan=20, + pruning_vlans=["10", "20", "30-40"], + ), + ), + ], + state="merged", + ), + ) + commands = [ + "interface GigabitEthernet0/2", + "switchport trunk encapsulation isl", + "switchport trunk native vlan 20", + "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + "switchport trunk pruning vlan add 30-40", + ] + result = self.execute_module(changed=True) + self.maxDiff = None + self.assertEqual(result["commands"], commands) + + def test_ios_l2_interfaces_trunk_multiline_replace(self): + self.execute_show_command.return_value = dedent( + """\ + interface GigabitEthernet0/2 + switchport trunk allowed vlan 10-20,40 + switchport trunk encapsulation dot1q + switchport trunk native vlan 10 + switchport trunk pruning vlan 10,20 + switchport mode trunk + """, + ) + set_module_args( + dict( + config=[ + dict( + mode="trunk", + name="GigabitEthernet0/2", + trunk=dict( + allowed_vlans=["60-70"] + [str(vlan) for vlan in range(101, 500, 2)], + encapsulation="isl", + native_vlan=20, + pruning_vlans=["10", "20", "30-40"], + ), + ), + ], + state="replaced", + ), + ) + commands = [ + "interface GigabitEthernet0/2", + "switchport trunk encapsulation isl", + "switchport trunk native vlan 20", + "switchport trunk allowed vlan remove 10-20,40", + "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + "switchport trunk pruning vlan add 30-40", + ] + result = self.execute_module(changed=True) + self.maxDiff = None + self.assertEqual(result["commands"], commands) + + def test_ios_l2_interfaces_trunk_multiline_replace_init(self): + self.execute_show_command.return_value = dedent( + """\ + interface GigabitEthernet0/2 + switchport trunk encapsulation dot1q + switchport trunk native vlan 10 + switchport trunk pruning vlan 10,20 + switchport mode trunk + """, + ) + set_module_args( + dict( + config=[ + dict( + mode="trunk", + name="GigabitEthernet0/2", + trunk=dict( + allowed_vlans=["60-70"] + [str(vlan) for vlan in range(101, 500, 2)], + encapsulation="isl", + native_vlan=20, + pruning_vlans=["10", "20", "30-40"], + ), + ), + ], + state="replaced", + ), + ) + commands = [ + "interface GigabitEthernet0/2", + "switchport trunk encapsulation isl", + "switchport trunk native vlan 20", + "switchport trunk allowed vlan 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + "switchport trunk pruning vlan add 30-40", + ] + result = self.execute_module(changed=True) + self.maxDiff = None + self.assertEqual(result["commands"], commands) + + def test_ios_l2_interfaces_trunk_multiline_overridden(self): + self.execute_show_command.return_value = dedent( + """\ + interface GigabitEthernet0/2 + switchport trunk allowed vlan 10-20,40 + switchport trunk encapsulation dot1q + switchport trunk native vlan 10 + switchport trunk pruning vlan 10,20 + switchport mode trunk + """, + ) + set_module_args( + dict( + config=[ + dict( + mode="trunk", + name="GigabitEthernet0/2", + trunk=dict( + allowed_vlans=["60-70"] + [str(vlan) for vlan in range(101, 500, 2)], + encapsulation="isl", + native_vlan=20, + pruning_vlans=["10", "20", "30-40"], + ), + ), + ], + state="overridden", + ), + ) + commands = [ + "interface GigabitEthernet0/2", + "switchport trunk encapsulation isl", + "switchport trunk native vlan 20", + "switchport trunk allowed vlan remove 10-20,40", + "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + "switchport trunk pruning vlan add 30-40", + ] + result = self.execute_module(changed=True) + self.maxDiff = None + self.assertEqual(result["commands"], commands) From 1b2090f236bbd1f0e485a7c0e7f2800ec9d3464a Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Sun, 2 Jun 2024 15:59:52 +0300 Subject: [PATCH 3/6] Add changelog entry --- changelogs/fragments/l2_interfaces_multiline_trunk.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fragments/l2_interfaces_multiline_trunk.py diff --git a/changelogs/fragments/l2_interfaces_multiline_trunk.py b/changelogs/fragments/l2_interfaces_multiline_trunk.py new file mode 100644 index 000000000..dfe86afd1 --- /dev/null +++ b/changelogs/fragments/l2_interfaces_multiline_trunk.py @@ -0,0 +1,3 @@ +--- +bugfixes: + - l2_interfaces - If a large number of VLANs are affected, the configuration will now be correctly split into several commands. From 23bbb1ed9e0bfa20f0d0e2d4ccd93fffa66f2c8e Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Sat, 8 Jun 2024 15:20:20 +0200 Subject: [PATCH 4/6] fix(changelog): fragmets file extention --- ...faces_multiline_trunk.py => l2_interfaces_multiline_trunk.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelogs/fragments/{l2_interfaces_multiline_trunk.py => l2_interfaces_multiline_trunk.yml} (100%) diff --git a/changelogs/fragments/l2_interfaces_multiline_trunk.py b/changelogs/fragments/l2_interfaces_multiline_trunk.yml similarity index 100% rename from changelogs/fragments/l2_interfaces_multiline_trunk.py rename to changelogs/fragments/l2_interfaces_multiline_trunk.yml From cfbf8871bc6ce21e808c7a2914fec6af84d9d1c3 Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Mon, 10 Jun 2024 20:59:02 +0200 Subject: [PATCH 5/6] fix(test l2_interfaces): python style --- .../network/ios/test_ios_l2_interfaces.py | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/tests/unit/modules/network/ios/test_ios_l2_interfaces.py b/tests/unit/modules/network/ios/test_ios_l2_interfaces.py index 14cd5b37e..43ed183a0 100644 --- a/tests/unit/modules/network/ios/test_ios_l2_interfaces.py +++ b/tests/unit/modules/network/ios/test_ios_l2_interfaces.py @@ -826,10 +826,14 @@ def test_ios_l2_interfaces_trunk_multiline_merge(self): "interface GigabitEthernet0/2", "switchport trunk encapsulation isl", "switchport trunk native vlan 20", - "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", - "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", - "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", - "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + """switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147, +149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", + """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257, +259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", + """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367, +369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", + """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477, +479,481,483,485,487,489,491,493,495,497,499""", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) @@ -869,10 +873,14 @@ def test_ios_l2_interfaces_trunk_multiline_replace(self): "switchport trunk encapsulation isl", "switchport trunk native vlan 20", "switchport trunk allowed vlan remove 10-20,40", - "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", - "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", - "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", - "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + """switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147, +149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", + """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257, +259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", + """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367, +369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", + """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477, +479,481,483,485,487,489,491,493,495,497,499""" "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) @@ -910,10 +918,14 @@ def test_ios_l2_interfaces_trunk_multiline_replace_init(self): "interface GigabitEthernet0/2", "switchport trunk encapsulation isl", "switchport trunk native vlan 20", - "switchport trunk allowed vlan 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", - "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", - "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", - "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + """switchport trunk allowed vlan 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153, +155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", + """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259, +261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", + """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369, +371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", + """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479, +481,483,485,487,489,491,493,495,497,499""", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) @@ -953,10 +965,14 @@ def test_ios_l2_interfaces_trunk_multiline_overridden(self): "switchport trunk encapsulation isl", "switchport trunk native vlan 20", "switchport trunk allowed vlan remove 10-20,40", - "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", - "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", - "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", - "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479,481,483,485,487,489,491,493,495,497,499", + """switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151, +153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", + """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259, +261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", + """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369, +371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", + """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479, +481,483,485,487,489,491,493,495,497,499""", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) From c58f6f861cc7725551e4caca3a965f17ee8f2f59 Mon Sep 17 00:00:00 2001 From: Aleksey Zhukov <353748+alezkv@users.noreply.github.com> Date: Tue, 11 Jun 2024 12:35:44 +0200 Subject: [PATCH 6/6] fix(test_ios_l2_interfaces): tests --- .../network/ios/test_ios_l2_interfaces.py | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/tests/unit/modules/network/ios/test_ios_l2_interfaces.py b/tests/unit/modules/network/ios/test_ios_l2_interfaces.py index 43ed183a0..a1cee74ad 100644 --- a/tests/unit/modules/network/ios/test_ios_l2_interfaces.py +++ b/tests/unit/modules/network/ios/test_ios_l2_interfaces.py @@ -826,14 +826,14 @@ def test_ios_l2_interfaces_trunk_multiline_merge(self): "interface GigabitEthernet0/2", "switchport trunk encapsulation isl", "switchport trunk native vlan 20", - """switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147, -149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", - """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257, -259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", - """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367, -369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", - """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477, -479,481,483,485,487,489,491,493,495,497,499""", + "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147," + + "149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257," + + "259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367," + + "369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477," + + "479,481,483,485,487,489,491,493,495,497,499", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) @@ -873,14 +873,14 @@ def test_ios_l2_interfaces_trunk_multiline_replace(self): "switchport trunk encapsulation isl", "switchport trunk native vlan 20", "switchport trunk allowed vlan remove 10-20,40", - """switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147, -149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", - """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257, -259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", - """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367, -369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", - """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477, -479,481,483,485,487,489,491,493,495,497,499""" + "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147," + + "149,151,153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257," + + "259,261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367," + + "369,371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477," + + "479,481,483,485,487,489,491,493,495,497,499", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) @@ -918,14 +918,14 @@ def test_ios_l2_interfaces_trunk_multiline_replace_init(self): "interface GigabitEthernet0/2", "switchport trunk encapsulation isl", "switchport trunk native vlan 20", - """switchport trunk allowed vlan 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153, -155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", - """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259, -261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", - """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369, -371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", - """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479, -481,483,485,487,489,491,493,495,497,499""", + "switchport trunk allowed vlan 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151,153," + + "155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259," + + "261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369," + + "371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479," + + "481,483,485,487,489,491,493,495,497,499", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True) @@ -965,14 +965,14 @@ def test_ios_l2_interfaces_trunk_multiline_overridden(self): "switchport trunk encapsulation isl", "switchport trunk native vlan 20", "switchport trunk allowed vlan remove 10-20,40", - """switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151, -153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205""", - """switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259, -261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315""", - """switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369, -371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425""", - """switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479, -481,483,485,487,489,491,493,495,497,499""", + "switchport trunk allowed vlan add 60-70,101,103,105,107,109,111,113,115,117,119,121,123,125,127,129,131,133,135,137,139,141,143,145,147,149,151," + + "153,155,157,159,161,163,165,167,169,171,173,175,177,179,181,183,185,187,189,191,193,195,197,199,201,203,205", + "switchport trunk allowed vlan add 207,209,211,213,215,217,219,221,223,225,227,229,231,233,235,237,239,241,243,245,247,249,251,253,255,257,259," + + "261,263,265,267,269,271,273,275,277,279,281,283,285,287,289,291,293,295,297,299,301,303,305,307,309,311,313,315", + "switchport trunk allowed vlan add 317,319,321,323,325,327,329,331,333,335,337,339,341,343,345,347,349,351,353,355,357,359,361,363,365,367,369," + + "371,373,375,377,379,381,383,385,387,389,391,393,395,397,399,401,403,405,407,409,411,413,415,417,419,421,423,425", + "switchport trunk allowed vlan add 427,429,431,433,435,437,439,441,443,445,447,449,451,453,455,457,459,461,463,465,467,469,471,473,475,477,479," + + "481,483,485,487,489,491,493,495,497,499", "switchport trunk pruning vlan add 30-40", ] result = self.execute_module(changed=True)