Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix BGP ASDOT notation handling in ios_bgp_global module #1124

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/fix_bgp_asdot_error.yml
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion docs/cisco.ios.ios_bgp_global_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4892,7 +4892,7 @@ Parameters
<b>number</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">integer</span>
<span style="color: purple">string</span>
</div>
</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class Bgp_globalArgs(object): # pylint: disable=R0903
"type": "dict",
"options": {
"set": {"type": "bool"},
"number": {"type": "int"},
"number": {"type": "str"},
roverflow marked this conversation as resolved.
Show resolved Hide resolved
roverflow marked this conversation as resolved.
Show resolved Hide resolved
"dual_as": {"type": "bool"},
"no_prepend": {
"type": "dict",
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ios_bgp_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 46 additions & 0 deletions tests/unit/modules/network/ios/test_ios_bgp_global.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,3 +790,49 @@ 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"])
Loading