From c05cc8de2e5ebe7832724188d8038ce0df1d8335 Mon Sep 17 00:00:00 2001 From: Girish5tri <136325447+Girish5tri@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:10:17 +0530 Subject: [PATCH 01/19] Update bgp_global.py --- .../module_utils/network/ios/argspec/bgp_global/bgp_global.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py index 1a6047041..5c6f376a2 100644 --- a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py @@ -500,7 +500,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - "number": {"type": "int"}, + "number": {"type": "str"}, "dual_as": {"type": "bool"}, "no_prepend": { "type": "dict", From 4fc0d7d653d4ca1fbcf79ae1cfe4d439eee98452 Mon Sep 17 00:00:00 2001 From: Girish5tri <136325447+Girish5tri@users.noreply.github.com> Date: Wed, 9 Oct 2024 12:52:22 +0530 Subject: [PATCH 02/19] added a unit test to test_ios_bgp_global.py --- .../network/ios/test_ios_bgp_global.py | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 67fd77e1d..7716bd021 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -790,3 +790,50 @@ def test_ios_bgp_global_action_states_no_default(self): commands = ["router bgp 6500", "no neighbor 192.0.2.2 shutdown"] result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) + + + def test_ios_bgp_global_asdot_parsed(self): + set_module_args( + dict( + running_config=dedent( + """\ + router bgp 65000 + bgp asnotation dot + bgp log-neighbor-changes + bgp graceful-shutdown all neighbors 50 local-preference 100 community 100 + neighbor 192.0.2.1 remote-as 500.65083 + neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as + """, + ), + state="parsed", + ), + ) + result = self.execute_module(changed=False) + parsed_list = { + "as_number": "65000", + "bgp": { + "asnotation": True, + "log_neighbor_changes": True, + "default": {'ipv4_unicast': True, 'route_target': {'filter': True}}, + "graceful_shutdown": { + "neighbors": {"time": 50}, + "local_preference": 100, + "community": "100" + } + }, + "neighbors": [ + { + "neighbor_address": "192.0.2.1", + "remote_as": "500.65083", + "local_as": { + "number": "501.65083", + "no_prepend": { + "replace_as": True, + "set": True + }, + "set": True + } + } + ] + } + self.assertEqual(parsed_list, result["parsed"]) From 4ca6ad345e1f2f3084686ecbeb9f61e9cb1b312b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 07:23:14 +0000 Subject: [PATCH 03/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../modules/network/ios/test_ios_bgp_global.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 7716bd021..4e376d5d8 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -791,7 +791,6 @@ def test_ios_bgp_global_action_states_no_default(self): result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) - def test_ios_bgp_global_asdot_parsed(self): set_module_args( dict( @@ -814,12 +813,12 @@ def test_ios_bgp_global_asdot_parsed(self): "bgp": { "asnotation": True, "log_neighbor_changes": True, - "default": {'ipv4_unicast': True, 'route_target': {'filter': True}}, + "default": {"ipv4_unicast": True, "route_target": {"filter": True}}, "graceful_shutdown": { "neighbors": {"time": 50}, "local_preference": 100, - "community": "100" - } + "community": "100", + }, }, "neighbors": [ { @@ -829,11 +828,11 @@ def test_ios_bgp_global_asdot_parsed(self): "number": "501.65083", "no_prepend": { "replace_as": True, - "set": True + "set": True, }, - "set": True - } - } - ] + "set": True, + }, + }, + ], } self.assertEqual(parsed_list, result["parsed"]) From 465feecedaf1ffdcde188e01d89ee70de1c9cce7 Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Wed, 9 Oct 2024 14:15:17 +0530 Subject: [PATCH 04/19] added changelog --- changelogs/fix_bgp_issue.yaml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 changelogs/fix_bgp_issue.yaml diff --git a/changelogs/fix_bgp_issue.yaml b/changelogs/fix_bgp_issue.yaml new file mode 100644 index 000000000..fef67141a --- /dev/null +++ b/changelogs/fix_bgp_issue.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: + - ios_bgp_global - Fixes an issue where the 'number' attribute in 'local_as' parameter failed to parse ASDOT notation, causing a 'float to int' conversion error. \ No newline at end of file From a372af102bc66b6e97c29a6b44841befa0907073 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 08:47:52 +0000 Subject: [PATCH 05/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- changelogs/fix_bgp_issue.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fix_bgp_issue.yaml b/changelogs/fix_bgp_issue.yaml index fef67141a..26b8dfcd7 100644 --- a/changelogs/fix_bgp_issue.yaml +++ b/changelogs/fix_bgp_issue.yaml @@ -1,3 +1,3 @@ --- bugfixes: - - ios_bgp_global - Fixes an issue where the 'number' attribute in 'local_as' parameter failed to parse ASDOT notation, causing a 'float to int' conversion error. \ No newline at end of file + - ios_bgp_global - Fixes an issue where the 'number' attribute in 'local_as' parameter failed to parse ASDOT notation, causing a 'float to int' conversion error. From 91d7713d9093cee1452a0baf6de3a93df272062e Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Wed, 9 Oct 2024 14:19:28 +0530 Subject: [PATCH 06/19] changelog added --- changelogs/{fix_bgp_issue.yaml => fragments/fix_bgp_asdot.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelogs/{fix_bgp_issue.yaml => fragments/fix_bgp_asdot.yml} (100%) diff --git a/changelogs/fix_bgp_issue.yaml b/changelogs/fragments/fix_bgp_asdot.yml similarity index 100% rename from changelogs/fix_bgp_issue.yaml rename to changelogs/fragments/fix_bgp_asdot.yml From d8f7e8a4d7d7c591a35e25c7b3843b5404d23a9c Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Wed, 9 Oct 2024 14:25:21 +0530 Subject: [PATCH 07/19] changelog --- .../fragments/{fix_bgp_asdot.yml => fix_bgp_asdot_error.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename changelogs/fragments/{fix_bgp_asdot.yml => fix_bgp_asdot_error.yml} (100%) diff --git a/changelogs/fragments/fix_bgp_asdot.yml b/changelogs/fragments/fix_bgp_asdot_error.yml similarity index 100% rename from changelogs/fragments/fix_bgp_asdot.yml rename to changelogs/fragments/fix_bgp_asdot_error.yml From c0162356a4abcb4ac3e36292128e672328697ec3 Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Wed, 9 Oct 2024 14:56:10 +0530 Subject: [PATCH 08/19] fixed sanity errors --- plugins/modules/ios_bgp_global.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/ios_bgp_global.py b/plugins/modules/ios_bgp_global.py index 9ea931db7..2e4d11eb1 100644 --- a/plugins/modules/ios_bgp_global.py +++ b/plugins/modules/ios_bgp_global.py @@ -972,7 +972,7 @@ description: - AS number used as local AS - Please refer vendor documentation for valid values - type: int + type: str dual_as: description: Accept either real AS or local AS from the ebgp peer type: bool From 84344bb98d2622152daf4153d21381eb432556d4 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 9 Oct 2024 09:26:23 +0000 Subject: [PATCH 09/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/cisco.ios.ios_bgp_global_module.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cisco.ios.ios_bgp_global_module.rst b/docs/cisco.ios.ios_bgp_global_module.rst index f3ec41e59..a5ee31e41 100644 --- a/docs/cisco.ios.ios_bgp_global_module.rst +++ b/docs/cisco.ios.ios_bgp_global_module.rst @@ -4892,7 +4892,7 @@ Parameters number
- integer + string
From 3d40398fae03e99a58c7bb1ef148d0e9aff3f8f5 Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Thu, 10 Oct 2024 06:17:39 +0530 Subject: [PATCH 10/19] added tests --- .../ios_bgp_global/tests/cli/merged.yaml | 9 ++ .../targets/ios_bgp_global/vars/main.yaml | 12 +++ .../network/ios/test_ios_bgp_global.py | 86 +++++++++++++++++++ 3 files changed, 107 insertions(+) diff --git a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml index f7fd02ba4..e7ca98b4d 100644 --- a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml @@ -11,6 +11,7 @@ config: as_number: 65000 bgp: + asnotation: true default: ipv4_unicast: false route_target: @@ -27,6 +28,14 @@ remote_as: 100 shutdown: set: false + - neighbor_address: 192.0.2.1 + remote_as: "500.65083" + local_as: + number: "501.65083" + no_prepend: + replace_as: true + set: true + set: true timers: keepalive: 100 holdtime: 200 diff --git a/tests/integration/targets/ios_bgp_global/vars/main.yaml b/tests/integration/targets/ios_bgp_global/vars/main.yaml index 71dd2788f..fef5c7ea7 100644 --- a/tests/integration/targets/ios_bgp_global/vars/main.yaml +++ b/tests/integration/targets/ios_bgp_global/vars/main.yaml @@ -11,10 +11,14 @@ merged: - bgp log-neighbor-changes - neighbor 198.0.2.1 remote-as 100 - neighbor 198.0.2.1 description merge neighbor + - bgp asnotation dot + - neighbor 192.0.2.1 remote-as 500.65083 + - neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as after: as_number: "65000" bgp: + asnotation: true default: ipv4_unicast: false route_target: @@ -26,6 +30,14 @@ merged: time: 50 log_neighbor_changes: true neighbors: + - local_as: + no_prepend: + replace_as: true + set: true + number: "501.65083" + set: true + neighbor_address: "192.0.2.1" + remote_as: "500.65083" - description: merge neighbor neighbor_address: 198.0.2.1 remote_as: "100" diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 4e376d5d8..9f5e841c0 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -836,3 +836,89 @@ def test_ios_bgp_global_asdot_parsed(self): ], } self.assertEqual(parsed_list, result["parsed"]) + + def test_ios_bgp_global_asdot_merged(self): + set_module_args( + dict( + config=dict( + as_number="65000", + bgp=dict( + asnotation=True, + log_neighbor_changes=True, + graceful_shutdown=dict( + neighbors=dict(time=50), + local_preference=100, + community="100", + ), + ), + neighbors=[ + dict( + neighbor_address="192.0.2.1", + remote_as="500.65083", + local_as=dict( + number="501.65083", + no_prepend=dict( + replace_as=True, + set=True, + ), + set=True, + ), + ), + ], + ), + state="merged", + ) + ) + commands = [ + "router bgp 65000", + "bgp asnotation dot", + "bgp log-neighbor-changes", + "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", + "neighbor 192.0.2.1 remote-as 500.65083", + "neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as", + ] + result = self.execute_module(changed=True) + self.assertEqual(sorted(result['commands']), sorted(commands)) + + def test_ios_bgp_global_asdot_rendered(self): + set_module_args( + dict( + config=dict( + as_number="65000", + bgp=dict( + asnotation=True, + log_neighbor_changes=True, + graceful_shutdown=dict( + neighbors=dict(time=50), + local_preference=100, + community="100", + ), + ), + neighbors=[ + dict( + neighbor_address="192.0.2.1", + remote_as="500.65083", + local_as=dict( + number="501.65083", + no_prepend=dict( + replace_as=True, + set=True, + ), + set=True, + ), + ), + ], + ), + state="rendered", + ) + ) + commands = [ + "router bgp 65000", + "bgp asnotation dot", + "bgp log-neighbor-changes", + "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", + "neighbor 192.0.2.1 remote-as 500.65083", + "neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as", + ] + result = self.execute_module(changed=False) + self.assertEqual(sorted(result['rendered']), sorted(commands)) From 85c758b7a67f0676b0d0ca75e233edb11a25b943 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 10 Oct 2024 00:47:51 +0000 Subject: [PATCH 11/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/unit/modules/network/ios/test_ios_bgp_global.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 9f5e841c0..8b63a3225 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -867,7 +867,7 @@ def test_ios_bgp_global_asdot_merged(self): ], ), state="merged", - ) + ), ) commands = [ "router bgp 65000", @@ -878,7 +878,7 @@ def test_ios_bgp_global_asdot_merged(self): "neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as", ] result = self.execute_module(changed=True) - self.assertEqual(sorted(result['commands']), sorted(commands)) + self.assertEqual(sorted(result["commands"]), sorted(commands)) def test_ios_bgp_global_asdot_rendered(self): set_module_args( @@ -910,7 +910,7 @@ def test_ios_bgp_global_asdot_rendered(self): ], ), state="rendered", - ) + ), ) commands = [ "router bgp 65000", @@ -921,4 +921,4 @@ def test_ios_bgp_global_asdot_rendered(self): "neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as", ] result = self.execute_module(changed=False) - self.assertEqual(sorted(result['rendered']), sorted(commands)) + self.assertEqual(sorted(result["rendered"]), sorted(commands)) From c0aeb5a55d9cb2c78152d516fa724641a83ddb3b Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Thu, 10 Oct 2024 16:04:00 +0530 Subject: [PATCH 12/19] updated new tests --- .../ios_bgp_global/tests/cli/merged.yaml | 8 ++++ .../targets/ios_bgp_global/vars/main.yaml | 10 +++++ .../network/ios/test_ios_bgp_global.py | 43 +++++++++++++++++++ 3 files changed, 61 insertions(+) diff --git a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml index e7ca98b4d..92b39f98f 100644 --- a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml @@ -36,6 +36,14 @@ replace_as: true set: true set: true + - neighbor_address: 192.0.2.2 + remote_as: 200 + local_as: + number: 501 + no_prepend: + replace_as: true + set: true + set: true timers: keepalive: 100 holdtime: 200 diff --git a/tests/integration/targets/ios_bgp_global/vars/main.yaml b/tests/integration/targets/ios_bgp_global/vars/main.yaml index fef5c7ea7..e92428923 100644 --- a/tests/integration/targets/ios_bgp_global/vars/main.yaml +++ b/tests/integration/targets/ios_bgp_global/vars/main.yaml @@ -14,6 +14,8 @@ merged: - bgp asnotation dot - neighbor 192.0.2.1 remote-as 500.65083 - neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as + - neighbor 192.0.2.2 remote-as 200 + - neighbor 192.0.2.2 local-as 501 no-prepend replace-as after: as_number: "65000" @@ -38,6 +40,14 @@ merged: set: true neighbor_address: "192.0.2.1" remote_as: "500.65083" + - local_as: + no_prepend: + replace_as: true + set: true + number: "501" + set: true + neighbor_address: "192.0.2.2" + remote_as: "200" - description: merge neighbor neighbor_address: 198.0.2.1 remote_as: "100" diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 8b63a3225..1831ad084 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -880,6 +880,49 @@ def test_ios_bgp_global_asdot_merged(self): result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) + def test_ios_bgp_global_int_merged(self): + set_module_args( + dict( + config=dict( + as_number="65000", + bgp=dict( + asnotation=True, + log_neighbor_changes=True, + graceful_shutdown=dict( + neighbors=dict(time=50), + local_preference=100, + community="100", + ), + ), + neighbors=[ + dict( + neighbor_address="192.0.2.1", + remote_as="500.65083", + local_as=dict( + number="501", + no_prepend=dict( + replace_as=True, + set=True, + ), + set=True, + ), + ), + ], + ), + state="merged", + ), + ) + commands = [ + "router bgp 65000", + "bgp asnotation dot", + "bgp log-neighbor-changes", + "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", + "neighbor 192.0.2.1 remote-as 500.65083", + "neighbor 192.0.2.1 local-as 501 no-prepend replace-as", + ] + result = self.execute_module(changed=True) + self.assertEqual(sorted(result["commands"]), sorted(commands)) + def test_ios_bgp_global_asdot_rendered(self): set_module_args( dict( From 6eb6318ddbc64d80038b194a0d77d7515ffffe44 Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Thu, 17 Oct 2024 15:34:25 +0530 Subject: [PATCH 13/19] new --- plugins/action/ios.py | 15 +++ .../ios/argspec/bgp_global/bgp_global.py | 7 +- .../ios/config/bgp_global/bgp_global.py | 5 + .../network/ios/rm_templates/bgp_global.py | 6 +- plugins/modules/ios_bgp_global.py | 6 + .../ios_bgp_global/tests/cli/merged.yaml | 17 --- .../targets/ios_bgp_global/vars/main.yaml | 22 ---- .../network/ios/test_ios_bgp_global.py | 107 +++++++++--------- 8 files changed, 87 insertions(+), 98 deletions(-) diff --git a/plugins/action/ios.py b/plugins/action/ios.py index 38c0ed229..8a02ae7c0 100644 --- a/plugins/action/ios.py +++ b/plugins/action/ios.py @@ -47,6 +47,21 @@ def run(self, tmp=None, task_vars=None): % self._play_context.connection, } + # Handle deprecated 'number' parameter + if 'config' in self._task.args and self._task.args['config'] is not None: + config = self._task.args['config'] + if 'neighbors' in config: + for neighbor in config['neighbors']: + if 'local_as' in neighbor: + if 'number' in neighbor['local_as']: + display.deprecated( + msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", + date="2027-01-01", + collection_name="cisco.ios", + ) + neighbor['local_as']['asn'] = str(neighbor['local_as']['number']) + del neighbor['local_as']['number'] + result = super(ActionModule, self).run(task_vars=task_vars) if warnings: if "warnings" in result: diff --git a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py index 5c6f376a2..e56e41c66 100644 --- a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py @@ -500,7 +500,12 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - "number": {"type": "str"}, + "number": { + "type": "int", + "deprecated_by": "asn", + "removed_at_date": "2027-01-01", + }, + "asn": {"type": "str"}, "dual_as": {"type": "bool"}, "no_prepend": { "type": "dict", diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index 36c9bf89a..823fd7ff3 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -456,3 +456,8 @@ def handle_deprecates(self, want, is_nbr=False): _want_nbrs = want.get("neighbors", {}) for nbr in _want_nbrs: nbr = self.handle_deprecates(nbr, is_nbr=True) + else: + if 'local_as' in want: + if 'number' in want['local_as']: + want['local_as']['asn'] = want['local_as'].pop('number') + return want diff --git a/plugins/module_utils/network/ios/rm_templates/bgp_global.py b/plugins/module_utils/network/ios/rm_templates/bgp_global.py index a210b2fc3..008a58086 100644 --- a/plugins/module_utils/network/ios/rm_templates/bgp_global.py +++ b/plugins/module_utils/network/ios/rm_templates/bgp_global.py @@ -1582,7 +1582,7 @@ def __init__(self, lines=None, module=None): "getval": re.compile( r""" \sneighbor\s(?P\S+)\s(?Plocal-as) - (\s(?P\S+))? + (\s(?P\S+))? (\s(?Pdual-as))? (\s(?Pno-prepend))? (\s(?Preplace-as))? @@ -1590,7 +1590,7 @@ def __init__(self, lines=None, module=None): re.VERBOSE, ), "setval": "neighbor {{ neighbor_address }} local-as" - "{{ (' ' + local_as.number|string) if local_as.number is defined else '' }}" + "{{ (' ' + local_as.asn|string) if local_as.asn is defined else '' }}" "{{ (' dual-as') if local_as.dual_as is defined else '' }}" "{{ (' no-prepend') if local_as.no_prepend.set is defined else '' }}" "{{ (' replace-as') if local_as.no_prepend.replace_as is defined else '' }}", @@ -1600,7 +1600,7 @@ def __init__(self, lines=None, module=None): "neighbor_address": "{{ neighbor_address }}", "local_as": { "set": "{{ not not local_as }}", - "number": "{{ number }}", + "asn": "{{ asn }}", "dual_as": "{{ not not dual_as }}", "no_prepend": { "set": "{{ not not no_prepend }}", diff --git a/plugins/modules/ios_bgp_global.py b/plugins/modules/ios_bgp_global.py index 2e4d11eb1..8a13e55a6 100644 --- a/plugins/modules/ios_bgp_global.py +++ b/plugins/modules/ios_bgp_global.py @@ -970,8 +970,14 @@ type: bool number: description: + - DEPRECATED: This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead. - AS number used as local AS - Please refer vendor documentation for valid values + type: int + asn: + description: + - Autonomous system number for local BGP routes + - Please refer vendor documentation for valid values type: str dual_as: description: Accept either real AS or local AS from the ebgp peer diff --git a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml index 92b39f98f..f7fd02ba4 100644 --- a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml @@ -11,7 +11,6 @@ config: as_number: 65000 bgp: - asnotation: true default: ipv4_unicast: false route_target: @@ -28,22 +27,6 @@ remote_as: 100 shutdown: set: false - - neighbor_address: 192.0.2.1 - remote_as: "500.65083" - local_as: - number: "501.65083" - no_prepend: - replace_as: true - set: true - set: true - - neighbor_address: 192.0.2.2 - remote_as: 200 - local_as: - number: 501 - no_prepend: - replace_as: true - set: true - set: true timers: keepalive: 100 holdtime: 200 diff --git a/tests/integration/targets/ios_bgp_global/vars/main.yaml b/tests/integration/targets/ios_bgp_global/vars/main.yaml index e92428923..71dd2788f 100644 --- a/tests/integration/targets/ios_bgp_global/vars/main.yaml +++ b/tests/integration/targets/ios_bgp_global/vars/main.yaml @@ -11,16 +11,10 @@ merged: - bgp log-neighbor-changes - neighbor 198.0.2.1 remote-as 100 - neighbor 198.0.2.1 description merge neighbor - - bgp asnotation dot - - neighbor 192.0.2.1 remote-as 500.65083 - - neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as - - neighbor 192.0.2.2 remote-as 200 - - neighbor 192.0.2.2 local-as 501 no-prepend replace-as after: as_number: "65000" bgp: - asnotation: true default: ipv4_unicast: false route_target: @@ -32,22 +26,6 @@ merged: time: 50 log_neighbor_changes: true neighbors: - - local_as: - no_prepend: - replace_as: true - set: true - number: "501.65083" - set: true - neighbor_address: "192.0.2.1" - remote_as: "500.65083" - - local_as: - no_prepend: - replace_as: true - set: true - number: "501" - set: true - neighbor_address: "192.0.2.2" - remote_as: "200" - description: merge neighbor neighbor_address: 198.0.2.1 remote_as: "100" diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 1831ad084..3bc3ebb18 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -791,53 +791,50 @@ def test_ios_bgp_global_action_states_no_default(self): result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) - def test_ios_bgp_global_asdot_parsed(self): + def test_ios_bgp_global_asdot_merged(self): set_module_args( dict( - running_config=dedent( - """\ - router bgp 65000 - bgp asnotation dot - bgp log-neighbor-changes - bgp graceful-shutdown all neighbors 50 local-preference 100 community 100 - neighbor 192.0.2.1 remote-as 500.65083 - neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as - """, + config=dict( + as_number="65000", + bgp=dict( + asnotation=True, + log_neighbor_changes=True, + graceful_shutdown=dict( + neighbors=dict(time=50), + local_preference=100, + community="100", + ), + ), + neighbors=[ + dict( + neighbor_address="192.0.2.1", + remote_as="500.65083", + local_as=dict( + asn="501.7843", + no_prepend=dict( + replace_as=True, + set=True, + ), + set=True, + ), + ), + ], ), - state="parsed", + state="merged", ), ) - result = self.execute_module(changed=False) - parsed_list = { - "as_number": "65000", - "bgp": { - "asnotation": True, - "log_neighbor_changes": True, - "default": {"ipv4_unicast": True, "route_target": {"filter": True}}, - "graceful_shutdown": { - "neighbors": {"time": 50}, - "local_preference": 100, - "community": "100", - }, - }, - "neighbors": [ - { - "neighbor_address": "192.0.2.1", - "remote_as": "500.65083", - "local_as": { - "number": "501.65083", - "no_prepend": { - "replace_as": True, - "set": True, - }, - "set": True, - }, - }, - ], - } - self.assertEqual(parsed_list, result["parsed"]) + commands = [ + "router bgp 65000", + "bgp asnotation dot", + "bgp log-neighbor-changes", + "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", + "neighbor 192.0.2.1 remote-as 500.65083", + "neighbor 192.0.2.1 local-as 501.7843 no-prepend replace-as", + ] + result = self.execute_module(changed=True) + self.assertEqual(sorted(result["commands"]), sorted(commands)) - def test_ios_bgp_global_asdot_merged(self): + def test_ios_bgp_global_merged_number(self): set_module_args( dict( config=dict( @@ -854,9 +851,9 @@ def test_ios_bgp_global_asdot_merged(self): neighbors=[ dict( neighbor_address="192.0.2.1", - remote_as="500.65083", + remote_as=500, local_as=dict( - number="501.65083", + number=501, no_prepend=dict( replace_as=True, set=True, @@ -874,13 +871,13 @@ def test_ios_bgp_global_asdot_merged(self): "bgp asnotation dot", "bgp log-neighbor-changes", "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", - "neighbor 192.0.2.1 remote-as 500.65083", - "neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as", + "neighbor 192.0.2.1 remote-as 500", + "neighbor 192.0.2.1 local-as 501 no-prepend replace-as", ] result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) - def test_ios_bgp_global_int_merged(self): + def test_ios_bgp_global_merged_asn(self): set_module_args( dict( config=dict( @@ -899,7 +896,7 @@ def test_ios_bgp_global_int_merged(self): neighbor_address="192.0.2.1", remote_as="500.65083", local_as=dict( - number="501", + asn="501", no_prepend=dict( replace_as=True, set=True, @@ -923,7 +920,7 @@ def test_ios_bgp_global_int_merged(self): result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) - def test_ios_bgp_global_asdot_rendered(self): + def test_ios_bgp_global_merged_num(self): set_module_args( dict( config=dict( @@ -940,9 +937,9 @@ def test_ios_bgp_global_asdot_rendered(self): neighbors=[ dict( neighbor_address="192.0.2.1", - remote_as="500.65083", + remote_as="600.65083", local_as=dict( - number="501.65083", + number="701", no_prepend=dict( replace_as=True, set=True, @@ -952,7 +949,7 @@ def test_ios_bgp_global_asdot_rendered(self): ), ], ), - state="rendered", + state="merged", ), ) commands = [ @@ -960,8 +957,8 @@ def test_ios_bgp_global_asdot_rendered(self): "bgp asnotation dot", "bgp log-neighbor-changes", "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", - "neighbor 192.0.2.1 remote-as 500.65083", - "neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as", + "neighbor 192.0.2.1 remote-as 600.65083", + "neighbor 192.0.2.1 local-as 701 no-prepend replace-as", ] - result = self.execute_module(changed=False) - self.assertEqual(sorted(result["rendered"]), sorted(commands)) + result = self.execute_module(changed=True) + self.assertEqual(sorted(result["commands"]), sorted(commands)) \ No newline at end of file From 7aaf9fe6a375cbaddcf90c997282e6a43675558b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 10:07:03 +0000 Subject: [PATCH 14/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/cisco.ios.ios_bgp_global_module.rst | 22 ++++++++++++++++++- plugins/action/ios.py | 16 +++++++------- .../ios/config/bgp_global/bgp_global.py | 6 ++--- .../network/ios/test_ios_bgp_global.py | 2 +- 4 files changed, 33 insertions(+), 13 deletions(-) diff --git a/docs/cisco.ios.ios_bgp_global_module.rst b/docs/cisco.ios.ios_bgp_global_module.rst index a5ee31e41..a5250ffd4 100644 --- a/docs/cisco.ios.ios_bgp_global_module.rst +++ b/docs/cisco.ios.ios_bgp_global_module.rst @@ -4800,6 +4800,25 @@ Parameters + +
+ asn + +
+ string +
+ + + + +
Autonomous system number for local BGP routes
+
Please refer vendor documentation for valid values
+ + + + + +
dual_as @@ -4892,12 +4911,13 @@ Parameters number
- string + integer
+
{'DEPRECATED': "This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead."}
AS number used as local AS
Please refer vendor documentation for valid values
diff --git a/plugins/action/ios.py b/plugins/action/ios.py index 8a02ae7c0..24a1a6582 100644 --- a/plugins/action/ios.py +++ b/plugins/action/ios.py @@ -48,19 +48,19 @@ def run(self, tmp=None, task_vars=None): } # Handle deprecated 'number' parameter - if 'config' in self._task.args and self._task.args['config'] is not None: - config = self._task.args['config'] - if 'neighbors' in config: - for neighbor in config['neighbors']: - if 'local_as' in neighbor: - if 'number' in neighbor['local_as']: + if "config" in self._task.args and self._task.args["config"] is not None: + config = self._task.args["config"] + if "neighbors" in config: + for neighbor in config["neighbors"]: + if "local_as" in neighbor: + if "number" in neighbor["local_as"]: display.deprecated( msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", date="2027-01-01", collection_name="cisco.ios", ) - neighbor['local_as']['asn'] = str(neighbor['local_as']['number']) - del neighbor['local_as']['number'] + neighbor["local_as"]["asn"] = str(neighbor["local_as"]["number"]) + del neighbor["local_as"]["number"] result = super(ActionModule, self).run(task_vars=task_vars) if warnings: diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index 823fd7ff3..abf63d3ff 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -457,7 +457,7 @@ def handle_deprecates(self, want, is_nbr=False): for nbr in _want_nbrs: nbr = self.handle_deprecates(nbr, is_nbr=True) else: - if 'local_as' in want: - if 'number' in want['local_as']: - want['local_as']['asn'] = want['local_as'].pop('number') + if "local_as" in want: + if "number" in want["local_as"]: + want["local_as"]["asn"] = want["local_as"].pop("number") return want diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 3bc3ebb18..4cc370142 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -961,4 +961,4 @@ def test_ios_bgp_global_merged_num(self): "neighbor 192.0.2.1 local-as 701 no-prepend replace-as", ] result = self.execute_module(changed=True) - self.assertEqual(sorted(result["commands"]), sorted(commands)) \ No newline at end of file + self.assertEqual(sorted(result["commands"]), sorted(commands)) From 844c976d6227811ef726871ecdb78ce3c4218b15 Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Fri, 18 Oct 2024 06:09:10 +0530 Subject: [PATCH 15/19] updated_deprecation_method --- plugins/action/ios.py | 28 +++++++-------- .../ios/config/bgp_global/bgp_global.py | 36 +++++++++++++++++-- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/plugins/action/ios.py b/plugins/action/ios.py index 24a1a6582..d9dffe6a3 100644 --- a/plugins/action/ios.py +++ b/plugins/action/ios.py @@ -47,20 +47,20 @@ def run(self, tmp=None, task_vars=None): % self._play_context.connection, } - # Handle deprecated 'number' parameter - if "config" in self._task.args and self._task.args["config"] is not None: - config = self._task.args["config"] - if "neighbors" in config: - for neighbor in config["neighbors"]: - if "local_as" in neighbor: - if "number" in neighbor["local_as"]: - display.deprecated( - msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", - date="2027-01-01", - collection_name="cisco.ios", - ) - neighbor["local_as"]["asn"] = str(neighbor["local_as"]["number"]) - del neighbor["local_as"]["number"] + # # Handle deprecated 'number' parameter + # if "config" in self._task.args and self._task.args["config"] is not None: + # config = self._task.args["config"] + # if "neighbors" in config: + # for neighbor in config["neighbors"]: + # if "local_as" in neighbor: + # if "number" in neighbor["local_as"]: + # display.deprecated( + # msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", + # date="2027-01-01", + # collection_name="cisco.ios", + # ) + # neighbor["local_as"]["asn"] = str(neighbor["local_as"]["number"]) + # del neighbor["local_as"]["number"] result = super(ActionModule, self).run(task_vars=task_vars) if warnings: diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index abf63d3ff..e611ca412 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -140,7 +140,11 @@ def execute_module(self): :rtype: A dictionary :returns: The result from module execution """ + if self.want: + self.want = self.handle_deprecates(self.want) + if self.state not in ["parsed", "gathered"]: + #self.want = self.handle_deprecates(self.want) self.generate_commands() self.run_commands() return self.result @@ -160,8 +164,8 @@ def generate_commands(self): "configuring new ASN".format(h_asn), ) - if self.want: - self.handle_deprecates(self.want) + self.want = self.handle_deprecates(self.want) + self.have = self.handle_deprecates(self.have) for each in self.want, self.have: self._bgp_global_list_to_dict(each) @@ -193,6 +197,8 @@ def _compare(self, want, have): the `want` and `have` data with the `parsers` defined for the Bgp_global network resource. """ + want = self.handle_deprecates(want) + self.generic_list_parsers = ["distributes", "aggregate_addresses", "networks"] if self._has_bgp_inject_maps(want): @@ -356,8 +362,10 @@ def _compare_neighbor_lists(self, want, have): ] for name, w_neighbor in want.items(): + w_neighbor = self.handle_deprecates(w_neighbor, is_nbr=True) handle_shutdown_default = False have_nbr = have.pop(name, {}) + have_nbr = self.handle_deprecates(have_nbr, is_nbr=True) want_route = w_neighbor.pop("route_maps", {}) have_route = have_nbr.pop("route_maps", {}) if ( @@ -459,5 +467,27 @@ def handle_deprecates(self, want, is_nbr=False): else: if "local_as" in want: if "number" in want["local_as"]: - want["local_as"]["asn"] = want["local_as"].pop("number") + want["local_as"]["asn"] = str(want["local_as"].pop("number")) return want + + + # def handle_deprecates(self, want, is_nbr=False): + # """ + # Handles deprecated values post rewrite + # neighbor.route_map [dict] - neighbor.route_maps [list:dict] + + # Args: + # want (_type_): Handle want attributes for deprecated values + # is_nbr (bool, optional): activates neighbor part on recursion. Defaults to False. + # """ + # if not is_nbr: + # if want.get("neighbors"): + # _want_nbrs = want.get("neighbors", {}) + # for nbr in _want_nbrs: + # nbr = self.handle_deprecates(nbr, is_nbr=True) + # else: + # if "local_as" in want: + # if "number" in want["local_as"]: + # want["local_as"]["asn"] = str(want["local_as"]["number"]) + # del want["local_as"]["number"] + # return want From 8c3edd0f422840b2a8f7ed38f1d6f8893d13ecec Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 00:39:36 +0000 Subject: [PATCH 16/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .../module_utils/network/ios/config/bgp_global/bgp_global.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index e611ca412..0fe9a6707 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -144,7 +144,7 @@ def execute_module(self): self.want = self.handle_deprecates(self.want) if self.state not in ["parsed", "gathered"]: - #self.want = self.handle_deprecates(self.want) + # self.want = self.handle_deprecates(self.want) self.generate_commands() self.run_commands() return self.result @@ -470,7 +470,6 @@ def handle_deprecates(self, want, is_nbr=False): want["local_as"]["asn"] = str(want["local_as"].pop("number")) return want - # def handle_deprecates(self, want, is_nbr=False): # """ # Handles deprecated values post rewrite From a44cb40f2b2e02ffa77bb88f5482de9a24724334 Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Fri, 18 Oct 2024 17:00:02 +0530 Subject: [PATCH 17/19] fin update --- plugins/action/ios.py | 15 ------- .../ios/argspec/bgp_global/bgp_global.py | 8 ++-- .../ios/config/bgp_global/bgp_global.py | 17 ++++---- plugins/modules/ios_bgp_global.py | 2 +- .../ios_bgp_global/tests/cli/merged.yaml | 17 ++++++++ .../targets/ios_bgp_global/vars/main.yaml | 23 +++++++++- .../network/ios/test_ios_bgp_global.py | 43 ------------------- 7 files changed, 52 insertions(+), 73 deletions(-) diff --git a/plugins/action/ios.py b/plugins/action/ios.py index d9dffe6a3..38c0ed229 100644 --- a/plugins/action/ios.py +++ b/plugins/action/ios.py @@ -47,21 +47,6 @@ def run(self, tmp=None, task_vars=None): % self._play_context.connection, } - # # Handle deprecated 'number' parameter - # if "config" in self._task.args and self._task.args["config"] is not None: - # config = self._task.args["config"] - # if "neighbors" in config: - # for neighbor in config["neighbors"]: - # if "local_as" in neighbor: - # if "number" in neighbor["local_as"]: - # display.deprecated( - # msg="DEPRECATED: The 'number' option in 'local_as' is deprecated, Use 'asn' instead.", - # date="2027-01-01", - # collection_name="cisco.ios", - # ) - # neighbor["local_as"]["asn"] = str(neighbor["local_as"]["number"]) - # del neighbor["local_as"]["number"] - result = super(ActionModule, self).run(task_vars=task_vars) if warnings: if "warnings" in result: diff --git a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py index e56e41c66..d72589047 100644 --- a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py @@ -500,10 +500,10 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - "number": { - "type": "int", - "deprecated_by": "asn", - "removed_at_date": "2027-01-01", + 'number': { + 'type': 'int', + 'removed_at_date': '2027-01-31', + 'removed_from_collection': 'cisco.ios', }, "asn": {"type": "str"}, "dual_as": {"type": "bool"}, diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index 0fe9a6707..c3f11426a 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -140,11 +140,11 @@ def execute_module(self): :rtype: A dictionary :returns: The result from module execution """ - if self.want: - self.want = self.handle_deprecates(self.want) - if self.state not in ["parsed", "gathered"]: +<<<<<<< Updated upstream # self.want = self.handle_deprecates(self.want) +======= +>>>>>>> Stashed changes self.generate_commands() self.run_commands() return self.result @@ -164,8 +164,8 @@ def generate_commands(self): "configuring new ASN".format(h_asn), ) - self.want = self.handle_deprecates(self.want) - self.have = self.handle_deprecates(self.have) + if self.want: + self.handle_deprecates(self.want) for each in self.want, self.have: self._bgp_global_list_to_dict(each) @@ -197,8 +197,6 @@ def _compare(self, want, have): the `want` and `have` data with the `parsers` defined for the Bgp_global network resource. """ - want = self.handle_deprecates(want) - self.generic_list_parsers = ["distributes", "aggregate_addresses", "networks"] if self._has_bgp_inject_maps(want): @@ -362,10 +360,8 @@ def _compare_neighbor_lists(self, want, have): ] for name, w_neighbor in want.items(): - w_neighbor = self.handle_deprecates(w_neighbor, is_nbr=True) handle_shutdown_default = False have_nbr = have.pop(name, {}) - have_nbr = self.handle_deprecates(have_nbr, is_nbr=True) want_route = w_neighbor.pop("route_maps", {}) have_route = have_nbr.pop("route_maps", {}) if ( @@ -469,6 +465,7 @@ def handle_deprecates(self, want, is_nbr=False): if "number" in want["local_as"]: want["local_as"]["asn"] = str(want["local_as"].pop("number")) return want +<<<<<<< Updated upstream # def handle_deprecates(self, want, is_nbr=False): # """ @@ -490,3 +487,5 @@ def handle_deprecates(self, want, is_nbr=False): # want["local_as"]["asn"] = str(want["local_as"]["number"]) # del want["local_as"]["number"] # return want +======= +>>>>>>> Stashed changes diff --git a/plugins/modules/ios_bgp_global.py b/plugins/modules/ios_bgp_global.py index 8a13e55a6..98093449b 100644 --- a/plugins/modules/ios_bgp_global.py +++ b/plugins/modules/ios_bgp_global.py @@ -970,7 +970,7 @@ type: bool number: description: - - DEPRECATED: This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead. + - "DEPRECATED: This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead." - AS number used as local AS - Please refer vendor documentation for valid values type: int diff --git a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml index f7fd02ba4..ffe4b52ef 100644 --- a/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml +++ b/tests/integration/targets/ios_bgp_global/tests/cli/merged.yaml @@ -11,6 +11,7 @@ config: as_number: 65000 bgp: + asnotation: true default: ipv4_unicast: false route_target: @@ -27,6 +28,22 @@ remote_as: 100 shutdown: set: false + - neighbor_address: 192.0.2.1 + remote_as: "500.65083" + local_as: + asn: "501.65083" + no_prepend: + replace_as: true + set: true + set: true + - neighbor_address: 192.0.2.2 + remote_as: 500 + local_as: + number: 501 + no_prepend: + replace_as: true + set: true + set: true timers: keepalive: 100 holdtime: 200 diff --git a/tests/integration/targets/ios_bgp_global/vars/main.yaml b/tests/integration/targets/ios_bgp_global/vars/main.yaml index 71dd2788f..5720d1c34 100644 --- a/tests/integration/targets/ios_bgp_global/vars/main.yaml +++ b/tests/integration/targets/ios_bgp_global/vars/main.yaml @@ -11,10 +11,15 @@ merged: - bgp log-neighbor-changes - neighbor 198.0.2.1 remote-as 100 - neighbor 198.0.2.1 description merge neighbor - + - bgp asnotation dot + - neighbor 192.0.2.1 remote-as 500.65083 + - neighbor 192.0.2.1 local-as 501.65083 no-prepend replace-as + - neighbor 192.0.2.2 remote-as 500 + - neighbor 192.0.2.2 local-as 501 no-prepend replace-as after: as_number: "65000" bgp: + asnotation: true default: ipv4_unicast: false route_target: @@ -26,6 +31,22 @@ merged: time: 50 log_neighbor_changes: true neighbors: + - local_as: + no_prepend: + replace_as: true + set: true + asn: "501.65083" + set: true + neighbor_address: "192.0.2.1" + remote_as: "500.65083" + - local_as: + no_prepend: + replace_as: true + set: true + asn: "501" + set: true + neighbor_address: "192.0.2.2" + remote_as: "500" - description: merge neighbor neighbor_address: 198.0.2.1 remote_as: "100" diff --git a/tests/unit/modules/network/ios/test_ios_bgp_global.py b/tests/unit/modules/network/ios/test_ios_bgp_global.py index 4cc370142..5b09dbad4 100644 --- a/tests/unit/modules/network/ios/test_ios_bgp_global.py +++ b/tests/unit/modules/network/ios/test_ios_bgp_global.py @@ -919,46 +919,3 @@ def test_ios_bgp_global_merged_asn(self): ] result = self.execute_module(changed=True) self.assertEqual(sorted(result["commands"]), sorted(commands)) - - def test_ios_bgp_global_merged_num(self): - set_module_args( - dict( - config=dict( - as_number="65000", - bgp=dict( - asnotation=True, - log_neighbor_changes=True, - graceful_shutdown=dict( - neighbors=dict(time=50), - local_preference=100, - community="100", - ), - ), - neighbors=[ - dict( - neighbor_address="192.0.2.1", - remote_as="600.65083", - local_as=dict( - number="701", - no_prepend=dict( - replace_as=True, - set=True, - ), - set=True, - ), - ), - ], - ), - state="merged", - ), - ) - commands = [ - "router bgp 65000", - "bgp asnotation dot", - "bgp log-neighbor-changes", - "bgp graceful-shutdown all neighbors 50 local-preference 100 community 100", - "neighbor 192.0.2.1 remote-as 600.65083", - "neighbor 192.0.2.1 local-as 701 no-prepend replace-as", - ] - result = self.execute_module(changed=True) - self.assertEqual(sorted(result["commands"]), sorted(commands)) From 9669da0ebafd030103309e6a6dc06b819d567705 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:30:24 +0000 Subject: [PATCH 18/19] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- docs/cisco.ios.ios_bgp_global_module.rst | 2 +- .../network/ios/argspec/bgp_global/bgp_global.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/cisco.ios.ios_bgp_global_module.rst b/docs/cisco.ios.ios_bgp_global_module.rst index a5250ffd4..4f9135a10 100644 --- a/docs/cisco.ios.ios_bgp_global_module.rst +++ b/docs/cisco.ios.ios_bgp_global_module.rst @@ -4917,7 +4917,7 @@ Parameters -
{'DEPRECATED': "This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead."}
+
DEPRECATED: This option is deprecated and will be removed at/as of jan 2027. Use 'asn' instead.
AS number used as local AS
Please refer vendor documentation for valid values
diff --git a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py index d72589047..eb72f7687 100644 --- a/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/argspec/bgp_global/bgp_global.py @@ -500,10 +500,10 @@ class Bgp_globalArgs(object): # pylint: disable=R0903 "type": "dict", "options": { "set": {"type": "bool"}, - 'number': { - 'type': 'int', - 'removed_at_date': '2027-01-31', - 'removed_from_collection': 'cisco.ios', + "number": { + "type": "int", + "removed_at_date": "2027-01-31", + "removed_from_collection": "cisco.ios", }, "asn": {"type": "str"}, "dual_as": {"type": "bool"}, From b050f35ed913bebcac878d4fbc334ab4886e484a Mon Sep 17 00:00:00 2001 From: Girish5tri Date: Fri, 18 Oct 2024 17:27:15 +0530 Subject: [PATCH 19/19] newly --- .../ios/config/bgp_global/bgp_global.py | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py index c3f11426a..6cb3986df 100644 --- a/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py +++ b/plugins/module_utils/network/ios/config/bgp_global/bgp_global.py @@ -141,10 +141,6 @@ def execute_module(self): :returns: The result from module execution """ if self.state not in ["parsed", "gathered"]: -<<<<<<< Updated upstream - # self.want = self.handle_deprecates(self.want) -======= ->>>>>>> Stashed changes self.generate_commands() self.run_commands() return self.result @@ -465,27 +461,3 @@ def handle_deprecates(self, want, is_nbr=False): if "number" in want["local_as"]: want["local_as"]["asn"] = str(want["local_as"].pop("number")) return want -<<<<<<< Updated upstream - - # def handle_deprecates(self, want, is_nbr=False): - # """ - # Handles deprecated values post rewrite - # neighbor.route_map [dict] - neighbor.route_maps [list:dict] - - # Args: - # want (_type_): Handle want attributes for deprecated values - # is_nbr (bool, optional): activates neighbor part on recursion. Defaults to False. - # """ - # if not is_nbr: - # if want.get("neighbors"): - # _want_nbrs = want.get("neighbors", {}) - # for nbr in _want_nbrs: - # nbr = self.handle_deprecates(nbr, is_nbr=True) - # else: - # if "local_as" in want: - # if "number" in want["local_as"]: - # want["local_as"]["asn"] = str(want["local_as"]["number"]) - # del want["local_as"]["number"] - # return want -======= ->>>>>>> Stashed changes